diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2020-11-20 15:07:28 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-11-24 09:34:36 +0100 |
commit | 7cc491383b9de67abfd5bb9e1222287243cc3741 (patch) | |
tree | 3b4c5924f6f72c7753e1accd19e4632ebe0b9dbc /common | |
parent | 44fbe88055bbb7746ba3b0a30e0a9a8217c733d6 (diff) | |
download | barebox-7cc491383b9de67abfd5bb9e1222287243cc3741.tar.gz barebox-7cc491383b9de67abfd5bb9e1222287243cc3741.tar.xz |
usbgadget: autostart: don't print error on repeated nv.usbgadget.autostart=1
nvvar_add results in two calls to dev_set_param:
- once when the existing global variable is found and set
- once more when setting the nv variable
This results in an annoying but ultimately harmless message on startup:
ERROR: USB multi gadget already registered
ERROR: failed to create nv variable usbgadget.autostart: Device or
resource busy
Avoid this by ignoring usbgadget.autostart=1 after it succeeded once.
This issue should only affect $global.usbgadget.autostart, because all
other global variables are "simple" meaning that they have no setters
triggered.
Fixes: 5a5c5178e7dc ("usbgadget: autostart: support delayed usbgadget.autostart=1")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/usbgadget.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/common/usbgadget.c b/common/usbgadget.c index fb508db947..8b351c7bf4 100644 --- a/common/usbgadget.c +++ b/common/usbgadget.c @@ -102,12 +102,18 @@ int usbgadget_register(bool dfu, const char *dfu_opts, static int usbgadget_autostart_set(struct param_d *param, void *ctx) { + static bool started; bool fastboot_bbu = get_fastboot_bbu(); + int err; - if (!IS_ENABLED(CONFIG_USB_GADGET_AUTOSTART) || !autostart) + if (!IS_ENABLED(CONFIG_USB_GADGET_AUTOSTART) || !autostart || started) return 0; - return usbgadget_register(true, NULL, true, NULL, acm, fastboot_bbu); + err = usbgadget_register(true, NULL, true, NULL, acm, fastboot_bbu); + if (!err) + started = true; + + return err; } static int usbgadget_globalvars_init(void) |