From c649e3c91cdc96a86ca2665fcfafaca5c4b384b1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:02 -0600 Subject: dm: scsi: Rename CONFIG_CMD_SCSI to CONFIG_SCSI This option currently enables both the command and the SCSI functionality. Rename the existing option to CONFIG_SCSI since most of the code relates to the feature. Signed-off-by: Simon Glass --- disk/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'disk') diff --git a/disk/part.c b/disk/part.c index 543cab8103..2613bff22c 100644 --- a/disk/part.c +++ b/disk/part.c @@ -28,7 +28,7 @@ const struct block_drvr block_drvr[] = { #if defined(CONFIG_CMD_SATA) {.name = "sata", .get_dev = sata_get_dev, }, #endif -#if defined(CONFIG_CMD_SCSI) +#if defined(CONFIG_SCSI) { .name = "scsi", .get_dev = scsi_get_dev, }, #endif #if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE) -- cgit v1.2.1 From a6331fa83cb4a1557df4acfa4214d556f4596904 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:12 -0600 Subject: dm: disk: Use legacy block driver info for block device access Instead of calling xx_get_dev() functions for each interface type, use the new legacy block driver which can provide the device through its interface. Signed-off-by: Simon Glass --- disk/part.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'disk') diff --git a/disk/part.c b/disk/part.c index 2613bff22c..f055c74aa8 100644 --- a/disk/part.c +++ b/disk/part.c @@ -72,7 +72,6 @@ static struct part_driver *part_driver_lookup_type(int part_type) static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart) { const struct block_drvr *drvr = block_drvr; - struct blk_desc* (*reloc_get_dev)(int dev); int (*select_hwpart)(int dev_num, int hwpart); char *name; int ret; @@ -86,16 +85,16 @@ static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart) #endif while (drvr->name) { name = drvr->name; - reloc_get_dev = drvr->get_dev; select_hwpart = drvr->select_hwpart; #ifdef CONFIG_NEEDS_MANUAL_RELOC name += gd->reloc_off; - reloc_get_dev += gd->reloc_off; if (select_hwpart) select_hwpart += gd->reloc_off; #endif if (strncmp(ifname, name, strlen(name)) == 0) { - struct blk_desc *dev_desc = reloc_get_dev(dev); + struct blk_desc *dev_desc; + + dev_desc = blk_get_devnum_by_typename(name, dev); if (!dev_desc) return NULL; if (hwpart == 0 && !select_hwpart) -- cgit v1.2.1 From 57ebf67bad82da0b3ade1728fb39a64d1c29822f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:13 -0600 Subject: dm: usb: Drop the get_dev() function This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass --- disk/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'disk') diff --git a/disk/part.c b/disk/part.c index f055c74aa8..1b33928cc5 100644 --- a/disk/part.c +++ b/disk/part.c @@ -32,7 +32,7 @@ const struct block_drvr block_drvr[] = { { .name = "scsi", .get_dev = scsi_get_dev, }, #endif #if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE) - { .name = "usb", .get_dev = usb_stor_get_dev, }, + { .name = "usb", }, #endif #if defined(CONFIG_MMC) { -- cgit v1.2.1 From 74001a2570ccbc120366e66dd40e8c66e3a6820c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:14 -0600 Subject: dm: ide: Drop the get_dev() function This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass --- disk/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'disk') diff --git a/disk/part.c b/disk/part.c index 1b33928cc5..bf224b2c52 100644 --- a/disk/part.c +++ b/disk/part.c @@ -23,7 +23,7 @@ const struct block_drvr block_drvr[] = { #if defined(CONFIG_CMD_IDE) - { .name = "ide", .get_dev = ide_get_dev, }, + { .name = "ide", }, #endif #if defined(CONFIG_CMD_SATA) {.name = "sata", .get_dev = sata_get_dev, }, -- cgit v1.2.1 From 3c457f4d2e47cc91385abe15d3c825d0ce1a2b6f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:15 -0600 Subject: dm: mmc: Drop the get_dev() function This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass --- disk/part.c | 1 - 1 file changed, 1 deletion(-) (limited to 'disk') diff --git a/disk/part.c b/disk/part.c index bf224b2c52..e70bef5aab 100644 --- a/disk/part.c +++ b/disk/part.c @@ -37,7 +37,6 @@ const struct block_drvr block_drvr[] = { #if defined(CONFIG_MMC) { .name = "mmc", - .get_dev = mmc_get_dev, .select_hwpart = mmc_select_hwpart, }, #endif -- cgit v1.2.1 From edd82ab3547e27b4c1ab1ee7e620f982db9126ad Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:16 -0600 Subject: dm: scsi: Drop the get_dev() function This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass --- disk/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'disk') diff --git a/disk/part.c b/disk/part.c index e70bef5aab..67cb6c0c0b 100644 --- a/disk/part.c +++ b/disk/part.c @@ -29,7 +29,7 @@ const struct block_drvr block_drvr[] = { {.name = "sata", .get_dev = sata_get_dev, }, #endif #if defined(CONFIG_SCSI) - { .name = "scsi", .get_dev = scsi_get_dev, }, + { .name = "scsi", }, #endif #if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE) { .name = "usb", }, -- cgit v1.2.1 From 4e7189d4d8c2ab46c4c580ae300c14d1a9c20b11 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:17 -0600 Subject: dm: sata: Drop the get_dev() function This function is implemented by the legacy block functions now. Drop it. We cannot yet make sata_dev_desc[] private to common/sata.c as it is used by the SATA drivers. This will require the SATA interface to be reworked. Signed-off-by: Simon Glass --- disk/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'disk') diff --git a/disk/part.c b/disk/part.c index 67cb6c0c0b..4fc774bb97 100644 --- a/disk/part.c +++ b/disk/part.c @@ -26,7 +26,7 @@ const struct block_drvr block_drvr[] = { { .name = "ide", }, #endif #if defined(CONFIG_CMD_SATA) - {.name = "sata", .get_dev = sata_get_dev, }, + {.name = "sata", }, #endif #if defined(CONFIG_SCSI) { .name = "scsi", }, -- cgit v1.2.1 From f6d000edbeaddfe8e5b5e3be9fd3f6c76fdff6d2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:18 -0600 Subject: dm: systemace: Drop the get_dev() function This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass --- disk/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'disk') diff --git a/disk/part.c b/disk/part.c index 4fc774bb97..28c870664d 100644 --- a/disk/part.c +++ b/disk/part.c @@ -41,7 +41,7 @@ const struct block_drvr block_drvr[] = { }, #endif #if defined(CONFIG_SYSTEMACE) - { .name = "ace", .get_dev = systemace_get_dev, }, + { .name = "ace", }, #endif #if defined(CONFIG_SANDBOX) { .name = "host", .get_dev = host_get_dev, }, -- cgit v1.2.1 From f1d86fd3b15c2af53964d948c72c9a0a63511927 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:20 -0600 Subject: dm: sandbox: Drop the host_get_dev() function This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass --- disk/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'disk') diff --git a/disk/part.c b/disk/part.c index 28c870664d..e635d90864 100644 --- a/disk/part.c +++ b/disk/part.c @@ -44,7 +44,7 @@ const struct block_drvr block_drvr[] = { { .name = "ace", }, #endif #if defined(CONFIG_SANDBOX) - { .name = "host", .get_dev = host_get_dev, }, + { .name = "host", }, #endif { }, }; -- cgit v1.2.1 From 1fde473da7a5de1e6ad1c72d1b84763642bb1a9f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 13:52:31 -0600 Subject: dm: part: Use the legacy block driver for hardware partition support Drop use of the table in part.c for this feature. Signed-off-by: Simon Glass --- disk/part.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'disk') diff --git a/disk/part.c b/disk/part.c index e635d90864..db5dd5d2f9 100644 --- a/disk/part.c +++ b/disk/part.c @@ -71,9 +71,7 @@ static struct part_driver *part_driver_lookup_type(int part_type) static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart) { const struct block_drvr *drvr = block_drvr; - int (*select_hwpart)(int dev_num, int hwpart); char *name; - int ret; if (!ifname) return NULL; @@ -84,11 +82,8 @@ static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart) #endif while (drvr->name) { name = drvr->name; - select_hwpart = drvr->select_hwpart; #ifdef CONFIG_NEEDS_MANUAL_RELOC name += gd->reloc_off; - if (select_hwpart) - select_hwpart += gd->reloc_off; #endif if (strncmp(ifname, name, strlen(name)) == 0) { struct blk_desc *dev_desc; @@ -96,12 +91,7 @@ static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart) dev_desc = blk_get_devnum_by_typename(name, dev); if (!dev_desc) return NULL; - if (hwpart == 0 && !select_hwpart) - return dev_desc; - if (!select_hwpart) - return NULL; - ret = select_hwpart(dev_desc->devnum, hwpart); - if (ret < 0) + if (blk_dselect_hwpart(dev_desc, hwpart)) return NULL; return dev_desc; } -- cgit v1.2.1 From 6dd9faf8f97e1aad9961a480775612f6cbde27de Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 13:52:32 -0600 Subject: dm: part: Drop the block_drvr table This is not needed since we can use the functions provided by the legacy block device support. Signed-off-by: Simon Glass --- disk/part.c | 67 +++++++++++++------------------------------------------------ 1 file changed, 14 insertions(+), 53 deletions(-) (limited to 'disk') diff --git a/disk/part.c b/disk/part.c index db5dd5d2f9..3039f5f235 100644 --- a/disk/part.c +++ b/disk/part.c @@ -21,34 +21,6 @@ #define PRINTF(fmt,args...) #endif -const struct block_drvr block_drvr[] = { -#if defined(CONFIG_CMD_IDE) - { .name = "ide", }, -#endif -#if defined(CONFIG_CMD_SATA) - {.name = "sata", }, -#endif -#if defined(CONFIG_SCSI) - { .name = "scsi", }, -#endif -#if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE) - { .name = "usb", }, -#endif -#if defined(CONFIG_MMC) - { - .name = "mmc", - .select_hwpart = mmc_select_hwpart, - }, -#endif -#if defined(CONFIG_SYSTEMACE) - { .name = "ace", }, -#endif -#if defined(CONFIG_SANDBOX) - { .name = "host", }, -#endif - { }, -}; - DECLARE_GLOBAL_DATA_PTR; #ifdef HAVE_BLOCK_DEVICE @@ -70,34 +42,23 @@ static struct part_driver *part_driver_lookup_type(int part_type) static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart) { - const struct block_drvr *drvr = block_drvr; - char *name; + struct blk_desc *dev_desc; + int ret; - if (!ifname) + dev_desc = blk_get_devnum_by_typename(ifname, dev); + if (!dev_desc) { + debug("%s: No device for iface '%s', dev %d\n", __func__, + ifname, dev); return NULL; - - name = drvr->name; -#ifdef CONFIG_NEEDS_MANUAL_RELOC - name += gd->reloc_off; -#endif - while (drvr->name) { - name = drvr->name; -#ifdef CONFIG_NEEDS_MANUAL_RELOC - name += gd->reloc_off; -#endif - if (strncmp(ifname, name, strlen(name)) == 0) { - struct blk_desc *dev_desc; - - dev_desc = blk_get_devnum_by_typename(name, dev); - if (!dev_desc) - return NULL; - if (blk_dselect_hwpart(dev_desc, hwpart)) - return NULL; - return dev_desc; - } - drvr++; } - return NULL; + ret = blk_dselect_hwpart(dev_desc, hwpart); + if (ret) { + debug("%s: Failed to select h/w partition: err-%d\n", __func__, + ret); + return NULL; + } + + return dev_desc; } struct blk_desc *blk_get_dev(const char *ifname, int dev) -- cgit v1.2.1 From 1598dfcb101c2c3aaac68a4ac8fc9bdef2293eaa Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 13:52:36 -0600 Subject: dm: blk: Use the correct error code for blk_get_device_by_str() Return -EINVAL instead of -1 in this function, to provide a more meaningful error. Signed-off-by: Simon Glass --- disk/part.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'disk') diff --git a/disk/part.c b/disk/part.c index 3039f5f235..6a1c02d9fa 100644 --- a/disk/part.c +++ b/disk/part.c @@ -350,7 +350,7 @@ int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str, if (*ep) { printf("** Bad device specification %s %s **\n", ifname, dev_str); - dev = -1; + dev = -EINVAL; goto cleanup; } @@ -359,7 +359,7 @@ int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str, if (*ep) { printf("** Bad HW partition specification %s %s **\n", ifname, hwpart_str); - dev = -1; + dev = -EINVAL; goto cleanup; } } @@ -367,7 +367,7 @@ int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str, *dev_desc = get_dev_hwpart(ifname, dev, hwpart); if (!(*dev_desc) || ((*dev_desc)->type == DEV_TYPE_UNKNOWN)) { printf("** Bad device %s %s **\n", ifname, dev_hwpart_str); - dev = -1; + dev = -ENOENT; goto cleanup; } -- cgit v1.2.1