]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/cmd_fastboot.c
common/board_f: implement type casting for gd structure
[people/ms/u-boot.git] / common / cmd_fastboot.c
index 909616dcb7f3744f6fb5106f519b39b9564bfb04..346ab804541fd951316ca962ca3f5bb727f53244 100644 (file)
@@ -15,17 +15,27 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
        int ret;
 
+       g_dnl_clear_detach();
        ret = g_dnl_register("usb_dnl_fastboot");
        if (ret)
                return ret;
 
+       if (!g_dnl_board_usb_cable_connected()) {
+               puts("\rUSB cable not detected.\n" \
+                    "Command exit.\n");
+               return CMD_RET_FAILURE;
+       }
+
        while (1) {
+               if (g_dnl_detach())
+                       break;
                if (ctrlc())
                        break;
                usb_gadget_handle_interrupts();
        }
 
        g_dnl_unregister();
+       g_dnl_clear_detach();
        return CMD_RET_SUCCESS;
 }