Commit b5072264054879b4cdfe8219404a0b2347d933b5
Committed by
Marek Vasut
1 parent
c0978a94aa
Exists in
v2017.01-smarct4x
and in
37 other branches
USB: make "usb start" start usb only once
Currently we've this magic in include/config_distro_bootcmd.h to avoid scanning the usb bus multiple times. And it does not work when also using an usb keyboard because then the preboot command has already scanned the bus, so we're still scanning it twice. This commit makes "usb start" only start usb if it is no already started, allowing us to remove all the magic for it from include/config_distro_bootcmd.h and just call it unconditionally. This also causes "usb start" and "usb reset" to actually do what their different names suggest, rather then both of them doing exactly the same. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Showing 1 changed file with 31 additions and 17 deletions Side-by-side Diff
common/cmd_usb.c
... | ... | @@ -441,6 +441,26 @@ |
441 | 441 | return 0; |
442 | 442 | } |
443 | 443 | |
444 | +static void do_usb_start(void) | |
445 | +{ | |
446 | + bootstage_mark_name(BOOTSTAGE_ID_USB_START, "usb_start"); | |
447 | + | |
448 | + if (usb_init() < 0) | |
449 | + return; | |
450 | + | |
451 | +#ifdef CONFIG_USB_STORAGE | |
452 | + /* try to recognize storage devices immediately */ | |
453 | + usb_stor_curr_dev = usb_stor_scan(1); | |
454 | +#endif | |
455 | +#ifdef CONFIG_USB_HOST_ETHER | |
456 | + /* try to recognize ethernet devices immediately */ | |
457 | + usb_ether_curr_dev = usb_host_eth_scan(1); | |
458 | +#endif | |
459 | +#ifdef CONFIG_USB_KEYBOARD | |
460 | + drv_usb_kbd_init(); | |
461 | +#endif | |
462 | +} | |
463 | + | |
444 | 464 | /****************************************************************************** |
445 | 465 | * usb command intepreter |
446 | 466 | */ |
447 | 467 | |
... | ... | @@ -457,26 +477,20 @@ |
457 | 477 | if (argc < 2) |
458 | 478 | return CMD_RET_USAGE; |
459 | 479 | |
460 | - if ((strncmp(argv[1], "reset", 5) == 0) || | |
461 | - (strncmp(argv[1], "start", 5) == 0)) { | |
462 | - bootstage_mark_name(BOOTSTAGE_ID_USB_START, "usb_start"); | |
480 | + if (strncmp(argv[1], "start", 5) == 0) { | |
481 | + if (usb_started) | |
482 | + return 0; /* Already started */ | |
483 | + printf("starting USB...\n"); | |
484 | + do_usb_start(); | |
485 | + return 0; | |
486 | + } | |
487 | + | |
488 | + if (strncmp(argv[1], "reset", 5) == 0) { | |
489 | + printf("resetting USB...\n"); | |
463 | 490 | if (do_usb_stop_keyboard(1) != 0) |
464 | 491 | return 1; |
465 | 492 | usb_stop(); |
466 | - printf("(Re)start USB...\n"); | |
467 | - if (usb_init() >= 0) { | |
468 | -#ifdef CONFIG_USB_STORAGE | |
469 | - /* try to recognize storage devices immediately */ | |
470 | - usb_stor_curr_dev = usb_stor_scan(1); | |
471 | -#endif | |
472 | -#ifdef CONFIG_USB_HOST_ETHER | |
473 | - /* try to recognize ethernet devices immediately */ | |
474 | - usb_ether_curr_dev = usb_host_eth_scan(1); | |
475 | -#endif | |
476 | -#ifdef CONFIG_USB_KEYBOARD | |
477 | - drv_usb_kbd_init(); | |
478 | -#endif | |
479 | - } | |
493 | + do_usb_start(); | |
480 | 494 | return 0; |
481 | 495 | } |
482 | 496 | if (strncmp(argv[1], "stop", 4) == 0) { |