From 44add42d43300a330647704141c5a285358361db Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Fri, 26 Oct 2018 17:39:10 +0200 Subject: usbgadget: autostart: add DFU support Use global variable dfu_function to autostart DFU. As similar code is used to start multifunction gadget using command, move common code to common/usbgadget.c and consolidate it. It turned out that '-s' option of usbgadget command does nothing, so remove its help text and make it function as '-a'. Signed-off-by: Ladislav Michl Signed-off-by: Sascha Hauer --- drivers/usb/gadget/Kconfig | 8 ++-- drivers/usb/gadget/Makefile | 1 - drivers/usb/gadget/autostart.c | 98 ------------------------------------------ 3 files changed, 3 insertions(+), 104 deletions(-) delete mode 100644 drivers/usb/gadget/autostart.c (limited to 'drivers') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index b0408e3bbe..ca1bfc1b4e 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -33,13 +33,11 @@ config USB_GADGET_DRIVER_PXA27X config USB_GADGET_AUTOSTART bool default y - select ENVIRONMENT_VARIABLES - select FILE_LIST prompt "Automatically start usbgadget on boot" help - Enabling this option allows to automatically start a fastboot - gadget during boot. This behaviour is controlled with the - global.usbgadget.fastboot_function variable. + Enabling this option allows to automatically start a dfu or + fastboot gadget during boot. This behaviour is controlled with + the global.usbgadget.{dfu,fastboot}_function variable. comment "USB Gadget drivers" diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index e74cf02664..9ef594575b 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -1,6 +1,5 @@ obj-$(CONFIG_USB_GADGET) += composite.o config.o usbstring.o epautoconf.o udc-core.o functions.o config.o multi.o -obj-$(CONFIG_USB_GADGET_AUTOSTART) += autostart.o obj-$(CONFIG_USB_GADGET_SERIAL) += u_serial.o serial.o f_serial.o f_acm.o obj-$(CONFIG_USB_GADGET_DFU) += dfu.o obj-$(CONFIG_USB_GADGET_FASTBOOT) += f_fastboot.o diff --git a/drivers/usb/gadget/autostart.c b/drivers/usb/gadget/autostart.c deleted file mode 100644 index f640a9667d..0000000000 --- a/drivers/usb/gadget/autostart.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2017 Oleksij Rempel , Pengutronix - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -#define pr_fmt(fmt) "usbgadget autostart: " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static int autostart; -static int acm; -static char *fastboot_function; -static int fastboot_bbu; - -static int usbgadget_autostart(void) -{ - struct f_multi_opts *opts; - int ret; - - if (!autostart) - return 0; - - opts = xzalloc(sizeof(*opts)); - opts->release = usb_multi_opts_release; - - if (fastboot_function) { - opts->fastboot_opts.files = file_list_parse(fastboot_function); - if (IS_ERR(opts->fastboot_opts.files)) { - pr_err("Parsing file list \"%s\" failed: %s\n", fastboot_function, - strerrorp(opts->fastboot_opts.files)); - opts->fastboot_opts.files = NULL; - } - - opts->fastboot_opts.export_bbu = fastboot_bbu; - } - - opts->create_acm = acm; - - if (!opts->fastboot_opts.files && !opts->create_acm) { - pr_warn("No functions to register\n"); - return 0; - } - - setenv("otg.mode", "peripheral"); - - ret = usb_multi_register(opts); - if (ret) - usb_multi_opts_release(opts); - - return ret; -} -postenvironment_initcall(usbgadget_autostart); - -static int usbgadget_globalvars_init(void) -{ - - globalvar_add_simple_bool("usbgadget.autostart", &autostart); - globalvar_add_simple_bool("usbgadget.acm", &acm); - globalvar_add_simple_string("usbgadget.fastboot_function", - &fastboot_function); - globalvar_add_simple_bool("usbgadget.fastboot_bbu", &fastboot_bbu); - - return 0; -} -device_initcall(usbgadget_globalvars_init); - -BAREBOX_MAGICVAR_NAMED(global_usbgadget_autostart, - global.usbgadget.autostart, - "usbgadget: Automatically start usbgadget on boot"); -BAREBOX_MAGICVAR_NAMED(global_usbgadget_acm, - global.usbgadget.acm, - "usbgadget: Create CDC ACM function"); -BAREBOX_MAGICVAR_NAMED(global_usbgadget_fastboot_function, - global.usbgadget.fastboot_function, - "usbgadget: Create Android Fastboot function"); -BAREBOX_MAGICVAR_NAMED(global_usbgadget_fastboot_bbu, - global.usbgadget.fastboot_bbu, - "usbgadget: export barebox update handlers via fastboot"); -- cgit v1.2.3