]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
spl: sdp: Detach the controller on error
authorMarek Vasut <marex@denx.de>
Fri, 1 Sep 2023 09:49:57 +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 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>
common/spl/spl_sdp.c

index cc4fb4f7cca2183d1a4ff35afd46a07156ee2f2c..aae886d2e578a4fe7ad2bf9d56a031d5865b6f5c 100644 (file)
@@ -25,13 +25,13 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
        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;
        }
 
        /*
@@ -42,6 +42,9 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
        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;
 }