X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cmd%2Ffastboot.c;h=1b4215114d7e5d7e7393667f9b3365457fa07459;hb=6d7dacf726ca043a3f5487549bbfa506c990c813;hp=557257aef8437bcb79d60824a62574645740b931;hpb=3eceff642c01e03e055127c9cf21608faaff28ac;p=oweals%2Fu-boot.git diff --git a/cmd/fastboot.c b/cmd/fastboot.c index 557257aef8..1b4215114d 100644 --- a/cmd/fastboot.c +++ b/cmd/fastboot.c @@ -13,6 +13,7 @@ #include #include #include +#include static int do_fastboot_udp(int argc, char *const argv[], uintptr_t buf_addr, size_t buf_size) @@ -38,17 +39,22 @@ static int do_fastboot_usb(int argc, char *const argv[], #if CONFIG_IS_ENABLED(USB_FUNCTION_FASTBOOT) int controller_index; char *usb_controller; + char *endp; int ret; if (argc < 2) return CMD_RET_USAGE; usb_controller = argv[1]; - controller_index = simple_strtoul(usb_controller, NULL, 0); + controller_index = simple_strtoul(usb_controller, &endp, 0); + if (*endp != '\0') { + pr_err("Error: Wrong USB controller index format\n"); + return CMD_RET_FAILURE; + } - ret = board_usb_init(controller_index, USB_INIT_DEVICE); + ret = usb_gadget_initialize(controller_index); if (ret) { - pr_err("USB init failed: %d", ret); + pr_err("USB init failed: %d\n", ret); return CMD_RET_FAILURE; } @@ -69,6 +75,7 @@ static int do_fastboot_usb(int argc, char *const argv[], break; if (ctrlc()) break; + WATCHDOG_RESET(); usb_gadget_handle_interrupts(controller_index); } @@ -77,7 +84,7 @@ static int do_fastboot_usb(int argc, char *const argv[], exit: g_dnl_unregister(); g_dnl_clear_detach(); - board_usb_cleanup(controller_index, USB_INIT_DEVICE); + usb_gadget_release(controller_index); return ret; #else @@ -120,6 +127,12 @@ NXTARG: ; } + /* Handle case when USB controller param is just '-' */ + if (argc == 1) { + pr_err("Error: Incorrect USB controller index\n"); + return CMD_RET_USAGE; + } + fastboot_init((void *)buf_addr, buf_size); if (!strcmp(argv[1], "udp"))