]> git.ipfire.org Git - thirdparty/u-boot.git/blobdiff - common/dfu.c
Init virtio before loading ENV from EXT4 or FAT
[thirdparty/u-boot.git] / common / dfu.c
index 96190889ab770ed5a445aab8036439a956b7007b..1af8194139c336389d9a331e8873022d13ef1ab4 100644 (file)
@@ -10,7 +10,6 @@
  *         Lukasz Majewski <l.majewski@samsung.com>
  */
 
-#include <common.h>
 #include <command.h>
 #include <log.h>
 #include <watchdog.h>
 #include <g_dnl.h>
 #include <usb.h>
 #include <net.h>
+#include <linux/printk.h>
 
 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();
        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
@@ -54,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
                         */
@@ -67,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.
                         *
@@ -76,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) {
@@ -102,11 +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();
-       usb_gadget_release(usbctrl_index);
+err_detach:
+       udc_device_put(udc);
 
        if (dfu_reset)
                do_reset(NULL, 0, 0, NULL);