[PATCH 10/17] dfu: Use plain udevice for UDC controller interaction

Marek Vasut marex at denx.de
Sat Aug 19 16:24:00 CEST 2023


Convert to plain udevice interaction with UDC controller
device, avoid the use of UDC uclass dev_array .

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
---
 common/dfu.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/common/dfu.c b/common/dfu.c
index 32fba84da16..45206b9e225 100644
--- a/common/dfu.c
+++ b/common/dfu.c
@@ -23,11 +23,12 @@
 int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
 {
 	bool dfu_reset = false;
+	struct udevice *udc;
 	int ret, i = 0;
 
-	ret = usb_gadget_initialize(usbctrl_index);
+	ret = udc_device_get_by_index(usbctrl_index, &udc);
 	if (ret) {
-		pr_err("usb_gadget_initialize failed\n");
+		pr_err("udc_device_get_by_index failed\n");
 		return CMD_RET_FAILURE;
 	}
 	g_dnl_clear_detach();
@@ -55,7 +56,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
 			}
 
 			/*
-			 * This extra number of usb_gadget_handle_interrupts()
+			 * This extra number of dm_usb_gadget_handle_interrupts()
 			 * calls is necessary to assure correct transmission
 			 * completion with dfu-util
 			 */
@@ -68,7 +69,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
 
 		if (dfu_get_defer_flush()) {
 			/*
-			 * Call to usb_gadget_handle_interrupts() is necessary
+			 * Call to dm_usb_gadget_handle_interrupts() is necessary
 			 * to act on ZLP OUT transaction from HOST PC after
 			 * transmitting the whole file.
 			 *
@@ -77,7 +78,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
 			 * 5 seconds). In such situation the dfu-util program
 			 * exits with error message.
 			 */
-			usb_gadget_handle_interrupts(usbctrl_index);
+			dm_usb_gadget_handle_interrupts(udc);
 			ret = dfu_flush(dfu_get_defer_flush(), NULL, 0, 0);
 			dfu_set_defer_flush(NULL);
 			if (ret) {
@@ -103,12 +104,12 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
 			goto exit;
 
 		schedule();
-		usb_gadget_handle_interrupts(usbctrl_index);
+		dm_usb_gadget_handle_interrupts(udc);
 	}
 exit:
 	g_dnl_unregister();
 err_detach:
-	usb_gadget_release(usbctrl_index);
+	udc_device_put(udc);
 
 	if (dfu_reset)
 		do_reset(NULL, 0, 0, NULL);
-- 
2.40.1



More information about the U-Boot mailing list