summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Vasut <[email protected]>2023-09-01 11:49:55 +0200
committerMarek Vasut <[email protected]>2023-09-15 23:38:02 +0200
commitedd6042d450286d98b20667b20f1ca4e5c579ee0 (patch)
treefefea5e0e6bb83f32b66f43d64240c34a8bb9a32
parentf032260c7c336cf88c1914286fd42a1588080db3 (diff)
dfu: Detach the controller on error
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 <[email protected]> Signed-off-by: Marek Vasut <[email protected]>
-rw-r--r--common/dfu.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/common/dfu.c b/common/dfu.c
index 96190889ab7..32fba84da16 100644
--- a/common/dfu.c
+++ b/common/dfu.c
@@ -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)