[PATCH v2 11/17] spl: sdp: Detach the controller on error

Marek Vasut marex at denx.de
Fri Sep 1 11:49:57 CEST 2023


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 at baylibre.com>
Signed-off-by: Marek Vasut <marex at denx.de>
---
Cc: Angus Ainslie <angus at akkea.ca>
Cc: Dmitrii Merkurev <dimorinny at google.com>
Cc: Eddie Cai <eddie.cai.linux at gmail.com>
Cc: Kever Yang <kever.yang at rock-chips.com>
Cc: Lukasz Majewski <lukma at denx.de>
Cc: Miquel Raynal <miquel.raynal at bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek at baylibre.com>
Cc: Nishanth Menon <nm at ti.com>
Cc: Patrice Chotard <patrice.chotard at foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay at foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich at vrull.eu>
Cc: Simon Glass <sjg at chromium.org>
Cc: Stefan Roese <sr at denx.de>
Cc: kernel at puri.sm
---
V2: - Call g_dnl_unregister() in case sdp_init() fails and on regular exit
    - Add RB from Mattijs
---
 common/spl/spl_sdp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
index cc4fb4f7cca..aae886d2e57 100644
--- a/common/spl/spl_sdp.c
+++ b/common/spl/spl_sdp.c
@@ -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;
 }
-- 
2.40.1



More information about the U-Boot mailing list