* [PATCH master] usbgadget: autostart: don't print error on repeated nv.usbgadget.autostart=1
@ 2020-11-20 14:07 Ahmad Fatoum
2020-11-24 8:34 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2020-11-20 14:07 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
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>
---
common/usbgadget.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/common/usbgadget.c b/common/usbgadget.c
index fb508db94762..8b351c7bf468 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)
--
2.29.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH master] usbgadget: autostart: don't print error on repeated nv.usbgadget.autostart=1
2020-11-20 14:07 [PATCH master] usbgadget: autostart: don't print error on repeated nv.usbgadget.autostart=1 Ahmad Fatoum
@ 2020-11-24 8:34 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2020-11-24 8:34 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Fri, Nov 20, 2020 at 03:07:28PM +0100, Ahmad Fatoum wrote:
> 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>
> ---
> common/usbgadget.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/common/usbgadget.c b/common/usbgadget.c
> index fb508db94762..8b351c7bf468 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)
> --
> 2.29.2
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-24 8:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20 14:07 [PATCH master] usbgadget: autostart: don't print error on repeated nv.usbgadget.autostart=1 Ahmad Fatoum
2020-11-24 8:34 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox