In case anything errors out during the SDP transfer, 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>
ret = g_dnl_register("usb_dnl_sdp");
if (ret) {
pr_err("SDP dnl register failed: %d\n", ret);
- return ret;
+ goto err_detach;
}
ret = sdp_init(controller_index);
if (ret) {
pr_err("SDP init failed: %d\n", ret);
- return -ENODEV;
+ goto err_unregister;
}
/*
ret = spl_sdp_handle(controller_index, spl_image, bootdev);
debug("SDP ended\n");
+err_unregister:
+ g_dnl_unregister();
+err_detach:
usb_gadget_release(controller_index);
return ret;
}