From bf03086f1aa66abd50d440db7895dfd535095e0c Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 09:47:24 +0200 Subject: usbgadget: autostart: Handle errors in file list gracefully file_list_parse() can fail and returns an error pointer. Print an error message when it fails and also set to NULL again so that usb_multi_register() does not stumble upon the error pointer. Signed-off-by: Sascha Hauer --- drivers/usb/gadget/autostart.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/autostart.c b/drivers/usb/gadget/autostart.c index 465d8fd380..3fa43137fa 100644 --- a/drivers/usb/gadget/autostart.c +++ b/drivers/usb/gadget/autostart.c @@ -11,6 +11,8 @@ * GNU General Public License for more details. * */ +#define pr_fmt(fmt) "usbgadget autostart: " fmt + #include #include #include @@ -42,8 +44,14 @@ static int usbgadget_autostart(void) opts = xzalloc(sizeof(*opts)); opts->release = usb_multi_opts_release; - if (fastboot_function) + 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->create_acm = acm; -- cgit v1.2.3 From bc7e00c45bf479258f033a454e3c538d164c4ea5 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 09:49:00 +0200 Subject: usbgadget: do not register when no functions present registering a multifunction device makes only sense when there's at least one function configured. Just return otherwise. Signed-off-by: Sascha Hauer --- drivers/usb/gadget/autostart.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/gadget/autostart.c b/drivers/usb/gadget/autostart.c index 3fa43137fa..a27be899c3 100644 --- a/drivers/usb/gadget/autostart.c +++ b/drivers/usb/gadget/autostart.c @@ -55,6 +55,10 @@ static int usbgadget_autostart(void) opts->create_acm = acm; + if (!opts->fastboot_opts.files && !opts->create_acm) { + pr_warn("No functions to register\n"); + return 0; + } ret = usb_multi_register(opts); if (ret) -- cgit v1.2.3 From 9e6ddf343d61a6b2bb2a6dea8e4a34137a2978f9 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 09:55:46 +0200 Subject: usbgadget: only set to peripheral mode when error checking is done Only begin to modify the hardware when the obious errors have been checked. Signed-off-by: Sascha Hauer --- drivers/usb/gadget/autostart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/autostart.c b/drivers/usb/gadget/autostart.c index a27be899c3..2ca979057e 100644 --- a/drivers/usb/gadget/autostart.c +++ b/drivers/usb/gadget/autostart.c @@ -39,8 +39,6 @@ static int usbgadget_autostart(void) if (!autostart) return 0; - setenv("otg.mode", "peripheral"); - opts = xzalloc(sizeof(*opts)); opts->release = usb_multi_opts_release; @@ -60,6 +58,8 @@ static int usbgadget_autostart(void) return 0; } + setenv("otg.mode", "peripheral"); + ret = usb_multi_register(opts); if (ret) usb_multi_opts_release(opts); -- cgit v1.2.3 From 87f3efc26e3f4d8f171c56bdd819088f79e1110c Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 10:06:37 +0200 Subject: usbgadget: unregister when usb_composite_probe() fails When usb_multi_register() returns an error it can't be called again as we do not unregister the driver properly. Fix this. Signed-off-by: Sascha Hauer --- drivers/usb/gadget/multi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index 6385c16186..6eeeb4e982 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c @@ -234,6 +234,8 @@ static struct usb_composite_driver multi_driver = { int usb_multi_register(struct f_multi_opts *opts) { + int ret; + if (gadget_multi_opts) { pr_err("USB multi gadget already registered\n"); return -EBUSY; @@ -241,7 +243,13 @@ int usb_multi_register(struct f_multi_opts *opts) gadget_multi_opts = opts; - return usb_composite_probe(&multi_driver); + ret = usb_composite_probe(&multi_driver); + if (ret) { + usb_composite_unregister(&multi_driver); + gadget_multi_opts = NULL; + } + + return ret; } void usb_multi_unregister(void) -- cgit v1.2.3 From 9f36f6d615ab6eca2e37823213c0f6f3ead25921 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 12:17:53 +0200 Subject: file_list: Add function to add an entry to the list Add file_list_add_entry() to add a single entry to a file_list. Then use it in file_list_parse_one() instead of open coding adding a new entry. Signed-off-by: Sascha Hauer --- common/file-list.c | 28 +++++++++++++++++++--------- include/file-list.h | 3 +++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/common/file-list.c b/common/file-list.c index 90c0f429c5..010f8f0617 100644 --- a/common/file-list.c +++ b/common/file-list.c @@ -8,12 +8,26 @@ #define PARSE_NAME 1 #define PARSE_FLAGS 2 +int file_list_add_entry(struct file_list *files, const char *name, const char *filename, + unsigned long flags) +{ + struct file_list_entry *entry = xzalloc(sizeof(*entry)); + + entry->name = xstrdup(name); + entry->filename = xstrdup(filename); + entry->flags = flags; + + list_add_tail(&entry->list, &files->list); + + return 0; +} + static int file_list_parse_one(struct file_list *files, const char *partstr, const char **endstr) { int i = 0, state = PARSE_DEVICE; char filename[PATH_MAX]; char name[PATH_MAX]; - struct file_list_entry *entry = xzalloc(sizeof(*entry)); + unsigned long flags = 0; memset(filename, 0, sizeof(filename)); memset(name, 0, sizeof(name)); @@ -39,13 +53,13 @@ static int file_list_parse_one(struct file_list *files, const char *partstr, con case PARSE_FLAGS: switch (*partstr) { case 's': - entry->flags |= FILE_LIST_FLAG_SAFE; + flags |= FILE_LIST_FLAG_SAFE; break; case 'r': - entry->flags |= FILE_LIST_FLAG_READBACK; + flags |= FILE_LIST_FLAG_READBACK; break; case 'c': - entry->flags |= FILE_LIST_FLAG_CREATE; + flags |= FILE_LIST_FLAG_CREATE; break; default: return -EINVAL; @@ -60,15 +74,11 @@ static int file_list_parse_one(struct file_list *files, const char *partstr, con if (state != PARSE_FLAGS) return -EINVAL; - entry->name = xstrdup(name); - entry->filename = xstrdup(filename); if (*partstr == ',') partstr++; *endstr = partstr; - list_add_tail(&entry->list, &files->list); - - return 0; + return file_list_add_entry(files, name, filename, flags); } struct file_list *file_list_parse(const char *str) diff --git a/include/file-list.h b/include/file-list.h index 608181ff8d..ccdc2b5efd 100644 --- a/include/file-list.h +++ b/include/file-list.h @@ -20,6 +20,9 @@ struct file_list { struct file_list *file_list_parse(const char *str); void file_list_free(struct file_list *); +int file_list_add_entry(struct file_list *files, const char *name, const char *filename, + unsigned long flags); + #define file_list_for_each_entry(files, entry) \ list_for_each_entry(entry, &files->list, list) -- cgit v1.2.3 From dc8c2c4b942f499fedb284b096eff3b2b9970b9c Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 12:21:51 +0200 Subject: file_list: Add function to get entry by its name Signed-off-by: Sascha Hauer --- common/file-list.c | 12 ++++++++++++ include/file-list.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/common/file-list.c b/common/file-list.c index 010f8f0617..0b760c1aec 100644 --- a/common/file-list.c +++ b/common/file-list.c @@ -8,6 +8,18 @@ #define PARSE_NAME 1 #define PARSE_FLAGS 2 +struct file_list_entry *file_list_entry_by_name(struct file_list *files, const char *name) +{ + struct file_list_entry *entry; + + file_list_for_each_entry(files, entry) { + if (!strcmp(entry->name, name)) + return entry; + } + + return NULL; +} + int file_list_add_entry(struct file_list *files, const char *name, const char *filename, unsigned long flags) { diff --git a/include/file-list.h b/include/file-list.h index ccdc2b5efd..1e02539d4d 100644 --- a/include/file-list.h +++ b/include/file-list.h @@ -23,6 +23,8 @@ void file_list_free(struct file_list *); int file_list_add_entry(struct file_list *files, const char *name, const char *filename, unsigned long flags); +struct file_list_entry *file_list_entry_by_name(struct file_list *files, const char *name); + #define file_list_for_each_entry(files, entry) \ list_for_each_entry(entry, &files->list, list) -- cgit v1.2.3 From 9710d39e0de75ca5fd5a5d9c6de4fe4efba31790 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 12:22:59 +0200 Subject: file_list: Allow only unique names on list The key to a file_list is it's name, so ensure it's unique. Signed-off-by: Sascha Hauer --- common/file-list.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/common/file-list.c b/common/file-list.c index 0b760c1aec..e13d5af659 100644 --- a/common/file-list.c +++ b/common/file-list.c @@ -23,7 +23,13 @@ struct file_list_entry *file_list_entry_by_name(struct file_list *files, const c int file_list_add_entry(struct file_list *files, const char *name, const char *filename, unsigned long flags) { - struct file_list_entry *entry = xzalloc(sizeof(*entry)); + struct file_list_entry *entry; + + entry = file_list_entry_by_name(files, name); + if (entry) + return -EEXIST; + + entry = xzalloc(sizeof(*entry)); entry->name = xstrdup(name); entry->filename = xstrdup(filename); -- cgit v1.2.3 From 6d328ea1369f42b6a5658d548461991585534631 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 13:51:13 +0200 Subject: file_list: Fix memory leak in failure path In case of a parse error not only the list header has to be freed, but also the entries. Use file_list_free() for this purpose. Signed-off-by: Sascha Hauer --- common/file-list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/file-list.c b/common/file-list.c index e13d5af659..be8f53bd89 100644 --- a/common/file-list.c +++ b/common/file-list.c @@ -122,7 +122,7 @@ struct file_list *file_list_parse(const char *str) return files; out: - free(files); + file_list_free(files); return ERR_PTR(ret); } -- cgit v1.2.3 From bee9b68fe08dc7df01d80ec784841026345e4931 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 13:52:26 +0200 Subject: file_list: Add GPL header to file Signed-off-by: Sascha Hauer --- common/file-list.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/file-list.c b/common/file-list.c index be8f53bd89..0c3cb0a4e7 100644 --- a/common/file-list.c +++ b/common/file-list.c @@ -1,3 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; version 2. + * + * 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. + */ + #include #include #include -- cgit v1.2.3 From d1ccb5df97750f0aa61bb70b173bfdfbbe4f0d6b Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 13:58:28 +0200 Subject: file_list: Add error messages Add error messages when file list parsing fails. Also, forward the error from file_list_parse_one() instead of using -EINVAL for every error. Signed-off-by: Sascha Hauer --- common/file-list.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/common/file-list.c b/common/file-list.c index 0c3cb0a4e7..8d61b76cbb 100644 --- a/common/file-list.c +++ b/common/file-list.c @@ -9,6 +9,8 @@ * General Public License for more details. */ +#define pr_fmt(fmt) "file_list: " fmt + #include #include #include @@ -91,6 +93,7 @@ static int file_list_parse_one(struct file_list *files, const char *partstr, con flags |= FILE_LIST_FLAG_CREATE; break; default: + pr_err("Unknown flag '%c'\n", *partstr); return -EINVAL; } break; @@ -100,8 +103,10 @@ static int file_list_parse_one(struct file_list *files, const char *partstr, con partstr++; } - if (state != PARSE_FLAGS) + if (state != PARSE_FLAGS) { + pr_err("Missing ')'\n"); return -EINVAL; + } if (*partstr == ',') partstr++; @@ -121,9 +126,9 @@ struct file_list *file_list_parse(const char *str) INIT_LIST_HEAD(&files->list); while (*str) { - if (file_list_parse_one(files, str, &endptr)) { - printf("parse error\n"); - ret = -EINVAL; + ret = file_list_parse_one(files, str, &endptr); + if (ret) { + pr_err("parse error\n"); goto out; } str = endptr; -- cgit v1.2.3 From a3976c3a84f204b005835dd6b358d72b18eeffa3 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 12:25:17 +0200 Subject: usbgadget: fastboot: Use function to find file_list entry by name We have file_list_entry_by_name() now, so use it rather than open coding it. Signed-off-by: Sascha Hauer --- drivers/usb/gadget/f_fastboot.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 598637619d..0f2c02ee47 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -679,18 +679,15 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req, const char *cmd fastboot_tx_print(f_fb, "INFOCopying file to %s...", cmd); - file_list_for_each_entry(f_fb->files, fentry) { - if (!strcmp(cmd, fentry->name)) { - filename = fentry->filename; - break; - } - } + fentry = file_list_entry_by_name(f_fb->files, cmd); - if (!filename) { + if (!fentry) { fastboot_tx_print(f_fb, "FAILNo such partition: %s", cmd); return; } + filename = fentry->filename; + if (filetype == filetype_ubi) { int fd; struct mtd_info_user meminfo; -- cgit v1.2.3 From bed2c7741b185d8242a70529bbfbcc20b3a84418 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 12:27:32 +0200 Subject: bbu: Add function to iterate over registered handlers Signed-off-by: Sascha Hauer --- common/bbu.c | 15 +++++++++++++++ include/bbu.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/common/bbu.c b/common/bbu.c index 031c433820..3b372263b1 100644 --- a/common/bbu.c +++ b/common/bbu.c @@ -30,6 +30,21 @@ static LIST_HEAD(bbu_image_handlers); +int bbu_handlers_iterate(int (*fn)(struct bbu_handler *, void *), void *ctx) +{ + struct bbu_handler *handler; + + list_for_each_entry(handler, &bbu_image_handlers, list) { + int ret; + + ret = fn(handler, ctx); + if (ret) + return ret; + } + + return 0; +} + int bbu_force(struct bbu_data *data, const char *fmt, ...) { va_list args; diff --git a/include/bbu.h b/include/bbu.h index 9d24ffc395..54434b03e0 100644 --- a/include/bbu.h +++ b/include/bbu.h @@ -42,6 +42,8 @@ bool barebox_update_handler_exists(struct bbu_data *); void bbu_handlers_list(void); +int bbu_handlers_iterate(int (*fn)(struct bbu_handler *, void *), void *); + #ifdef CONFIG_BAREBOX_UPDATE int bbu_register_handler(struct bbu_handler *); -- cgit v1.2.3 From 02ade8d921def6b826163302afe6914a3543d175 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 12:53:58 +0200 Subject: usbgadget command: catch errors when parsing the file list file_list_parse() can fail. Print an error message in this case instead of crashing. Signed-off-by: Sascha Hauer --- commands/usbgadget.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/commands/usbgadget.c b/commands/usbgadget.c index ba09f97847..59359098ad 100644 --- a/commands/usbgadget.c +++ b/commands/usbgadget.c @@ -83,10 +83,14 @@ static int do_usbgadget(int argc, char *argv[]) if (fastboot_opts) { opts->fastboot_opts.files = file_list_parse(fastboot_opts); + if (IS_ERR(opts->fastboot_opts.files)) + goto err_parse; } if (dfu_opts) { opts->dfu_opts.files = file_list_parse(dfu_opts); + if (IS_ERR(opts->dfu_opts.files)) + goto err_parse; } if (create_serial) { @@ -98,6 +102,13 @@ static int do_usbgadget(int argc, char *argv[]) usb_multi_opts_release(opts); return ret; + +err_parse: + printf("Cannot parse file list \"%s\": %s\n", fastboot_opts, strerrorp(opts->fastboot_opts.files)); + + free(opts); + + return 1; } BAREBOX_CMD_HELP_START(usbgadget) -- cgit v1.2.3 From 470ac4a7ba37dc1c09f2d59ba0f7bf7519d45d92 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 12:56:30 +0200 Subject: usbgadget: fastboot: Allow to automatically export the bbu handlers We have a list of registered handlers which take a barebox update. Do the next step and allow to automatically export them via fastboot so that barebox can be updated via fastboot without manually exporting the partition. Since this may not be desirable in all cases this behaviour is configurable. Signed-off-by: Sascha Hauer --- drivers/usb/gadget/f_fastboot.c | 18 ++++++++++++++++++ drivers/usb/gadget/multi.c | 1 + include/usb/fastboot.h | 7 +++++++ 3 files changed, 26 insertions(+) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 0f2c02ee47..85c64c05c8 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -283,6 +283,21 @@ out: return ret; } +static int fastboot_add_bbu_variables(struct bbu_handler *handler, void *ctx) +{ + struct f_fastboot *f_fb = ctx; + char *name; + int ret; + + name = basprintf("bbu-%s", handler->name); + + ret = file_list_add_entry(f_fb->files, name, handler->devicefile, 0); + + free(name); + + return ret; +} + static int fastboot_bind(struct usb_configuration *c, struct usb_function *f) { struct usb_composite_dev *cdev = c->cdev; @@ -302,6 +317,9 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f) var = fb_addvar(f_fb, "bootloader-version"); fb_setvar(var, release_string); + if (IS_ENABLED(CONFIG_BAREBOX_UPDATE) && opts->export_bbu) + bbu_handlers_iterate(fastboot_add_bbu_variables, f_fb); + file_list_for_each_entry(f_fb->files, fentry) { ret = fastboot_add_partition_variables(f_fb, fentry); if (ret) diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index 6eeeb4e982..44969be0c9 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c @@ -128,6 +128,7 @@ static int multi_bind_fastboot(struct usb_composite_dev *cdev) opts = container_of(fi_fastboot, struct f_fastboot_opts, func_inst); opts->files = gadget_multi_opts->fastboot_opts.files; + opts->export_bbu = gadget_multi_opts->fastboot_opts.export_bbu; f_fastboot = usb_get_function(fi_fastboot); if (IS_ERR(f_fastboot)) { diff --git a/include/usb/fastboot.h b/include/usb/fastboot.h index dab5a9a299..ced890c9ab 100644 --- a/include/usb/fastboot.h +++ b/include/usb/fastboot.h @@ -5,9 +5,16 @@ #include #include +/** + * struct f_fastboot_opts - options to configure the fastboot gadget + * @func_inst: The USB function instance to register on + * @files: A file_list containing the files (partitions) to export via fastboot + * @export_bbu: Automatically include the partitions provided by barebox update (bbu) + */ struct f_fastboot_opts { struct usb_function_instance func_inst; struct file_list *files; + bool export_bbu; }; #endif /* _USB_FASTBOOT_H */ -- cgit v1.2.3 From fa92b0bf757084f69780e533bc498106d51f6f5e Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 12:58:31 +0200 Subject: fastboot command: Add -b option to export bbu handlers When -b is given the usbgadget command will automatically export the registered bbu handlers via fastboot. Signed-off-by: Sascha Hauer --- commands/usbgadget.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/commands/usbgadget.c b/commands/usbgadget.c index 59359098ad..507871edd2 100644 --- a/commands/usbgadget.c +++ b/commands/usbgadget.c @@ -33,11 +33,11 @@ static int do_usbgadget(int argc, char *argv[]) { int opt, ret; - int acm = 1, create_serial = 0, fastboot_set = 0; + int acm = 1, create_serial = 0, fastboot_set = 0, fastboot_export_bbu = 0; const char *fastboot_opts = NULL, *dfu_opts = NULL; struct f_multi_opts *opts; - while ((opt = getopt(argc, argv, "asdA::D:")) > 0) { + while ((opt = getopt(argc, argv, "asdA::D:b")) > 0) { switch (opt) { case 'a': acm = 1; @@ -54,6 +54,9 @@ static int do_usbgadget(int argc, char *argv[]) fastboot_opts = optarg; fastboot_set = 1; break; + case 'b': + fastboot_export_bbu = 1; + break; case 'd': usb_multi_unregister(); return 0; @@ -85,6 +88,7 @@ static int do_usbgadget(int argc, char *argv[]) opts->fastboot_opts.files = file_list_parse(fastboot_opts); if (IS_ERR(opts->fastboot_opts.files)) goto err_parse; + opts->fastboot_opts.export_bbu = fastboot_export_bbu; } if (dfu_opts) { @@ -119,6 +123,7 @@ BAREBOX_CMD_HELP_OPT ("-a", "Create CDC ACM function") BAREBOX_CMD_HELP_OPT ("-s", "Create Generic Serial function") BAREBOX_CMD_HELP_OPT ("-A [desc]", "Create Android Fastboot function. If 'desc' is not provided,") BAREBOX_CMD_HELP_OPT ("", "trying to use 'global.usbgadget.fastboot_function' variable.") +BAREBOX_CMD_HELP_OPT ("-b", "include registered barebox update handlers (fastboot specific)") BAREBOX_CMD_HELP_OPT ("-D ", "Create DFU function") BAREBOX_CMD_HELP_OPT ("-d", "Disable the currently running gadget") BAREBOX_CMD_HELP_END -- cgit v1.2.3 From 05761813eff43493ee0519f0699a396de3f007a5 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 27 Sep 2017 13:46:40 +0200 Subject: usbgadget autostart: add usbgadget.fastboot_bbu to automatically export bbu handlers Signed-off-by: Sascha Hauer --- drivers/usb/gadget/autostart.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/gadget/autostart.c b/drivers/usb/gadget/autostart.c index 2ca979057e..f640a9667d 100644 --- a/drivers/usb/gadget/autostart.c +++ b/drivers/usb/gadget/autostart.c @@ -30,6 +30,7 @@ static int autostart; static int acm; static char *fastboot_function; +static int fastboot_bbu; static int usbgadget_autostart(void) { @@ -49,6 +50,8 @@ static int usbgadget_autostart(void) strerrorp(opts->fastboot_opts.files)); opts->fastboot_opts.files = NULL; } + + opts->fastboot_opts.export_bbu = fastboot_bbu; } opts->create_acm = acm; @@ -75,6 +78,7 @@ static int usbgadget_globalvars_init(void) 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; } @@ -89,3 +93,6 @@ BAREBOX_MAGICVAR_NAMED(global_usbgadget_acm, 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