]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dfu: Detach the controller on error
authorMarek Vasut <marex@denx.de>
Fri, 1 Sep 2023 09:49:55 +0000 (11:49 +0200)
committerMarek Vasut <marex@denx.de>
Fri, 15 Sep 2023 21:38:02 +0000 (23:38 +0200)
In case anything errors out during the DFU registration, detach
the controller instead of bailing out right away. This way, the
controller can be reattached on next attempt.

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Signed-off-by: Marek Vasut <marex@denx.de>
common/dfu.c

index 96190889ab770ed5a445aab8036439a956b7007b..32fba84da160538afb84b97d11bc3f27ff901ea6 100644 (file)
@@ -34,7 +34,8 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
        ret = g_dnl_register(usb_dnl_gadget);
        if (ret) {
                pr_err("g_dnl_register failed");
-               return CMD_RET_FAILURE;
+               ret = CMD_RET_FAILURE;
+               goto err_detach;
        }
 
 #ifdef CONFIG_DFU_TIMEOUT
@@ -106,6 +107,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
        }
 exit:
        g_dnl_unregister();
+err_detach:
        usb_gadget_release(usbctrl_index);
 
        if (dfu_reset)