diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2020-09-28 16:45:05 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-09-29 10:25:02 +0200 |
commit | 5a5c5178e7dc6a58a059fe4a1f4167a31809ccaf (patch) | |
tree | 0e651561524a6e8ff4086ca7c8aa5ba67370c2cd /common | |
parent | d877a4436bb960e6b942510c3de37b9bd048c1ba (diff) | |
download | barebox-5a5c5178e7dc6a58a059fe4a1f4167a31809ccaf.tar.gz barebox-5a5c5178e7dc6a58a059fe4a1f4167a31809ccaf.tar.xz |
usbgadget: autostart: support delayed usbgadget.autostart=1
So far, global.usbgadget.autostart=1 from the shell was without effect,
because the variable is only evaluated once at postenvironment_initcall.
Use the new globalvar_add_bool() to allow acting on the variable being
true at any time. This is necessary for scripts that want to enable
the usbgadget autostart functionality selectively without themselves
hardcoding the particularities of what is exported.
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 | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/common/usbgadget.c b/common/usbgadget.c index b4f4ba04ca..be2bcc467d 100644 --- a/common/usbgadget.c +++ b/common/usbgadget.c @@ -101,7 +101,7 @@ int usbgadget_register(bool dfu, const char *dfu_opts, return ret; } -static int usbgadget_autostart(void) +static int usbgadget_autostart_set(struct param_d *param, void *ctx) { bool fastboot_bbu = get_fastboot_bbu(); @@ -110,12 +110,12 @@ static int usbgadget_autostart(void) return usbgadget_register(true, NULL, true, NULL, acm, fastboot_bbu); } -postenvironment_initcall(usbgadget_autostart); static int usbgadget_globalvars_init(void) { if (IS_ENABLED(CONFIG_USB_GADGET_AUTOSTART)) { - globalvar_add_simple_bool("usbgadget.autostart", &autostart); + globalvar_add_bool("usbgadget.autostart", usbgadget_autostart_set, + &autostart, NULL); globalvar_add_simple_bool("usbgadget.acm", &acm); } globalvar_add_simple_string("usbgadget.dfu_function", &dfu_function); |