From 3f603cbbb8e175e545d6037a783e1ef82bab30f9 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 11 Feb 2016 13:23:26 -0700 Subject: dm: Use uclass_first_device_err() where it is useful Use this new function in places where it simplifies the code. Signed-off-by: Simon Glass --- cmd/bmp.c | 12 ++++-------- cmd/tpm.c | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'cmd') diff --git a/cmd/bmp.c b/cmd/bmp.c index 01b3d39..fb6fe3f 100644 --- a/cmd/bmp.c +++ b/cmd/bmp.c @@ -246,18 +246,14 @@ int bmp_display(ulong addr, int x, int y) addr = map_to_sysmem(bmp); #ifdef CONFIG_DM_VIDEO - ret = uclass_first_device(UCLASS_VIDEO, &dev); + ret = uclass_first_device_err(UCLASS_VIDEO, &dev); if (!ret) { - if (!dev) - ret = -ENODEV; - if (!ret) { - bool align = false; + bool align = false; # ifdef CONFIG_SPLASH_SCREEN_ALIGN - align = true; + align = true; # endif /* CONFIG_SPLASH_SCREEN_ALIGN */ - ret = video_bmp_display(dev, addr, x, y, align); - } + ret = video_bmp_display(dev, addr, x, y, align); } #elif defined(CONFIG_LCD) ret = lcd_display_bitmap(addr, x, y); diff --git a/cmd/tpm.c b/cmd/tpm.c index 6edf3e9..312503f 100644 --- a/cmd/tpm.c +++ b/cmd/tpm.c @@ -447,8 +447,8 @@ static int get_tpm(struct udevice **devp) { int rc; - rc = uclass_first_device(UCLASS_TPM, devp); - if (rc || !*devp) { + rc = uclass_first_device_err(UCLASS_TPM, devp); + if (rc) { printf("Could not find TPM (ret=%d)\n", rc); return CMD_RET_FAILURE; } -- cgit v1.1 From 4101f6879256720b30df712089a3df18565f9203 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:25:34 -0700 Subject: dm: Drop the block_dev_desc_t typedef Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long and causes 80-column violations, rename it to struct blk_desc. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Tested-by: Stephen Warren --- cmd/disk.c | 2 +- cmd/fat.c | 4 ++-- cmd/gpt.c | 8 ++++---- cmd/host.c | 4 ++-- cmd/ide.c | 22 +++++++++++----------- cmd/mmc.c | 2 +- cmd/part.c | 8 ++++---- cmd/read.c | 4 ++-- cmd/reiser.c | 4 ++-- cmd/sata.c | 10 +++++----- cmd/scsi.c | 12 ++++++------ cmd/unzip.c | 2 +- cmd/usb.c | 2 +- cmd/usb_mass_storage.c | 6 +++--- cmd/zfs.c | 4 ++-- 15 files changed, 47 insertions(+), 47 deletions(-) (limited to 'cmd') diff --git a/cmd/disk.c b/cmd/disk.c index 3025225..c53c2a2 100644 --- a/cmd/disk.c +++ b/cmd/disk.c @@ -20,7 +20,7 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, #if defined(CONFIG_IMAGE_FORMAT_LEGACY) image_header_t *hdr; #endif - block_dev_desc_t *dev_desc; + struct blk_desc *dev_desc; #if defined(CONFIG_FIT) const void *fit_hdr = NULL; diff --git a/cmd/fat.c b/cmd/fat.c index aae993d..82b9b38 100644 --- a/cmd/fat.c +++ b/cmd/fat.c @@ -69,7 +69,7 @@ static int do_fat_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { int dev, part; - block_dev_desc_t *dev_desc; + struct blk_desc *dev_desc; disk_partition_t info; if (argc < 2) { @@ -105,7 +105,7 @@ static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, int ret; unsigned long addr; unsigned long count; - block_dev_desc_t *dev_desc = NULL; + struct blk_desc *dev_desc = NULL; disk_partition_t info; int dev = 0; int part = 1; diff --git a/cmd/gpt.c b/cmd/gpt.c index d94d553..881367c 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -168,7 +168,7 @@ static bool found_key(const char *str, const char *key) * @return - zero on success, otherwise error * */ -static int set_gpt_info(block_dev_desc_t *dev_desc, +static int set_gpt_info(struct blk_desc *dev_desc, const char *str_part, char **str_disk_guid, disk_partition_t **partitions, @@ -328,7 +328,7 @@ err: return errno; } -static int gpt_default(block_dev_desc_t *blk_dev_desc, const char *str_part) +static int gpt_default(struct blk_desc *blk_dev_desc, const char *str_part) { int ret; char *str_disk_guid; @@ -356,7 +356,7 @@ static int gpt_default(block_dev_desc_t *blk_dev_desc, const char *str_part) return ret; } -static int gpt_verify(block_dev_desc_t *blk_dev_desc, const char *str_part) +static int gpt_verify(struct blk_desc *blk_dev_desc, const char *str_part) { ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, blk_dev_desc->blksz); @@ -408,7 +408,7 @@ static int do_gpt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int ret = CMD_RET_SUCCESS; int dev = 0; char *ep; - block_dev_desc_t *blk_dev_desc = NULL; + struct blk_desc *blk_dev_desc = NULL; if (argc < 4 || argc > 5) return CMD_RET_USAGE; diff --git a/cmd/host.c b/cmd/host.c index ba1460e..ee219ce 100644 --- a/cmd/host.c +++ b/cmd/host.c @@ -67,7 +67,7 @@ static int do_host_info(cmd_tbl_t *cmdtp, int flag, int argc, int dev; printf("%3s %12s %s\n", "dev", "blocks", "path"); for (dev = min_dev; dev <= max_dev; dev++) { - block_dev_desc_t *blk_dev; + struct blk_desc *blk_dev; int ret; printf("%3d ", dev); @@ -92,7 +92,7 @@ static int do_host_dev(cmd_tbl_t *cmdtp, int flag, int argc, { int dev; char *ep; - block_dev_desc_t *blk_dev; + struct blk_desc *blk_dev; int ret; if (argc < 1 || argc > 3) diff --git a/cmd/ide.c b/cmd/ide.c index f19a7ce..06202c5 100644 --- a/cmd/ide.c +++ b/cmd/ide.c @@ -53,7 +53,7 @@ ulong ide_bus_offset[CONFIG_SYS_IDE_MAXBUS] = { static int ide_bus_ok[CONFIG_SYS_IDE_MAXBUS]; -block_dev_desc_t ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE]; +struct blk_desc ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE]; /* ------------------------------------------------------------------------- */ #ifdef CONFIG_IDE_RESET @@ -62,7 +62,7 @@ static void ide_reset (void); #define ide_reset() /* dummy */ #endif -static void ide_ident (block_dev_desc_t *dev_desc); +static void ide_ident(struct blk_desc *dev_desc); static uchar ide_wait (int dev, ulong t); #define IDE_TIME_OUT 2000 /* 2 sec timeout */ @@ -78,8 +78,8 @@ static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len #endif #ifdef CONFIG_ATAPI -static void atapi_inquiry(block_dev_desc_t *dev_desc); -static ulong atapi_read(block_dev_desc_t *block_dev, lbaint_t blknr, +static void atapi_inquiry(struct blk_desc *dev_desc); +static ulong atapi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer); #endif @@ -187,7 +187,7 @@ int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) if (strcmp(argv[1], "read") == 0) { ulong addr = simple_strtoul(argv[2], NULL, 16); ulong cnt = simple_strtoul(argv[4], NULL, 16); - block_dev_desc_t *dev_desc; + struct blk_desc *dev_desc; ulong n; #ifdef CONFIG_SYS_64BIT_LBA @@ -446,7 +446,7 @@ void ide_init(void) /* ------------------------------------------------------------------------- */ #ifdef CONFIG_PARTITIONS -block_dev_desc_t *ide_get_dev(int dev) +struct blk_desc *ide_get_dev(int dev) { return (dev < CONFIG_SYS_IDE_MAXDEVICE) ? &ide_dev_desc[dev] : NULL; } @@ -541,7 +541,7 @@ __weak void ide_input_data(int dev, ulong *sect_buf, int words) /* ------------------------------------------------------------------------- */ -static void ide_ident(block_dev_desc_t *dev_desc) +static void ide_ident(struct blk_desc *dev_desc) { unsigned char c; hd_driveid_t iop; @@ -713,7 +713,7 @@ static void ide_ident(block_dev_desc_t *dev_desc) /* ------------------------------------------------------------------------- */ -ulong ide_read(block_dev_desc_t *block_dev, lbaint_t blknr, lbaint_t blkcnt, +ulong ide_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { int device = block_dev->dev; @@ -839,7 +839,7 @@ IDE_READ_E: /* ------------------------------------------------------------------------- */ -ulong ide_write(block_dev_desc_t *block_dev, lbaint_t blknr, lbaint_t blkcnt, +ulong ide_write(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) { int device = block_dev->dev; @@ -1301,7 +1301,7 @@ error: } -static void atapi_inquiry(block_dev_desc_t *dev_desc) +static void atapi_inquiry(struct blk_desc *dev_desc) { unsigned char ccb[12]; /* Command descriptor block */ unsigned char iobuf[64]; /* temp buf */ @@ -1394,7 +1394,7 @@ static void atapi_inquiry(block_dev_desc_t *dev_desc) #define ATAPI_READ_BLOCK_SIZE 2048 /* assuming CD part */ #define ATAPI_READ_MAX_BLOCK (ATAPI_READ_MAX_BYTES/ATAPI_READ_BLOCK_SIZE) -ulong atapi_read(block_dev_desc_t *block_dev, lbaint_t blknr, lbaint_t blkcnt, +ulong atapi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { int device = block_dev->dev; diff --git a/cmd/mmc.c b/cmd/mmc.c index 1c7156f..ab59e7f 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -424,7 +424,7 @@ static int do_mmc_rescan(cmd_tbl_t *cmdtp, int flag, static int do_mmc_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - block_dev_desc_t *mmc_dev; + struct blk_desc *mmc_dev; struct mmc *mmc; mmc = init_mmc_device(curr_device, false); diff --git a/cmd/part.c b/cmd/part.c index 5599509..a572aab 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -29,7 +29,7 @@ static int do_part_uuid(int argc, char * const argv[]) { int part; - block_dev_desc_t *dev_desc; + struct blk_desc *dev_desc; disk_partition_t info; if (argc < 2) @@ -52,7 +52,7 @@ static int do_part_uuid(int argc, char * const argv[]) static int do_part_list(int argc, char * const argv[]) { int ret; - block_dev_desc_t *desc; + struct blk_desc *desc; char *var = NULL; bool bootable = false; int i; @@ -114,7 +114,7 @@ static int do_part_list(int argc, char * const argv[]) static int do_part_start(int argc, char * const argv[]) { - block_dev_desc_t *desc; + struct blk_desc *desc; disk_partition_t info; char buf[512] = { 0 }; int part; @@ -148,7 +148,7 @@ static int do_part_start(int argc, char * const argv[]) static int do_part_size(int argc, char * const argv[]) { - block_dev_desc_t *desc; + struct blk_desc *desc; disk_partition_t info; char buf[512] = { 0 }; int part; diff --git a/cmd/read.c b/cmd/read.c index 8710288..6a1e1d9 100644 --- a/cmd/read.c +++ b/cmd/read.c @@ -15,7 +15,7 @@ int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { char *ep; - block_dev_desc_t *dev_desc = NULL; + struct blk_desc *dev_desc = NULL; int dev; int part = 0; disk_partition_t part_info; @@ -57,7 +57,7 @@ int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) offset = part_info.start; limit = part_info.size; } else { - /* Largest address not available in block_dev_desc_t. */ + /* Largest address not available in struct blk_desc. */ limit = ~0; } diff --git a/cmd/reiser.c b/cmd/reiser.c index 8871564..1cca5eb 100644 --- a/cmd/reiser.c +++ b/cmd/reiser.c @@ -34,7 +34,7 @@ int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { char *filename = "/"; int dev, part; - block_dev_desc_t *dev_desc=NULL; + struct blk_desc *dev_desc = NULL; disk_partition_t info; if (argc < 3) @@ -82,7 +82,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int dev, part; ulong addr = 0, filelen; disk_partition_t info; - block_dev_desc_t *dev_desc = NULL; + struct blk_desc *dev_desc = NULL; unsigned long count; char *addr_str; diff --git a/cmd/sata.c b/cmd/sata.c index 76bacea..a1faf2d 100644 --- a/cmd/sata.c +++ b/cmd/sata.c @@ -16,15 +16,15 @@ #include static int sata_curr_device = -1; -block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE]; +struct blk_desc sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE]; -static unsigned long sata_bread(block_dev_desc_t *block_dev, lbaint_t start, +static unsigned long sata_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, void *dst) { return sata_read(block_dev->dev, start, blkcnt, dst); } -static unsigned long sata_bwrite(block_dev_desc_t *block_dev, lbaint_t start, +static unsigned long sata_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, const void *buffer) { return sata_write(block_dev->dev, start, blkcnt, buffer); @@ -36,7 +36,7 @@ int __sata_initialize(void) int i; for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) { - memset(&sata_dev_desc[i], 0, sizeof(struct block_dev_desc)); + memset(&sata_dev_desc[i], 0, sizeof(struct blk_desc)); sata_dev_desc[i].if_type = IF_TYPE_SATA; sata_dev_desc[i].dev = i; sata_dev_desc[i].part_type = PART_TYPE_UNKNOWN; @@ -75,7 +75,7 @@ __weak int __sata_stop(void) int sata_stop(void) __attribute__((weak, alias("__sata_stop"))); #ifdef CONFIG_PARTITIONS -block_dev_desc_t *sata_get_dev(int dev) +struct blk_desc *sata_get_dev(int dev) { return (dev < CONFIG_SYS_SATA_MAX_DEVICE) ? &sata_dev_desc[dev] : NULL; } diff --git a/cmd/scsi.c b/cmd/scsi.c index bc7d1b6..dff811b 100644 --- a/cmd/scsi.c +++ b/cmd/scsi.c @@ -48,7 +48,7 @@ static int scsi_max_devs; /* number of highest available scsi device */ static int scsi_curr_dev; /* current device */ -static block_dev_desc_t scsi_dev_desc[CONFIG_SYS_SCSI_MAX_DEVICE]; +static struct blk_desc scsi_dev_desc[CONFIG_SYS_SCSI_MAX_DEVICE]; /******************************************************************************** * forward declerations of some Setup Routines @@ -66,9 +66,9 @@ void scsi_ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len); static int scsi_read_capacity(ccb *pccb, lbaint_t *capacity, unsigned long *blksz); -static ulong scsi_read(block_dev_desc_t *block_dev, lbaint_t blknr, +static ulong scsi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer); -static ulong scsi_write(block_dev_desc_t *block_dev, lbaint_t blknr, +static ulong scsi_write(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer); @@ -239,7 +239,7 @@ void scsi_init(void) #endif #ifdef CONFIG_PARTITIONS -block_dev_desc_t * scsi_get_dev(int dev) +struct blk_desc *scsi_get_dev(int dev) { return (dev < CONFIG_SYS_SCSI_MAX_DEVICE) ? &scsi_dev_desc[dev] : NULL; } @@ -376,7 +376,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #define SCSI_MAX_READ_BLK 0xFFFF #define SCSI_LBA48_READ 0xFFFFFFF -static ulong scsi_read(block_dev_desc_t *block_dev, lbaint_t blknr, +static ulong scsi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { int device = block_dev->dev; @@ -443,7 +443,7 @@ static ulong scsi_read(block_dev_desc_t *block_dev, lbaint_t blknr, /* Almost the maximum amount of the scsi_ext command.. */ #define SCSI_MAX_WRITE_BLK 0xFFFF -static ulong scsi_write(block_dev_desc_t *block_dev, lbaint_t blknr, +static ulong scsi_write(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) { int device = block_dev->dev; diff --git a/cmd/unzip.c b/cmd/unzip.c index 0686be6..5be1566 100644 --- a/cmd/unzip.c +++ b/cmd/unzip.c @@ -43,7 +43,7 @@ U_BOOT_CMD( static int do_gzwrite(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - block_dev_desc_t *bdev; + struct blk_desc *bdev; int ret; unsigned char *addr; unsigned long length; diff --git a/cmd/usb.c b/cmd/usb.c index c7b642c..5f3b06a 100644 --- a/cmd/usb.c +++ b/cmd/usb.c @@ -625,7 +625,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int i; extern char usb_started; #ifdef CONFIG_USB_STORAGE - block_dev_desc_t *stor_dev; + struct blk_desc *stor_dev; #endif if (argc < 2) diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c index 0415591..03b7e21 100644 --- a/cmd/usb_mass_storage.c +++ b/cmd/usb_mass_storage.c @@ -19,7 +19,7 @@ static int ums_read_sector(struct ums *ums_dev, ulong start, lbaint_t blkcnt, void *buf) { - block_dev_desc_t *block_dev = &ums_dev->block_dev; + struct blk_desc *block_dev = &ums_dev->block_dev; lbaint_t blkstart = start + ums_dev->start_sector; return block_dev->block_read(block_dev, blkstart, blkcnt, buf); @@ -28,7 +28,7 @@ static int ums_read_sector(struct ums *ums_dev, static int ums_write_sector(struct ums *ums_dev, ulong start, lbaint_t blkcnt, const void *buf) { - block_dev_desc_t *block_dev = &ums_dev->block_dev; + struct blk_desc *block_dev = &ums_dev->block_dev; lbaint_t blkstart = start + ums_dev->start_sector; return block_dev->block_write(block_dev, blkstart, blkcnt, buf); @@ -53,7 +53,7 @@ static void ums_fini(void) static int ums_init(const char *devtype, const char *devnums) { char *s, *t, *devnum, *name; - block_dev_desc_t *block_dev; + struct blk_desc *block_dev; int ret; struct ums *ums_new; diff --git a/cmd/zfs.c b/cmd/zfs.c index 0aed29e..9076a8a 100644 --- a/cmd/zfs.c +++ b/cmd/zfs.c @@ -39,7 +39,7 @@ static int do_zfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] int part; ulong addr = 0; disk_partition_t info; - block_dev_desc_t *dev_desc; + struct blk_desc *dev_desc; char buf[12]; unsigned long count; const char *addr_str; @@ -135,7 +135,7 @@ static int do_zfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { const char *filename = "/"; int part; - block_dev_desc_t *dev_desc; + struct blk_desc *dev_desc; disk_partition_t info; struct device_s vdev; -- cgit v1.1 From db1d9e78e6f0ea51a698f18abe4cebc5ff39b691 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:25:42 -0700 Subject: dm: blk: Rename get_dev() to blk_get_dev() The current name is too generic. Add a 'blk_' prefix to aid searching and make its purpose clearer. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Tested-by: Stephen Warren --- cmd/gpt.c | 2 +- cmd/read.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/gpt.c b/cmd/gpt.c index 881367c..8ffaef3 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -418,7 +418,7 @@ static int do_gpt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) printf("'%s' is not a number\n", argv[3]); return CMD_RET_USAGE; } - blk_dev_desc = get_dev(argv[2], dev); + blk_dev_desc = blk_get_dev(argv[2], dev); if (!blk_dev_desc) { printf("%s: %s dev %d NOT available\n", __func__, argv[2], dev); diff --git a/cmd/read.c b/cmd/read.c index 6a1e1d9..12ac165 100644 --- a/cmd/read.c +++ b/cmd/read.c @@ -39,7 +39,7 @@ int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) part = (int)simple_strtoul(++ep, NULL, 16); } - dev_desc = get_dev(argv[1], dev); + dev_desc = blk_get_dev(argv[1], dev); if (dev_desc == NULL) { printf("Block device %s %d not supported\n", argv[1], dev); return 1; -- cgit v1.1 From ebac37cfbfb32ea44704fe032fadd5cf334824b7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:25:43 -0700 Subject: dm: blk: Rename get_device() to blk_get_device_by_str() The current name is too generic. The function returns a block device based on a provided string. Rename it to aid searching and make its purpose clearer. Also add a few comments. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Tested-by: Stephen Warren --- cmd/part.c | 6 +++--- cmd/unzip.c | 2 +- cmd/usb_mass_storage.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'cmd') diff --git a/cmd/part.c b/cmd/part.c index a572aab..dd32d50 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -81,7 +81,7 @@ static int do_part_list(int argc, char * const argv[]) return CMD_RET_USAGE; } - ret = get_device(argv[0], argv[1], &desc); + ret = blk_get_device_by_str(argv[0], argv[1], &desc); if (ret < 0) return 1; @@ -128,7 +128,7 @@ static int do_part_start(int argc, char * const argv[]) part = simple_strtoul(argv[2], NULL, 0); - ret = get_device(argv[0], argv[1], &desc); + ret = blk_get_device_by_str(argv[0], argv[1], &desc); if (ret < 0) return 1; @@ -162,7 +162,7 @@ static int do_part_size(int argc, char * const argv[]) part = simple_strtoul(argv[2], NULL, 0); - ret = get_device(argv[0], argv[1], &desc); + ret = blk_get_device_by_str(argv[0], argv[1], &desc); if (ret < 0) return 1; diff --git a/cmd/unzip.c b/cmd/unzip.c index 5be1566..a8bcb1f 100644 --- a/cmd/unzip.c +++ b/cmd/unzip.c @@ -53,7 +53,7 @@ static int do_gzwrite(cmd_tbl_t *cmdtp, int flag, if (argc < 5) return CMD_RET_USAGE; - ret = get_device(argv[1], argv[2], &bdev); + ret = blk_get_device_by_str(argv[1], argv[2], &bdev); if (ret < 0) return CMD_RET_FAILURE; diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c index 03b7e21..59bb4ee 100644 --- a/cmd/usb_mass_storage.c +++ b/cmd/usb_mass_storage.c @@ -69,7 +69,7 @@ static int ums_init(const char *devtype, const char *devnums) if (!devnum) break; - ret = get_device(devtype, devnum, &block_dev); + ret = blk_get_device_by_str(devtype, devnum, &block_dev); if (ret < 0) goto cleanup; -- cgit v1.1 From e35929e4a1ffe861f2f45e107986568c56c4f077 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:25:44 -0700 Subject: dm: blk: Rename get_device_and_partition() Rename this function to blk_get_device_part_str(). This is a better name because it makes it clear that the function returns a block device and parses a string. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Tested-by: Stephen Warren --- cmd/disk.c | 2 +- cmd/fat.c | 4 ++-- cmd/part.c | 2 +- cmd/reiser.c | 4 ++-- cmd/zfs.c | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'cmd') diff --git a/cmd/disk.c b/cmd/disk.c index c53c2a2..0883c79 100644 --- a/cmd/disk.c +++ b/cmd/disk.c @@ -38,7 +38,7 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, bootstage_mark(BOOTSTAGE_ID_IDE_BOOT_DEVICE); - part = get_device_and_partition(intf, (argc == 3) ? argv[2] : NULL, + part = blk_get_device_part_str(intf, (argc == 3) ? argv[2] : NULL, &dev_desc, &info, 1); if (part < 0) { bootstage_error(BOOTSTAGE_ID_IDE_TYPE); diff --git a/cmd/fat.c b/cmd/fat.c index 82b9b38..18a1be9 100644 --- a/cmd/fat.c +++ b/cmd/fat.c @@ -77,7 +77,7 @@ static int do_fat_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc, return 0; } - part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1); + part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1); if (part < 0) return 1; @@ -114,7 +114,7 @@ static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, if (argc < 5) return cmd_usage(cmdtp); - part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1); + part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1); if (part < 0) return 1; diff --git a/cmd/part.c b/cmd/part.c index dd32d50..415b38a 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -37,7 +37,7 @@ static int do_part_uuid(int argc, char * const argv[]) if (argc > 3) return CMD_RET_USAGE; - part = get_device_and_partition(argv[0], argv[1], &dev_desc, &info, 0); + part = blk_get_device_part_str(argv[0], argv[1], &dev_desc, &info, 0); if (part < 0) return 1; diff --git a/cmd/reiser.c b/cmd/reiser.c index 1cca5eb..a717956 100644 --- a/cmd/reiser.c +++ b/cmd/reiser.c @@ -40,7 +40,7 @@ int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc < 3) return CMD_RET_USAGE; - part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1); + part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1); if (part < 0) return 1; @@ -122,7 +122,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; } - part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1); + part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1); if (part < 0) return 1; diff --git a/cmd/zfs.c b/cmd/zfs.c index 9076a8a..bb61afd 100644 --- a/cmd/zfs.c +++ b/cmd/zfs.c @@ -80,7 +80,7 @@ static int do_zfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] return 1; } - part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1); + part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1); if (part < 0) return 1; @@ -145,7 +145,7 @@ static int do_zfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc == 4) filename = argv[3]; - part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1); + part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1); if (part < 0) return 1; -- cgit v1.1 From 3e8bd469504f5d5a8800a2ea46d664dde701105b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:25:48 -0700 Subject: dm: part: Rename some partition functions Rename three partition functions so that they start with part_. This makes it clear what they relate to. Signed-off-by: Simon Glass Tested-by: Stephen Warren --- cmd/ide.c | 6 +++--- cmd/mmc.c | 2 +- cmd/part.c | 8 ++++---- cmd/read.c | 2 +- cmd/sata.c | 6 +++--- cmd/scsi.c | 6 +++--- cmd/usb.c | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) (limited to 'cmd') diff --git a/cmd/ide.c b/cmd/ide.c index 06202c5..01b91b5 100644 --- a/cmd/ide.c +++ b/cmd/ide.c @@ -137,7 +137,7 @@ int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) ++ok; if (dev) putc('\n'); - print_part(&ide_dev_desc[dev]); + part_print(&ide_dev_desc[dev]); } } if (!ok) { @@ -171,7 +171,7 @@ int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) int dev = (int) simple_strtoul(argv[2], NULL, 10); if (ide_dev_desc[dev].part_type != PART_TYPE_UNKNOWN) { - print_part(&ide_dev_desc[dev]); + part_print(&ide_dev_desc[dev]); } else { printf("\nIDE device %d not available\n", dev); @@ -435,7 +435,7 @@ void ide_init(void) if ((ide_dev_desc[i].lba > 0) && (ide_dev_desc[i].blksz > 0)) { /* initialize partition type */ - init_part(&ide_dev_desc[i]); + part_init(&ide_dev_desc[i]); if (curr_device < 0) curr_device = i; } diff --git a/cmd/mmc.c b/cmd/mmc.c index ab59e7f..fb4382e 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -433,7 +433,7 @@ static int do_mmc_part(cmd_tbl_t *cmdtp, int flag, mmc_dev = mmc_get_dev(curr_device); if (mmc_dev != NULL && mmc_dev->type != DEV_TYPE_UNKNOWN) { - print_part(mmc_dev); + part_print(mmc_dev); return CMD_RET_SUCCESS; } diff --git a/cmd/part.c b/cmd/part.c index 415b38a..414031e 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -92,7 +92,7 @@ static int do_part_list(int argc, char * const argv[]) for (p = 1; p < 128; p++) { char t[5]; - int r = get_partition_info(desc, p, &info); + int r = part_get_info(desc, p, &info); if (r != 0) continue; @@ -107,7 +107,7 @@ static int do_part_list(int argc, char * const argv[]) return 0; } - print_part(desc); + part_print(desc); return 0; } @@ -132,7 +132,7 @@ static int do_part_start(int argc, char * const argv[]) if (ret < 0) return 1; - err = get_partition_info(desc, part, &info); + err = part_get_info(desc, part, &info); if (err) return 1; @@ -166,7 +166,7 @@ static int do_part_size(int argc, char * const argv[]) if (ret < 0) return 1; - err = get_partition_info(desc, part, &info); + err = part_get_info(desc, part, &info); if (err) return 1; diff --git a/cmd/read.c b/cmd/read.c index 12ac165..f8d766a 100644 --- a/cmd/read.c +++ b/cmd/read.c @@ -50,7 +50,7 @@ int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) cnt = simple_strtoul(argv[5], NULL, 16); if (part != 0) { - if (get_partition_info(dev_desc, part, &part_info)) { + if (part_get_info(dev_desc, part, &part_info)) { printf("Cannot find partition %d\n", part); return 1; } diff --git a/cmd/sata.c b/cmd/sata.c index a1faf2d..8b1f19c 100644 --- a/cmd/sata.c +++ b/cmd/sata.c @@ -52,7 +52,7 @@ int __sata_initialize(void) rc = scan_sata(i); if (!rc && (sata_dev_desc[i].lba > 0) && (sata_dev_desc[i].blksz > 0)) - init_part(&sata_dev_desc[i]); + part_init(&sata_dev_desc[i]); } } sata_curr_device = 0; @@ -131,7 +131,7 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ++ok; if (dev) putc ('\n'); - print_part(&sata_dev_desc[dev]); + part_print(&sata_dev_desc[dev]); } } if (!ok) { @@ -164,7 +164,7 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int dev = (int)simple_strtoul(argv[2], NULL, 10); if (sata_dev_desc[dev].part_type != PART_TYPE_UNKNOWN) { - print_part(&sata_dev_desc[dev]); + part_print(&sata_dev_desc[dev]); } else { printf("\nSATA device %d not available\n", dev); rc = 1; diff --git a/cmd/scsi.c b/cmd/scsi.c index dff811b..de0651c 100644 --- a/cmd/scsi.c +++ b/cmd/scsi.c @@ -156,7 +156,7 @@ void scsi_scan(int mode) scsi_dev_desc[scsi_max_devs].log2blksz = LOG2(scsi_dev_desc[scsi_max_devs].blksz); scsi_dev_desc[scsi_max_devs].type=perq; - init_part(&scsi_dev_desc[scsi_max_devs]); + part_init(&scsi_dev_desc[scsi_max_devs]); removable: if(mode==1) { printf (" Device %d: ", scsi_max_devs); @@ -301,7 +301,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (dev) printf("\n"); debug ("print_part of %x\n",dev); - print_part(&scsi_dev_desc[dev]); + part_print(&scsi_dev_desc[dev]); } } if (!ok) @@ -329,7 +329,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (strncmp(argv[1],"part",4) == 0) { int dev = (int)simple_strtoul(argv[2], NULL, 10); if(scsi_dev_desc[dev].type != DEV_TYPE_UNKNOWN) { - print_part(&scsi_dev_desc[dev]); + part_print(&scsi_dev_desc[dev]); } else { printf ("\nSCSI device %d not available\n", dev); diff --git a/cmd/usb.c b/cmd/usb.c index 5f3b06a..53fd6ad 100644 --- a/cmd/usb.c +++ b/cmd/usb.c @@ -727,7 +727,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (devno) printf("\n"); debug("print_part of %x\n", devno); - print_part(stor_dev); + part_print(stor_dev); } } } else { @@ -737,7 +737,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) stor_dev->type != DEV_TYPE_UNKNOWN) { ok++; debug("print_part of %x\n", devno); - print_part(stor_dev); + part_print(stor_dev); } } if (!ok) { -- cgit v1.1 From a696d768c1274d667be86abe72869461b9fe0073 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:25:49 -0700 Subject: dm: cbfs: Fix handling of invalid type The comment for file_cbfs_type() says that it returns 0 for an invalid type. The code appears to check for -1, except that it uses an unsigned variable to store the type. This results in a warning on 64-bit machines. Adjust it to make the meaning clearer. Continue to handle the -1 case since it may be needed. Signed-off-by: Simon Glass Tested-by: Stephen Warren --- cmd/cbfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/cbfs.c b/cmd/cbfs.c index 35d8a7a..779e9c0 100644 --- a/cmd/cbfs.c +++ b/cmd/cbfs.c @@ -103,7 +103,7 @@ int do_cbfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) printf(" size type name\n"); printf("------------------------------------------\n"); while (file) { - u32 type = file_cbfs_type(file); + int type = file_cbfs_type(file); char *type_name = NULL; const char *filename = file_cbfs_name(file); @@ -140,7 +140,8 @@ int do_cbfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) case CBFS_COMPONENT_CMOS_LAYOUT: type_name = "cmos layout"; break; - case -1UL: + case -1: + case 0: type_name = "null"; break; } -- cgit v1.1 From bcce53d048de7f41078d25e39aa2f26d752d3658 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:25:51 -0700 Subject: dm: block: Rename device number member dev to devnum This is a device number, and we want to use 'dev' to mean a driver model device. Rename the member. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Tested-by: Stephen Warren --- cmd/disk.c | 2 +- cmd/fat.c | 4 ++-- cmd/ide.c | 12 ++++++------ cmd/mmc_spi.c | 4 ++-- cmd/reiser.c | 4 ++-- cmd/sata.c | 6 +++--- cmd/scsi.c | 6 +++--- cmd/usb_mass_storage.c | 2 +- cmd/zfs.c | 2 +- 9 files changed, 21 insertions(+), 21 deletions(-) (limited to 'cmd') diff --git a/cmd/disk.c b/cmd/disk.c index 0883c79..27ed115 100644 --- a/cmd/disk.c +++ b/cmd/disk.c @@ -45,7 +45,7 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, return 1; } - dev = dev_desc->dev; + dev = dev_desc->devnum; bootstage_mark(BOOTSTAGE_ID_IDE_TYPE); printf("\nLoading from %s device %d, partition %d: " diff --git a/cmd/fat.c b/cmd/fat.c index 18a1be9..4e20746 100644 --- a/cmd/fat.c +++ b/cmd/fat.c @@ -81,7 +81,7 @@ static int do_fat_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc, if (part < 0) return 1; - dev = dev_desc->dev; + dev = dev_desc->devnum; if (fat_set_blk_dev(dev_desc, &info) != 0) { printf("\n** Unable to use %s %d:%d for fatinfo **\n", argv[1], dev, part); @@ -118,7 +118,7 @@ static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, if (part < 0) return 1; - dev = dev_desc->dev; + dev = dev_desc->devnum; if (fat_set_blk_dev(dev_desc, &info) != 0) { printf("\n** Unable to use %s %d:%d for fatwrite **\n", diff --git a/cmd/ide.c b/cmd/ide.c index 01b91b5..dfd5548 100644 --- a/cmd/ide.c +++ b/cmd/ide.c @@ -418,7 +418,7 @@ void ide_init(void) int led = (IDE_BUS(i) == 0) ? LED_IDE1 : LED_IDE2; ide_dev_desc[i].type = DEV_TYPE_UNKNOWN; ide_dev_desc[i].if_type = IF_TYPE_IDE; - ide_dev_desc[i].dev = i; + ide_dev_desc[i].devnum = i; ide_dev_desc[i].part_type = PART_TYPE_UNKNOWN; ide_dev_desc[i].blksz = 0; ide_dev_desc[i].log2blksz = @@ -551,7 +551,7 @@ static void ide_ident(struct blk_desc *dev_desc) #endif int device; - device = dev_desc->dev; + device = dev_desc->devnum; printf(" Device %d: ", device); ide_led(DEVICE_LED(device), 1); /* LED on */ @@ -716,7 +716,7 @@ static void ide_ident(struct blk_desc *dev_desc) ulong ide_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { - int device = block_dev->dev; + int device = block_dev->devnum; ulong n = 0; unsigned char c; unsigned char pwrsave = 0; /* power save */ @@ -842,7 +842,7 @@ IDE_READ_E: ulong ide_write(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) { - int device = block_dev->dev; + int device = block_dev->devnum; ulong n = 0; unsigned char c; @@ -1308,7 +1308,7 @@ static void atapi_inquiry(struct blk_desc *dev_desc) unsigned char c; int device; - device = dev_desc->dev; + device = dev_desc->devnum; dev_desc->type = DEV_TYPE_UNKNOWN; /* not yet valid */ dev_desc->block_read = atapi_read; @@ -1397,7 +1397,7 @@ static void atapi_inquiry(struct blk_desc *dev_desc) ulong atapi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { - int device = block_dev->dev; + int device = block_dev->devnum; ulong n = 0; unsigned char ccb[12]; /* Command descriptor block */ ulong cnt; diff --git a/cmd/mmc_spi.c b/cmd/mmc_spi.c index a2138b8..0c44d06 100644 --- a/cmd/mmc_spi.c +++ b/cmd/mmc_spi.c @@ -72,8 +72,8 @@ static int do_mmc_spi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) printf("Failed to create MMC Device\n"); return 1; } - printf("%s: %d at %u:%u hz %u mode %u\n", mmc->cfg->name, mmc->block_dev.dev, - bus, cs, speed, mode); + printf("%s: %d at %u:%u hz %u mode %u\n", mmc->cfg->name, + mmc->block_dev.devnum, bus, cs, speed, mode); mmc_init(mmc); return 0; diff --git a/cmd/reiser.c b/cmd/reiser.c index a717956..cbdad36 100644 --- a/cmd/reiser.c +++ b/cmd/reiser.c @@ -48,7 +48,7 @@ int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) filename = argv[3]; } - dev = dev_desc->dev; + dev = dev_desc->devnum; PRINTF("Using device %s %d:%d, directory: %s\n", argv[1], dev, part, filename); reiserfs_set_blk_dev(dev_desc, &info); @@ -126,7 +126,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (part < 0) return 1; - dev = dev_desc->dev; + dev = dev_desc->devnum; printf("Loading file \"%s\" from %s device %d%c%c\n", filename, argv[1], dev, diff --git a/cmd/sata.c b/cmd/sata.c index 8b1f19c..c8de9a3 100644 --- a/cmd/sata.c +++ b/cmd/sata.c @@ -21,13 +21,13 @@ struct blk_desc sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE]; static unsigned long sata_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, void *dst) { - return sata_read(block_dev->dev, start, blkcnt, dst); + return sata_read(block_dev->devnum, start, blkcnt, dst); } static unsigned long sata_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, const void *buffer) { - return sata_write(block_dev->dev, start, blkcnt, buffer); + return sata_write(block_dev->devnum, start, blkcnt, buffer); } int __sata_initialize(void) @@ -38,7 +38,7 @@ int __sata_initialize(void) for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) { memset(&sata_dev_desc[i], 0, sizeof(struct blk_desc)); sata_dev_desc[i].if_type = IF_TYPE_SATA; - sata_dev_desc[i].dev = i; + sata_dev_desc[i].devnum = i; sata_dev_desc[i].part_type = PART_TYPE_UNKNOWN; sata_dev_desc[i].type = DEV_TYPE_HARDDISK; sata_dev_desc[i].lba = 0; diff --git a/cmd/scsi.c b/cmd/scsi.c index de0651c..951d1e5 100644 --- a/cmd/scsi.c +++ b/cmd/scsi.c @@ -99,7 +99,7 @@ void scsi_scan(int mode) scsi_dev_desc[i].revision[0]=0; scsi_dev_desc[i].removable = false; scsi_dev_desc[i].if_type=IF_TYPE_SCSI; - scsi_dev_desc[i].dev=i; + scsi_dev_desc[i].devnum = i; scsi_dev_desc[i].part_type=PART_TYPE_UNKNOWN; scsi_dev_desc[i].block_read=scsi_read; scsi_dev_desc[i].block_write = scsi_write; @@ -379,7 +379,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) static ulong scsi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { - int device = block_dev->dev; + int device = block_dev->devnum; lbaint_t start, blks; uintptr_t buf_addr; unsigned short smallblks = 0; @@ -446,7 +446,7 @@ static ulong scsi_read(struct blk_desc *block_dev, lbaint_t blknr, static ulong scsi_write(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) { - int device = block_dev->dev; + int device = block_dev->devnum; lbaint_t start, blks; uintptr_t buf_addr; unsigned short smallblks; diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c index 59bb4ee..14eed98 100644 --- a/cmd/usb_mass_storage.c +++ b/cmd/usb_mass_storage.c @@ -100,7 +100,7 @@ static int ums_init(const char *devtype, const char *devnums) ums[ums_count].block_dev = *block_dev; printf("UMS: LUN %d, dev %d, hwpart %d, sector %#x, count %#x\n", - ums_count, ums[ums_count].block_dev.dev, + ums_count, ums[ums_count].block_dev.devnum, ums[ums_count].block_dev.hwpart, ums[ums_count].start_sector, ums[ums_count].num_sectors); diff --git a/cmd/zfs.c b/cmd/zfs.c index bb61afd..93067a9 100644 --- a/cmd/zfs.c +++ b/cmd/zfs.c @@ -84,7 +84,7 @@ static int do_zfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] if (part < 0) return 1; - dev = dev_desc->dev; + dev = dev_desc->devnum; printf("Loading file \"%s\" from %s device %d%c%c\n", filename, argv[1], dev, part ? ':' : ' ', part ? part + '0' : ' '); -- cgit v1.1 From 2a981dc2c62c500110aad297fa70503aec36e689 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:25:52 -0700 Subject: dm: block: Adjust device calls to go through helpers function To ease conversion to driver model, add helper functions which deal with calling each block device method. With driver model we can reimplement these functions with the same arguments. Use inline functions to avoid increasing code size on some boards. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Tested-by: Stephen Warren --- cmd/disk.c | 6 +++--- cmd/ide.c | 4 ++-- cmd/read.c | 2 +- cmd/usb.c | 6 ++---- 4 files changed, 8 insertions(+), 10 deletions(-) (limited to 'cmd') diff --git a/cmd/disk.c b/cmd/disk.c index 27ed115..e0219f8 100644 --- a/cmd/disk.c +++ b/cmd/disk.c @@ -56,7 +56,7 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, ", Block Size: %ld\n", info.start, info.size, info.blksz); - if (dev_desc->block_read(dev_desc, info.start, 1, (ulong *)addr) != 1) { + if (blk_dread(dev_desc, info.start, 1, (ulong *)addr) != 1) { printf("** Read error on %d:%d\n", dev, part); bootstage_error(BOOTSTAGE_ID_IDE_PART_READ); return 1; @@ -100,8 +100,8 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, cnt /= info.blksz; cnt -= 1; - if (dev_desc->block_read(dev_desc, info.start + 1, cnt, - (ulong *)(addr + info.blksz)) != cnt) { + if (blk_dread(dev_desc, info.start + 1, cnt, + (ulong *)(addr + info.blksz)) != cnt) { printf("** Read error on %d:%d\n", dev, part); bootstage_error(BOOTSTAGE_ID_IDE_READ); return 1; diff --git a/cmd/ide.c b/cmd/ide.c index dfd5548..c4c08c8 100644 --- a/cmd/ide.c +++ b/cmd/ide.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -203,8 +204,7 @@ int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) #endif dev_desc = &ide_dev_desc[curr_device]; - n = dev_desc->block_read(dev_desc, blk, cnt, - (ulong *)addr); + n = blk_dread(dev_desc, blk, cnt, (ulong *)addr); /* flush cache after read */ flush_cache(addr, cnt * ide_dev_desc[curr_device].blksz); diff --git a/cmd/read.c b/cmd/read.c index f8d766a..61d8ce7 100644 --- a/cmd/read.c +++ b/cmd/read.c @@ -66,7 +66,7 @@ int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; } - if (dev_desc->block_read(dev_desc, offset + blk, cnt, addr) < 0) { + if (blk_read(dev_desc, offset + blk, cnt, addr) < 0) { printf("Error reading blocks\n"); return 1; } diff --git a/cmd/usb.c b/cmd/usb.c index 53fd6ad..9ed5dc6 100644 --- a/cmd/usb.c +++ b/cmd/usb.c @@ -759,8 +759,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) printf("\nUSB read: device %d block # %ld, count %ld" " ... ", usb_stor_curr_dev, blk, cnt); stor_dev = usb_stor_get_dev(usb_stor_curr_dev); - n = stor_dev->block_read(stor_dev, blk, cnt, - (ulong *)addr); + n = blk_dread(stor_dev, blk, cnt, (ulong *)addr); printf("%ld blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR"); if (n == cnt) @@ -781,8 +780,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) printf("\nUSB write: device %d block # %ld, count %ld" " ... ", usb_stor_curr_dev, blk, cnt); stor_dev = usb_stor_get_dev(usb_stor_curr_dev); - n = stor_dev->block_write(stor_dev, blk, cnt, - (ulong *)addr); + n = blk_dwrite(stor_dev, blk, cnt, (ulong *)addr); printf("%ld blocks write: %s\n", n, (n == cnt) ? "OK" : "ERROR"); if (n == cnt) -- cgit v1.1 From 40fd050890e08eb6d064aaf074cf3a8b75d1251e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:25:57 -0700 Subject: dm: sandbox: Add driver-model block-device support for sandbox Update the host driver to support driver model for block devices. A future commit will remove the old code, but for now it is useful to be able to use it both with and without CONFIG_BLK. Signed-off-by: Simon Glass Tested-by: Stephen Warren --- cmd/host.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/host.c b/cmd/host.c index ee219ce..8d84415 100644 --- a/cmd/host.c +++ b/cmd/host.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -80,7 +81,13 @@ static int do_host_info(cmd_tbl_t *cmdtp, int flag, int argc, continue; } - struct host_block_dev *host_dev = blk_dev->priv; + struct host_block_dev *host_dev; + +#ifdef CONFIG_BLK + host_dev = dev_get_priv(blk_dev->bdev); +#else + host_dev = blk_dev->priv; +#endif printf("%12lu %s\n", (unsigned long)blk_dev->lba, host_dev->filename); } -- cgit v1.1 From eea1d148f3c653b23e96a2f842c3760b4cbbaa51 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:26:05 -0700 Subject: Drop CONFIG_CRAMFS_CMDLINE This option doesn't do anything. Drop it. Signed-off-by: Simon Glass Suggested-by: Bin Meng --- cmd/cramfs.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'cmd') diff --git a/cmd/cramfs.c b/cmd/cramfs.c index 270701b..c103491 100644 --- a/cmd/cramfs.c +++ b/cmd/cramfs.c @@ -29,7 +29,6 @@ # define DEBUGF(fmt, args...) #endif -#ifdef CONFIG_CRAMFS_CMDLINE #include #ifdef CONFIG_SYS_NO_FLASH @@ -201,7 +200,3 @@ U_BOOT_CMD( "[ directory ]\n" " - list files in a directory.\n" ); - -#endif /* #ifdef CONFIG_CRAMFS_CMDLINE */ - -/***************************************************/ -- cgit v1.1