diff options
author | Tom Rini <trini@konsulko.com> | 2017-08-18 18:24:36 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-08-18 18:24:36 -0400 |
commit | 1fdafb2e3dfecdc4129a8062ad25b1adb32b0efb (patch) | |
tree | 6c6a74d4cb4e8a19bfd47510ade9fdcc3d08cb01 /cmd | |
parent | a6dd10c70be9be863488d9d7afede057a4d99823 (diff) | |
parent | a191ccaf12fb4fadedcd3c76df6327e2bb0f182b (diff) | |
download | u-boot-1fdafb2e3dfecdc4129a8062ad25b1adb32b0efb.tar.gz |
Merge branch 'master' of git://git.denx.de/u-boot-mmc
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/Makefile | 1 | ||||
-rw-r--r-- | cmd/blk_common.c | 104 | ||||
-rw-r--r-- | cmd/ide.c | 107 | ||||
-rw-r--r-- | cmd/mmc.c | 38 | ||||
-rw-r--r-- | cmd/sata.c | 178 | ||||
-rw-r--r-- | cmd/scsi.c | 79 | ||||
-rw-r--r-- | cmd/usb.c | 111 |
7 files changed, 231 insertions, 387 deletions
diff --git a/cmd/Makefile b/cmd/Makefile index 13c86f8fcc..4a865bd7d7 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -15,6 +15,7 @@ obj-y += version.o # command obj-$(CONFIG_CMD_AES) += aes.o obj-$(CONFIG_CMD_ARMFLASH) += armflash.o +obj-y += blk_common.o obj-$(CONFIG_SOURCE) += source.o obj-$(CONFIG_CMD_SOURCE) += source.o obj-$(CONFIG_CMD_BDI) += bdinfo.o diff --git a/cmd/blk_common.c b/cmd/blk_common.c new file mode 100644 index 0000000000..86c75e78d8 --- /dev/null +++ b/cmd/blk_common.c @@ -0,0 +1,104 @@ +/* + * Handling of common block commands + * + * Copyright (c) 2017 Google, Inc + * + * (C) Copyright 2000-2011 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <blk.h> + +#ifdef HAVE_BLOCK_DEVICE +int blk_common_cmd(int argc, char * const argv[], enum if_type if_type, + int *cur_devnump) +{ + const char *if_name = blk_get_if_type_name(if_type); + + switch (argc) { + case 0: + case 1: + return CMD_RET_USAGE; + case 2: + if (strncmp(argv[1], "inf", 3) == 0) { + blk_list_devices(if_type); + return 0; + } else if (strncmp(argv[1], "dev", 3) == 0) { + if (blk_print_device_num(if_type, *cur_devnump)) { + printf("\nno %s devices available\n", if_name); + return CMD_RET_FAILURE; + } + return 0; + } else if (strncmp(argv[1], "part", 4) == 0) { + if (blk_list_part(if_type)) + printf("\nno %s devices available\n", if_name); + return 0; + } + return CMD_RET_USAGE; + case 3: + if (strncmp(argv[1], "dev", 3) == 0) { + int dev = (int)simple_strtoul(argv[2], NULL, 10); + + if (!blk_show_device(if_type, dev)) { + *cur_devnump = dev; + printf("... is now current device\n"); + } else { + return CMD_RET_FAILURE; + } + return 0; + } else if (strncmp(argv[1], "part", 4) == 0) { + int dev = (int)simple_strtoul(argv[2], NULL, 10); + + if (blk_print_part_devnum(if_type, dev)) { + printf("\n%s device %d not available\n", + if_name, dev); + return CMD_RET_FAILURE; + } + return 0; + } + return CMD_RET_USAGE; + + default: /* at least 4 args */ + if (strcmp(argv[1], "read") == 0) { + ulong addr = simple_strtoul(argv[2], NULL, 16); + lbaint_t blk = simple_strtoul(argv[3], NULL, 16); + ulong cnt = simple_strtoul(argv[4], NULL, 16); + ulong n; + + printf("\n%s read: device %d block # %lld, count %ld ... ", + if_name, *cur_devnump, (unsigned long long)blk, + cnt); + + n = blk_read_devnum(if_type, *cur_devnump, blk, cnt, + (ulong *)addr); + + printf("%ld blocks read: %s\n", n, + n == cnt ? "OK" : "ERROR"); + return n == cnt ? 0 : 1; + } else if (strcmp(argv[1], "write") == 0) { + ulong addr = simple_strtoul(argv[2], NULL, 16); + lbaint_t blk = simple_strtoul(argv[3], NULL, 16); + ulong cnt = simple_strtoul(argv[4], NULL, 16); + ulong n; + + printf("\n%s write: device %d block # %lld, count %ld ... ", + if_name, *cur_devnump, (unsigned long long)blk, + cnt); + + n = blk_write_devnum(if_type, *cur_devnump, blk, cnt, + (ulong *)addr); + + printf("%ld blocks written: %s\n", n, + n == cnt ? "OK" : "ERROR"); + return n == cnt ? 0 : 1; + } else { + return CMD_RET_USAGE; + } + + return 0; + } +} +#endif @@ -34,116 +34,15 @@ static int curr_device = -1; int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { - int rcode = 0; - - switch (argc) { - case 0: - case 1: - return CMD_RET_USAGE; - case 2: + if (argc == 2) { if (strncmp(argv[1], "res", 3) == 0) { puts("\nReset IDE: "); ide_init(); return 0; - } else if (strncmp(argv[1], "inf", 3) == 0) { - blk_list_devices(IF_TYPE_IDE); - return 0; - - } else if (strncmp(argv[1], "dev", 3) == 0) { - if (blk_print_device_num(IF_TYPE_IDE, curr_device)) { - printf("\nno IDE devices available\n"); - return CMD_RET_FAILURE; - } - - return 0; - } else if (strncmp(argv[1], "part", 4) == 0) { - if (blk_list_part(IF_TYPE_IDE)) - printf("\nno IDE devices available\n"); - return 1; } - return CMD_RET_USAGE; - case 3: - if (strncmp(argv[1], "dev", 3) == 0) { - int dev = (int)simple_strtoul(argv[2], NULL, 10); - - if (!blk_show_device(IF_TYPE_IDE, dev)) { - curr_device = dev; - printf("... is now current device\n"); - } else { - return CMD_RET_FAILURE; - } - return 0; - } else if (strncmp(argv[1], "part", 4) == 0) { - int dev = (int)simple_strtoul(argv[2], NULL, 10); - - if (blk_print_part_devnum(IF_TYPE_IDE, dev)) { - printf("\nIDE device %d not available\n", dev); - return CMD_RET_FAILURE; - } - return 1; - } - - return CMD_RET_USAGE; - default: - /* at least 4 args */ - - if (strcmp(argv[1], "read") == 0) { - ulong addr = simple_strtoul(argv[2], NULL, 16); - ulong cnt = simple_strtoul(argv[4], NULL, 16); - ulong n; - -#ifdef CONFIG_SYS_64BIT_LBA - lbaint_t blk = simple_strtoull(argv[3], NULL, 16); - - printf("\nIDE read: device %d block # %lld, count %ld...", - curr_device, blk, cnt); -#else - lbaint_t blk = simple_strtoul(argv[3], NULL, 16); - - printf("\nIDE read: device %d block # %ld, count %ld...", - curr_device, blk, cnt); -#endif - - n = blk_read_devnum(IF_TYPE_IDE, curr_device, blk, cnt, - (ulong *)addr); - - printf("%ld blocks read: %s\n", - n, (n == cnt) ? "OK" : "ERROR"); - if (n == cnt) - return 0; - else - return 1; - } else if (strcmp(argv[1], "write") == 0) { - ulong addr = simple_strtoul(argv[2], NULL, 16); - ulong cnt = simple_strtoul(argv[4], NULL, 16); - ulong n; - -#ifdef CONFIG_SYS_64BIT_LBA - lbaint_t blk = simple_strtoull(argv[3], NULL, 16); - - printf("\nIDE write: device %d block # %lld, count %ld...", - curr_device, blk, cnt); -#else - lbaint_t blk = simple_strtoul(argv[3], NULL, 16); - - printf("\nIDE write: device %d block # %ld, count %ld...", - curr_device, blk, cnt); -#endif - n = blk_write_devnum(IF_TYPE_IDE, curr_device, blk, cnt, - (ulong *)addr); - - printf("%ld blocks written: %s\n", n, - n == cnt ? "OK" : "ERROR"); - if (n == cnt) - return 0; - else - return 1; - } else { - return CMD_RET_USAGE; - } - - return rcode; } + + return blk_common_cmd(argc, argv, IF_TYPE_IDE, &curr_device); } int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) @@ -643,6 +643,28 @@ static int do_mmc_boot_resize(cmd_tbl_t *cmdtp, int flag, printf("EMMC RPMB partition Size %d MB\n", rpmbsize); return CMD_RET_SUCCESS; } + +static int mmc_partconf_print(struct mmc *mmc) +{ + u8 ack, access, part; + + if (mmc->part_config == MMCPART_NOAVAILABLE) { + printf("No part_config info for ver. 0x%x\n", mmc->version); + return CMD_RET_FAILURE; + } + + access = EXT_CSD_EXTRACT_PARTITION_ACCESS(mmc->part_config); + ack = EXT_CSD_EXTRACT_BOOT_ACK(mmc->part_config); + part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config); + + printf("EXT_CSD[179], PARTITION_CONFIG:\n" + "BOOT_ACK: 0x%x\n" + "BOOT_PARTITION_ENABLE: 0x%x\n" + "PARTITION_ACCESS: 0x%x\n", ack, part, access); + + return CMD_RET_SUCCESS; +} + static int do_mmc_partconf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -650,13 +672,10 @@ static int do_mmc_partconf(cmd_tbl_t *cmdtp, int flag, struct mmc *mmc; u8 ack, part_num, access; - if (argc != 5) + if (argc != 2 && argc != 5) return CMD_RET_USAGE; dev = simple_strtoul(argv[1], NULL, 10); - ack = simple_strtoul(argv[2], NULL, 10); - part_num = simple_strtoul(argv[3], NULL, 10); - access = simple_strtoul(argv[4], NULL, 10); mmc = init_mmc_device(dev, false); if (!mmc) @@ -667,6 +686,13 @@ static int do_mmc_partconf(cmd_tbl_t *cmdtp, int flag, return CMD_RET_FAILURE; } + if (argc == 2) + return mmc_partconf_print(mmc); + + ack = simple_strtoul(argv[2], NULL, 10); + part_num = simple_strtoul(argv[3], NULL, 10); + access = simple_strtoul(argv[4], NULL, 10); + /* acknowledge to be sent during boot operation */ return mmc_set_part_conf(mmc, ack, part_num, access); } @@ -832,8 +858,8 @@ U_BOOT_CMD( " - Set the BOOT_BUS_WIDTH field of the specified device\n" "mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>\n" " - Change sizes of boot and RPMB partitions of specified device\n" - "mmc partconf dev boot_ack boot_partition partition_access\n" - " - Change the bits of the PARTITION_CONFIG field of the specified device\n" + "mmc partconf dev [boot_ack boot_partition partition_access]\n" + " - Show or change the bits of the PARTITION_CONFIG field of the specified device\n" "mmc rst-function dev value\n" " - Change the RST_n_FUNCTION field of the specified device\n" " WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.\n" diff --git a/cmd/sata.c b/cmd/sata.c index 4c53022ff6..7817442532 100644 --- a/cmd/sata.c +++ b/cmd/sata.c @@ -11,124 +11,116 @@ */ #include <common.h> +#include <ahci.h> +#include <dm.h> #include <command.h> #include <part.h> #include <sata.h> +#include <dm/device-internal.h> +#include <dm/uclass-internal.h> static int sata_curr_device = -1; +int sata_remove(int devnum) +{ +#ifdef CONFIG_AHCI + struct udevice *dev; + int rc; + + rc = uclass_find_device(UCLASS_AHCI, devnum, &dev); + if (!rc && !dev) + rc = uclass_find_first_device(UCLASS_AHCI, &dev); + if (rc || !dev) { + printf("Cannot find SATA device %d (err=%d)\n", devnum, rc); + return CMD_RET_FAILURE; + } + + rc = device_remove(dev, DM_REMOVE_NORMAL); + if (rc) { + printf("Cannot remove SATA device '%s' (err=%d)\n", dev->name, + rc); + return CMD_RET_FAILURE; + } + + return 0; +#else + return sata_stop(); +#endif +} + +int sata_probe(int devnum) +{ +#ifdef CONFIG_AHCI + struct udevice *dev; + struct udevice *blk; + int rc; + + rc = uclass_get_device(UCLASS_AHCI, devnum, &dev); + if (rc) + rc = uclass_find_first_device(UCLASS_AHCI, &dev); + if (rc) { + printf("Cannot probe SATA device %d (err=%d)\n", devnum, rc); + return CMD_RET_FAILURE; + } + rc = sata_scan(dev); + if (rc) { + printf("Cannot scan SATA device %d (err=%d)\n", devnum, rc); + return CMD_RET_FAILURE; + } + + rc = blk_get_from_parent(dev, &blk); + if (!rc) { + struct blk_desc *desc = dev_get_uclass_platdata(blk); + + if (desc->lba > 0 && desc->blksz > 0) + part_init(desc); + } + + return 0; +#else + return sata_initialize() < 0 ? CMD_RET_FAILURE : CMD_RET_SUCCESS; +#endif +} + static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { int rc = 0; - if (argc == 2 && strcmp(argv[1], "stop") == 0) - return sata_stop(); + if (argc >= 2) { + int devnum = 0; - if (argc == 2 && strcmp(argv[1], "init") == 0) { - if (sata_curr_device != -1) - sata_stop(); + if (argc == 3) + devnum = (int)simple_strtoul(argv[2], NULL, 10); + if (!strcmp(argv[1], "stop")) + return sata_remove(devnum); + + if (!strcmp(argv[1], "init")) { + if (sata_curr_device != -1) { + rc = sata_remove(devnum); + if (rc) + return rc; + } - return (sata_initialize() < 0) ? - CMD_RET_FAILURE : CMD_RET_SUCCESS; + return sata_probe(devnum); + } } /* If the user has not yet run `sata init`, do it now */ if (sata_curr_device == -1) { - rc = sata_initialize(); - if (rc == -1) + rc = sata_probe(0); + if (rc < 0) return CMD_RET_FAILURE; - sata_curr_device = rc; + sata_curr_device = 0; } - switch (argc) { - case 0: - case 1: - return CMD_RET_USAGE; - case 2: - if (strncmp(argv[1], "inf", 3) == 0) { - blk_list_devices(IF_TYPE_SATA); - return 0; - } else if (strncmp(argv[1], "dev", 3) == 0) { - if (blk_print_device_num(IF_TYPE_SATA, - sata_curr_device)) { - printf("\nno SATA devices available\n"); - return CMD_RET_FAILURE; - } - return 0; - } else if (strncmp(argv[1], "part", 4) == 0) { - if (blk_list_part(IF_TYPE_SATA)) - puts("\nno SATA devices available\n"); - return 0; - } - return CMD_RET_USAGE; - case 3: - if (strncmp(argv[1], "dev", 3) == 0) { - int dev = (int)simple_strtoul(argv[2], NULL, 10); - - if (!blk_show_device(IF_TYPE_SATA, dev)) { - sata_curr_device = dev; - printf("... is now current device\n"); - } else { - return CMD_RET_FAILURE; - } - return 0; - } else if (strncmp(argv[1], "part", 4) == 0) { - int dev = (int)simple_strtoul(argv[2], NULL, 10); - - if (blk_print_part_devnum(IF_TYPE_SATA, dev)) { - printf("\nSATA device %d not available\n", - dev); - return CMD_RET_FAILURE; - } - return rc; - } - return CMD_RET_USAGE; - - default: /* at least 4 args */ - if (strcmp(argv[1], "read") == 0) { - ulong addr = simple_strtoul(argv[2], NULL, 16); - ulong cnt = simple_strtoul(argv[4], NULL, 16); - ulong n; - lbaint_t blk = simple_strtoul(argv[3], NULL, 16); - - printf("\nSATA read: device %d block # %ld, count %ld ... ", - sata_curr_device, blk, cnt); - - n = blk_read_devnum(IF_TYPE_SATA, sata_curr_device, blk, - cnt, (ulong *)addr); - - printf("%ld blocks read: %s\n", - n, (n==cnt) ? "OK" : "ERROR"); - return (n == cnt) ? 0 : 1; - } else if (strcmp(argv[1], "write") == 0) { - ulong addr = simple_strtoul(argv[2], NULL, 16); - ulong cnt = simple_strtoul(argv[4], NULL, 16); - ulong n; - - lbaint_t blk = simple_strtoul(argv[3], NULL, 16); - - printf("\nSATA write: device %d block # %ld, count %ld ... ", - sata_curr_device, blk, cnt); - - n = blk_write_devnum(IF_TYPE_SATA, sata_curr_device, - blk, cnt, (ulong *)addr); - - printf("%ld blocks written: %s\n", - n, (n == cnt) ? "OK" : "ERROR"); - return (n == cnt) ? 0 : 1; - } else { - return CMD_RET_USAGE; - } - - return rc; - } + return blk_common_cmd(argc, argv, IF_TYPE_SATA, &sata_curr_device); } U_BOOT_CMD( sata, 5, 1, do_sata, "SATA sub system", "init - init SATA sub system\n" - "sata stop - disable SATA sub system\n" + "sata stop [dev] - disable SATA sub system or device\n" "sata info - show available SATA devices\n" "sata device [dev] - show or set current device\n" "sata part [dev] - print partition table\n" diff --git a/cmd/scsi.c b/cmd/scsi.c index 8e36de107e..b9d086fb6b 100644 --- a/cmd/scsi.c +++ b/cmd/scsi.c @@ -29,11 +29,7 @@ static int do_scsi(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { int ret; - switch (argc) { - case 0: - case 1: - return CMD_RET_USAGE; - case 2: + if (argc == 2) { if (strncmp(argv[1], "res", 3) == 0) { printf("\nReset SCSI\n"); #ifndef CONFIG_DM_SCSI @@ -44,84 +40,15 @@ static int do_scsi(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_FAILURE; return ret; } - if (strncmp(argv[1], "inf", 3) == 0) { - blk_list_devices(IF_TYPE_SCSI); - return 0; - } - if (strncmp(argv[1], "dev", 3) == 0) { - if (blk_print_device_num(IF_TYPE_SCSI, scsi_curr_dev)) { - printf("\nno SCSI devices available\n"); - return CMD_RET_FAILURE; - } - - return 0; - } if (strncmp(argv[1], "scan", 4) == 0) { ret = scsi_scan(true); if (ret) return CMD_RET_FAILURE; return ret; } - if (strncmp(argv[1], "part", 4) == 0) { - if (blk_list_part(IF_TYPE_SCSI)) - printf("\nno SCSI devices available\n"); - return 0; - } - return CMD_RET_USAGE; - case 3: - if (strncmp(argv[1], "dev", 3) == 0) { - int dev = (int)simple_strtoul(argv[2], NULL, 10); + } - if (!blk_show_device(IF_TYPE_SCSI, dev)) { - scsi_curr_dev = dev; - printf("... is now current device\n"); - } else { - return CMD_RET_FAILURE; - } - return 0; - } - if (strncmp(argv[1], "part", 4) == 0) { - int dev = (int)simple_strtoul(argv[2], NULL, 10); - - if (blk_print_part_devnum(IF_TYPE_SCSI, dev)) { - printf("\nSCSI device %d not available\n", - dev); - return CMD_RET_FAILURE; - } - return 0; - } - return CMD_RET_USAGE; - default: - /* at least 4 args */ - if (strcmp(argv[1], "read") == 0) { - ulong addr = simple_strtoul(argv[2], NULL, 16); - ulong blk = simple_strtoul(argv[3], NULL, 16); - ulong cnt = simple_strtoul(argv[4], NULL, 16); - ulong n; - - printf("\nSCSI read: device %d block # %ld, count %ld ... ", - scsi_curr_dev, blk, cnt); - n = blk_read_devnum(IF_TYPE_SCSI, scsi_curr_dev, blk, - cnt, (ulong *)addr); - printf("%ld blocks read: %s\n", n, - n == cnt ? "OK" : "ERROR"); - return 0; - } else if (strcmp(argv[1], "write") == 0) { - ulong addr = simple_strtoul(argv[2], NULL, 16); - ulong blk = simple_strtoul(argv[3], NULL, 16); - ulong cnt = simple_strtoul(argv[4], NULL, 16); - ulong n; - - printf("\nSCSI write: device %d block # %ld, count %ld ... ", - scsi_curr_dev, blk, cnt); - n = blk_write_devnum(IF_TYPE_SCSI, scsi_curr_dev, blk, - cnt, (ulong *)addr); - printf("%ld blocks written: %s\n", n, - n == cnt ? "OK" : "ERROR"); - return 0; - } - } /* switch */ - return CMD_RET_USAGE; + return blk_common_cmd(argc, argv, IF_TYPE_SCSI, &scsi_curr_dev); } U_BOOT_CMD( @@ -621,9 +621,6 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) struct usb_device *udev = NULL; int i; extern char usb_started; -#ifdef CONFIG_USB_STORAGE - struct blk_desc *stor_dev; -#endif if (argc < 2) return CMD_RET_USAGE; @@ -712,112 +709,10 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (strncmp(argv[1], "stor", 4) == 0) return usb_stor_info(); - if (strncmp(argv[1], "part", 4) == 0) { - int devno, ok = 0; - if (argc == 2) { - for (devno = 0; ; ++devno) { - stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, - devno); - if (stor_dev == NULL) - break; - if (stor_dev->type != DEV_TYPE_UNKNOWN) { - ok++; - if (devno) - printf("\n"); - debug("print_part of %x\n", devno); - part_print(stor_dev); - } - } - } else { - devno = simple_strtoul(argv[2], NULL, 16); - stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, devno); - if (stor_dev != NULL && - stor_dev->type != DEV_TYPE_UNKNOWN) { - ok++; - debug("print_part of %x\n", devno); - part_print(stor_dev); - } - } - if (!ok) { - printf("\nno USB devices available\n"); - return 1; - } - return 0; - } - if (strcmp(argv[1], "read") == 0) { - if (usb_stor_curr_dev < 0) { - printf("no current device selected\n"); - return 1; - } - if (argc == 5) { - unsigned long addr = simple_strtoul(argv[2], NULL, 16); - unsigned long blk = simple_strtoul(argv[3], NULL, 16); - unsigned long cnt = simple_strtoul(argv[4], NULL, 16); - unsigned long n; - printf("\nUSB read: device %d block # %ld, count %ld" - " ... ", usb_stor_curr_dev, blk, cnt); - stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, - usb_stor_curr_dev); - n = blk_dread(stor_dev, blk, cnt, (ulong *)addr); - printf("%ld blocks read: %s\n", n, - (n == cnt) ? "OK" : "ERROR"); - if (n == cnt) - return 0; - return 1; - } - } - if (strcmp(argv[1], "write") == 0) { - if (usb_stor_curr_dev < 0) { - printf("no current device selected\n"); - return 1; - } - if (argc == 5) { - unsigned long addr = simple_strtoul(argv[2], NULL, 16); - unsigned long blk = simple_strtoul(argv[3], NULL, 16); - unsigned long cnt = simple_strtoul(argv[4], NULL, 16); - unsigned long n; - printf("\nUSB write: device %d block # %ld, count %ld" - " ... ", usb_stor_curr_dev, blk, cnt); - stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, - usb_stor_curr_dev); - n = blk_dwrite(stor_dev, blk, cnt, (ulong *)addr); - printf("%ld blocks write: %s\n", n, - (n == cnt) ? "OK" : "ERROR"); - if (n == cnt) - return 0; - return 1; - } - } - if (strncmp(argv[1], "dev", 3) == 0) { - if (argc == 3) { - int dev = (int)simple_strtoul(argv[2], NULL, 10); - printf("\nUSB device %d: ", dev); - stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, dev); - if ((stor_dev == NULL) || - (stor_dev->if_type == IF_TYPE_UNKNOWN)) { - printf("unknown device\n"); - return 1; - } - printf("\n Device %d: ", dev); - dev_print(stor_dev); - if (stor_dev->type == DEV_TYPE_UNKNOWN) - return 1; - usb_stor_curr_dev = dev; - printf("... is now current device\n"); - return 0; - } else { - printf("\nUSB device %d: ", usb_stor_curr_dev); - stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, - usb_stor_curr_dev); - dev_print(stor_dev); - if (stor_dev->type == DEV_TYPE_UNKNOWN) - return 1; - return 0; - } - return 0; - } -#endif /* CONFIG_USB_STORAGE */ + return blk_common_cmd(argc, argv, IF_TYPE_USB, &usb_stor_curr_dev); +#else return CMD_RET_USAGE; +#endif /* CONFIG_USB_STORAGE */ } U_BOOT_CMD( |