Skip to contentSkip to conversation

cmd_part: fix type in part command help text

PATCH New Stephen Warren 5 participants 17 messages May 7, 2014 – May 23, 2014 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 cmd_part: fix type in part command help text

From: Stephen Warren <[email protected]>

All the sub-commands start with the main command anme, but it was missing from one of the help texts.

---
 common/cmd_part.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/cmd_part.c +1 -1
index 14248548d9fe..c84bc27b4042 100644
@@ -82,7 +82,7 @@ int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 U_BOOT_CMD(
 	part,	5,	1,	do_part,
 	"disk partition related commands",
-	"uuid <interface> <dev>:<part>\n"
+	"part uuid <interface> <dev>:<part>\n"
 	"    - print partition UUID\n"
 	"part uuid <interface> <dev>:<part> <varname>\n"
 	"    - set environment variable to partition UUID\n"
Signature · 1 line
1.8.1.5
#1 lore raw

PATCH 1/4 cmd_part: fix type in part command help text

Quoted 4 lines · Stephen Warren

From: Stephen Warren <[email protected]>

All the sub-commands start with the main command anme, but it was missing from one of the help texts.

Tom, it looks like I forgot to CC you on these patches. I assume they'll go into the main U-Boot tree. Do you need me to resend them? If not, do they look OK?

Thanks.

#2 lore raw

PATCH 1/4 cmd_part: fix type in part command help text

Quoted 9 lines · Stephen Warren
Quoted 4 lines · Stephen Warren

From: Stephen Warren <[email protected]>

All the sub-commands start with the main command anme, but it was missing from one of the help texts.

Tom, it looks like I forgot to CC you on these patches. I assume they'll go into the main U-Boot tree. Do you need me to resend them? If not, do they look OK?

I had tossed the series to Pantelis in patchwork since it's mostly MMC related.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140514/6b644749/attachment.pgp>
#3 lore raw

PATCH 1/4 cmd_part: fix type in part command help text

Hi Tom,

Sorry about that; It's all on my pile of work to do when I get back home.

Quoted 7 lines · Tom Rini
Quoted 6 lines · Stephen Warren
Quoted 4 lines · Stephen Warren

From: Stephen Warren <[email protected]>

All the sub-commands start with the main command anme, but it was missing from one of the help texts.

Quoted 11 lines
Quoted 3 lines

Tom, it looks like I forgot to CC you on these patches. I assume they'll go into the main U-Boot tree. Do you need me to resend them? If not, do they look OK?

I had tossed the series to Pantelis in patchwork since it's mostly MMC related.

Signature · 1 line
Tom

Regards

-- Pantelis

#4 lore raw

PATCH 1/4 cmd_part: fix type in part command help text

Quoted 3 lines · Pantelis Antoniou

Hi Tom,

Sorry about that; It's all on my pile of work to do when I get back home.

Did these get applied somewhere?

Quoted 26 lines · Tom Rini
Quoted 8 lines · Stephen Warren
Quoted 6 lines · Stephen Warren
Quoted 4 lines

From: Stephen Warren <[email protected]>

All the sub-commands start with the main command anme, but it was missing from one of the help texts.

Quoted 11 lines
Quoted 3 lines

Tom, it looks like I forgot to CC you on these patches. I assume they'll go into the main U-Boot tree. Do you need me to resend them? If not, do they look OK?

I had tossed the series to Pantelis in patchwork since it's mostly MMC related.

Signature · 1 line
Tom

Regards

-- Pantelis

#5 lore raw

PATCH 2/4 disk: support devices with HW partitions

In reply to Stephen Warren

From: Stephen Warren <[email protected]>

Some device types (e.g. eMMC) have hardware-level partitions (for eMMC, separate boot and user data partitions). This change allows the user to specify the HW partition they wish to access when passing a device ID to U-Boot Commands such as part, ls, load, ums, etc.

The syntax allows an optional ".$hwpartid" to be appended to the device name string for those commands.

Existing syntax, for MMC device 0, default HW partition ID, SW partition ID 1:

ls mmc 0:1 /

New syntax, for MMC device 0, HW partition ID 1 (boot0), SW partition ID 2:

ls mmc 0.1:2 /

For my purposes, this is most useful for the ums (USB mass storage gadget) command, but there's no reason not to allow the new syntax globally.

This patch adds the core support infra-structure. The next patch will provide the implementation for MMC.

---
 disk/part.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 64 insertions(+), 10 deletions(-)
disk/part.c +64 -10
index b8c6aac80162..5e10cae015e5 100644
@@ -22,6 +22,7 @@
 struct block_drvr {
 	char *name;
 	block_dev_desc_t* (*get_dev)(int dev);
+	int (*select_hwpart)(int dev_num, int hwpart);
 };
 
 static const struct block_drvr block_drvr[] = {
@@ -52,11 +53,13 @@ static const struct block_drvr block_drvr[] = {
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef HAVE_BLOCK_DEVICE
-block_dev_desc_t *get_dev(const char *ifname, int dev)
+block_dev_desc_t *get_dev_hwpart(const char *ifname, int dev, int hwpart)
 {
 	const struct block_drvr *drvr = block_drvr;
 	block_dev_desc_t* (*reloc_get_dev)(int dev);
+	int (*select_hwpart)(int dev_num, int hwpart);
 	char *name;
+	int ret;
 
 	if (!ifname)
 		return NULL;
@@ -68,17 +71,41 @@ block_dev_desc_t *get_dev(const char *ifname, int dev)
 	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;
-#endif
-		if (strncmp(ifname, name, strlen(name)) == 0)
-			return reloc_get_dev(dev);
+		if (select_hwpart)
+			select_hwpart += gd->reloc_off;
+#endif
+		if (strncmp(ifname, name, strlen(name)) == 0) {
+			block_dev_desc_t *dev_desc = reloc_get_dev(dev);
+			if (!dev_desc)
+				return NULL;
+			if (hwpart == -1)
+				return dev_desc;
+			if (!select_hwpart)
+				return NULL;
+			ret = select_hwpart(dev_desc->dev, hwpart);
+			if (ret < 0)
+				return NULL;
+			return dev_desc;
+		}
 		drvr++;
 	}
 	return NULL;
 }
+
+block_dev_desc_t *get_dev(const char *ifname, int dev)
+{
+	return get_dev_hwpart(ifname, dev, -1);
+}
 #else
+block_dev_desc_t *get_dev_hwpart(const char *ifname, int dev, int hwpart)
+{
+	return NULL;
+}
+
 block_dev_desc_t *get_dev(const char *ifname, int dev)
 {
 	return NULL;
@@ -413,25 +440,52 @@ int get_partition_info(block_dev_desc_t *dev_desc, int part
 	return -1;
 }
 
-int get_device(const char *ifname, const char *dev_str,
+int get_device(const char *ifname, const char *dev_hwpart_str,
 	       block_dev_desc_t **dev_desc)
 {
 	char *ep;
-	int dev;
+	char *dup_str = NULL;
+	const char *dev_str, *hwpart_str;
+	int dev, hwpart;
+
+	hwpart_str = strchr(dev_hwpart_str, '.');
+	if (hwpart_str) {
+		dup_str = strdup(dev_hwpart_str);
+		dup_str[hwpart_str - dev_hwpart_str] = 0;
+		dev_str = dup_str;
+		hwpart_str++;
+	} else {
+		dev_str = dev_hwpart_str;
+		hwpart = -1;
+	}
 
 	dev = simple_strtoul(dev_str, &ep, 16);
 	if (*ep) {
 		printf("** Bad device specification %s %s **\n",
 		       ifname, dev_str);
-		return -1;
+		dev = -1;
+		goto cleanup;
+	}
+
+	if (hwpart_str) {
+		hwpart = simple_strtoul(hwpart_str, &ep, 16);
+		if (*ep) {
+			printf("** Bad HW partition specification %s %s **\n",
+			    ifname, hwpart_str);
+			dev = -1;
+			goto cleanup;
+		}
 	}
 
-	*dev_desc = get_dev(ifname, dev);
+	*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_str);
-		return -1;
+		printf("** Bad device %s %s **\n", ifname, dev_hwpart_str);
+		dev = -1;
+		goto cleanup;
 	}
 
+cleanup:
+	free(dup_str);
 	return dev;
 }
 
Signature · 1 line
1.8.1.5
#6 lore raw

PATCH 2/4 disk: support devices with HW partitions

Hi Stephen,

Quoted 166 lines · Stephen Warren

From: Stephen Warren <[email protected]>

Some device types (e.g. eMMC) have hardware-level partitions (for eMMC, separate boot and user data partitions). This change allows the user to specify the HW partition they wish to access when passing a device ID to U-Boot Commands such as part, ls, load, ums, etc.

The syntax allows an optional ".$hwpartid" to be appended to the device name string for those commands.

Existing syntax, for MMC device 0, default HW partition ID, SW partition ID 1:

ls mmc 0:1 /

New syntax, for MMC device 0, HW partition ID 1 (boot0), SW partition ID 2:

ls mmc 0.1:2 /

For my purposes, this is most useful for the ums (USB mass storage gadget) command, but there's no reason not to allow the new syntax globally.

This patch adds the core support infra-structure. The next patch will provide the implementation for MMC.

---
disk/part.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++---------

1 file changed, 64 insertions(+), 10 deletions(-)
disk/part.c +64 -10
index b8c6aac80162..5e10cae015e5 100644
@@ -22,6 +22,7 @@
 struct block_drvr {
 	char *name;
 	block_dev_desc_t* (*get_dev)(int dev);
+	int (*select_hwpart)(int dev_num, int hwpart);
 };
 
 static const struct block_drvr block_drvr[] = {
@@ -52,11 +53,13 @@ static const struct block_drvr block_drvr[] = {
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef HAVE_BLOCK_DEVICE
-block_dev_desc_t *get_dev(const char *ifname, int dev)
+block_dev_desc_t *get_dev_hwpart(const char *ifname, int dev, int hwpart)
 {
 	const struct block_drvr *drvr = block_drvr;
 	block_dev_desc_t* (*reloc_get_dev)(int dev);
+	int (*select_hwpart)(int dev_num, int hwpart);
 	char *name;
+	int ret;
 
 	if (!ifname)
 		return NULL;
@@ -68,17 +71,41 @@ block_dev_desc_t *get_dev(const char *ifname, int dev)
 	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;
-#endif
-		if (strncmp(ifname, name, strlen(name)) == 0)
-			return reloc_get_dev(dev);
+		if (select_hwpart)
+			select_hwpart += gd->reloc_off;
+#endif
+		if (strncmp(ifname, name, strlen(name)) == 0) {
+			block_dev_desc_t *dev_desc = reloc_get_dev(dev);
+			if (!dev_desc)
+				return NULL;
+			if (hwpart == -1)
+				return dev_desc;
+			if (!select_hwpart)
+				return NULL;
+			ret = select_hwpart(dev_desc->dev, hwpart);
+			if (ret < 0)
+				return NULL;
+			return dev_desc;
+		}
 		drvr++;
 	}
 	return NULL;
 }
+
+block_dev_desc_t *get_dev(const char *ifname, int dev)
+{
+	return get_dev_hwpart(ifname, dev, -1);
+}
 #else
+block_dev_desc_t *get_dev_hwpart(const char *ifname, int dev, int hwpart)
+{
+	return NULL;
+}
+
 block_dev_desc_t *get_dev(const char *ifname, int dev)
 {
 	return NULL;
@@ -413,25 +440,52 @@ int get_partition_info(block_dev_desc_t *dev_desc, int part
 	return -1;
 }
 
-int get_device(const char *ifname, const char *dev_str,
+int get_device(const char *ifname, const char *dev_hwpart_str,
 	       block_dev_desc_t **dev_desc)
 {
 	char *ep;
-	int dev;
+	char *dup_str = NULL;
+	const char *dev_str, *hwpart_str;
+	int dev, hwpart;
+
+	hwpart_str = strchr(dev_hwpart_str, '.');
+	if (hwpart_str) {
+		dup_str = strdup(dev_hwpart_str);
+		dup_str[hwpart_str - dev_hwpart_str] = 0;
+		dev_str = dup_str;
+		hwpart_str++;
+	} else {
+		dev_str = dev_hwpart_str;
+		hwpart = -1;
+	}
 
 	dev = simple_strtoul(dev_str, &ep, 16);
 	if (*ep) {
 		printf("** Bad device specification %s %s **\n",
 		       ifname, dev_str);
-		return -1;
+		dev = -1;
+		goto cleanup;
+	}
+
+	if (hwpart_str) {
+		hwpart = simple_strtoul(hwpart_str, &ep, 16);
+		if (*ep) {
+			printf("** Bad HW partition specification %s %s **\n",
+			    ifname, hwpart_str);
+			dev = -1;
+			goto cleanup;
+		}
 	}
 
-	*dev_desc = get_dev(ifname, dev);
+	*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_str);
-		return -1;
+		printf("** Bad device %s %s **\n", ifname, dev_hwpart_str);
+		dev = -1;
+		goto cleanup;
 	}
 
+cleanup:
+	free(dup_str);
 	return dev;
 }
 
Signature · 1 line
1.8.1.5

Applied

Thanks

-- Pantelis

#7 lore raw

PATCH 3/4 mmc: provide a select_hwpart implementation for get_device()

In reply to Stephen Warren

From: Stephen Warren <[email protected]>

This enables specifying which eMMC HW partition to target for any U-Boot command that uses the generic get_partition() function to parse its command-line arguments.

---
 disk/part.c       |  6 +++++-
 drivers/mmc/mmc.c | 26 ++++++++++++++++++++++++++
 include/part.h    |  2 ++
 3 files changed, 33 insertions(+), 1 deletion(-)
disk/part.c +5 -1
index 5e10cae015e5..2827089d8d5f 100644
@@ -39,7 +39,11 @@ static const struct block_drvr block_drvr[] = {
 	{ .name = "usb", .get_dev = usb_stor_get_dev, },
 #endif
 #if defined(CONFIG_MMC)
-	{ .name = "mmc", .get_dev = mmc_get_dev, },
+	{
+		.name = "mmc",
+		.get_dev = mmc_get_dev,
+		.select_hwpart = mmc_select_hwpart,
+	},
 #endif
 #if defined(CONFIG_SYSTEMACE)
 	{ .name = "ace", .get_dev = systemace_get_dev, },
drivers/mmc/mmc.c +26 -0
index 16051e52ff16..3089d8d807a8 100644
@@ -550,6 +550,32 @@ static int mmc_set_capacity(struct mmc *mmc, int part_num)
 	return 0;
 }
 
+int mmc_select_hwpart(int dev_num, int hwpart)
+{
+	struct mmc *mmc = find_mmc_device(dev_num);
+	int ret;
+
+	if (!mmc)
+		return -1;
+
+	if (mmc->part_num == hwpart)
+		return 0;
+
+	if (mmc->part_config == MMCPART_NOAVAILABLE) {
+		printf("Card doesn't support part_switch\n");
+		return -1;
+	}
+
+	ret = mmc_switch_part(dev_num, hwpart);
+	if (ret)
+		return -1;
+
+	mmc->part_num = hwpart;
+
+	return 0;
+}
+
+
 int mmc_switch_part(int dev_num, unsigned int part_num)
 {
 	struct mmc *mmc = find_mmc_device(dev_num);
include/part.h +2 -0
index 53532dcd6120..f2c8c641faa8 100644
@@ -103,6 +103,7 @@ block_dev_desc_t* sata_get_dev(int dev);
 block_dev_desc_t* scsi_get_dev(int dev);
 block_dev_desc_t* usb_stor_get_dev(int dev);
 block_dev_desc_t* mmc_get_dev(int dev);
+int mmc_select_hwpart(int dev_num, int hwpart);
 block_dev_desc_t* systemace_get_dev(int dev);
 block_dev_desc_t* mg_disk_get_dev(int dev);
 block_dev_desc_t *host_get_dev(int dev);
@@ -126,6 +127,7 @@ static inline block_dev_desc_t* sata_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* scsi_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* usb_stor_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* mmc_get_dev(int dev) { return NULL; }
+static inline int mmc_select_hwpart(int dev_num, int hwpart) { return -1; }
 static inline block_dev_desc_t* systemace_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* mg_disk_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t *host_get_dev(int dev) { return NULL; }
Signature · 1 line
1.8.1.5
#8 lore raw

PATCH 3/4 mmc: provide a select_hwpart implementation for get_device()

Quoted 9 lines · Stephen Warren
drivers/mmc/mmc.c +9 -0
+int mmc_select_hwpart(int dev_num, int hwpart)
+{
+       struct mmc *mmc = find_mmc_device(dev_num);
+       int ret;
+
+       if (!mmc)
+               return -1;
+
+       if (mmc->part_num == hwpart)

drivers/mmc/mmc.c static int mmc_set_capacity(struct mmc *mmc, int part_num) · line 571

Quoted 10 lines
drivers/mmc/mmc.c +10 -0
+               return 0;
+
+       if (mmc->part_config == MMCPART_NOAVAILABLE) {
+               printf("Card doesn't support part_switch\n");
+               return -1;
+       }
+
+       ret = mmc_switch_part(dev_num, hwpart);
+       if (ret)
+               return -1;

Can't you return more appropriate return values rather than -1?

#9 lore raw

PATCH 3/4 mmc: provide a select_hwpart implementation for get_device()

Quoted 3 lines · Fabio Estevam
Quoted 1 line · Stephen Warren

+int mmc_select_hwpart(int dev_num, int hwpart)

...

Quoted 5 lines

drivers/mmc/mmc.c static int mmc_set_capacity(struct mmc *mmc, int part_num) · line 571

Quoted 3 lines
drivers/mmc/mmc.c +3 -0
+       ret = mmc_switch_part(dev_num, hwpart);
+       if (ret)
+               return -1;

Can't you return more appropriate return values rather than -1?

Oh yes, I should return ret there. I'll hold off for a while before posting V2 though.

#10 lore raw

PATCH 3/4 mmc: provide a select_hwpart implementation for get_device()

In reply to Stephen Warren

Hi Stephen,

Quoted 90 lines · Stephen Warren

From: Stephen Warren <[email protected]>

This enables specifying which eMMC HW partition to target for any U-Boot command that uses the generic get_partition() function to parse its command-line arguments.

---

disk/part.c       |  6 +++++-
drivers/mmc/mmc.c | 26 ++++++++++++++++++++++++++
include/part.h    |  2 ++
3 files changed, 33 insertions(+), 1 deletion(-)
disk/part.c +5 -1
index 5e10cae015e5..2827089d8d5f 100644
@@ -39,7 +39,11 @@ static const struct block_drvr block_drvr[] = {
 	{ .name = "usb", .get_dev = usb_stor_get_dev, },
 #endif
 #if defined(CONFIG_MMC)
-	{ .name = "mmc", .get_dev = mmc_get_dev, },
+	{
+		.name = "mmc",
+		.get_dev = mmc_get_dev,
+		.select_hwpart = mmc_select_hwpart,
+	},
 #endif
 #if defined(CONFIG_SYSTEMACE)
 	{ .name = "ace", .get_dev = systemace_get_dev, },
drivers/mmc/mmc.c +26 -0
index 16051e52ff16..3089d8d807a8 100644
@@ -550,6 +550,32 @@ static int mmc_set_capacity(struct mmc *mmc, int part_num)
 	return 0;
 }
 
+int mmc_select_hwpart(int dev_num, int hwpart)
+{
+	struct mmc *mmc = find_mmc_device(dev_num);
+	int ret;
+
+	if (!mmc)
+		return -1;
+
+	if (mmc->part_num == hwpart)
+		return 0;
+
+	if (mmc->part_config == MMCPART_NOAVAILABLE) {
+		printf("Card doesn't support part_switch\n");
+		return -1;
+	}
+
+	ret = mmc_switch_part(dev_num, hwpart);
+	if (ret)
+		return -1;
+
+	mmc->part_num = hwpart;
+
+	return 0;
+}
+
+
 int mmc_switch_part(int dev_num, unsigned int part_num)
 {
 	struct mmc *mmc = find_mmc_device(dev_num);
include/part.h +2 -0
index 53532dcd6120..f2c8c641faa8 100644
@@ -103,6 +103,7 @@ block_dev_desc_t* sata_get_dev(int dev);
 block_dev_desc_t* scsi_get_dev(int dev);
 block_dev_desc_t* usb_stor_get_dev(int dev);
 block_dev_desc_t* mmc_get_dev(int dev);
+int mmc_select_hwpart(int dev_num, int hwpart);
 block_dev_desc_t* systemace_get_dev(int dev);
 block_dev_desc_t* mg_disk_get_dev(int dev);
 block_dev_desc_t *host_get_dev(int dev);
@@ -126,6 +127,7 @@ static inline block_dev_desc_t* sata_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* scsi_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* usb_stor_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* mmc_get_dev(int dev) { return NULL; }
+static inline int mmc_select_hwpart(int dev_num, int hwpart) { return -1; }
 static inline block_dev_desc_t* systemace_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* mg_disk_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t *host_get_dev(int dev) { return NULL; }
Signature · 1 line
1.8.1.5

Applied, but expect a follow up patch for returning something else than -1.

Thanks

-- Pantelis

#11 lore raw

PATCH 3/4 mmc: provide a select_hwpart implementation for get_device()

Quoted 8 lines · Pantelis Antoniou

Hi Stephen,

Quoted 3 lines · Stephen Warren

This enables specifying which eMMC HW partition to target for any U-Boot command that uses the generic get_partition() function to parse its command-line arguments.

Applied, but expect a follow up patch for returning something else than -1.

What else should it return? -1 is consistent with plenty of code in that file...

#12 lore raw

PATCH 3/4 mmc: provide a select_hwpart implementation for get_device()

Hi Stephen,

Quoted 4 lines · Stephen Warren
Quoted 3 lines · Pantelis Antoniou

Hi Stephen,

On May 7, 2014, at 9:19 PM, Stephen Warren wrote:

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

This enables specifying which eMMC HW partition to target for any U-Boot command that uses the generic get_partition() function to parse its command-line arguments.

Applied, but expect a follow up patch for returning something else than -1.

What else should it return? -1 is consistent with plenty of code in that file...

Some kind of -ERRNO value?

Regards

-- Pantelis

#13 lore raw

PATCH 4/4 cmd_mmc: use new mmc_select_hwpart() function

In reply to Stephen Warren

From: Stephen Warren <[email protected]>

The implementation of mmc_select_hwpart() was cribbed from do_mmcops(). Update do_mmcops() to call mmc_select_hwpart() to avoid duplication.

---
 common/cmd_mmc.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
common/cmd_mmc.c +5 -14
index c1916c9b56a6..572aa895fa1c 100644
@@ -193,7 +193,7 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		print_mmc_devices('\n');
 		return 0;
 	} else if (strcmp(argv[1], "dev") == 0) {
-		int dev, part = -1;
+		int dev, part = -1, ret;
 		struct mmc *mmc;
 
 		if (argc == 2)
@@ -219,20 +219,11 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 		mmc_init(mmc);
 		if (part != -1) {
-			int ret;
-			if (mmc->part_config == MMCPART_NOAVAILABLE) {
-				printf("Card doesn't support part_switch\n");
+			ret = mmc_select_hwpart(dev, part);
+			printf("switch to partitions #%d, %s\n",
+			       part, (!ret) ? "OK" : "ERROR");
+			if (ret)
 				return 1;
-			}
-
-			if (part != mmc->part_num) {
-				ret = mmc_switch_part(dev, part);
-				if (!ret)
-					mmc->part_num = part;
-
-				printf("switch to partitions #%d, %s\n",
-						part, (!ret) ? "OK" : "ERROR");
-			}
 		}
 		curr_device = dev;
 		if (mmc->part_config == MMCPART_NOAVAILABLE)
Signature · 1 line
1.8.1.5
#14 lore raw

PATCH 4/4 cmd_mmc: use new mmc_select_hwpart() function

Hi Stephen,

Quoted 51 lines · Stephen Warren

From: Stephen Warren <[email protected]>

The implementation of mmc_select_hwpart() was cribbed from do_mmcops(). Update do_mmcops() to call mmc_select_hwpart() to avoid duplication.

---
common/cmd_mmc.c | 19 +++++--------------

1 file changed, 5 insertions(+), 14 deletions(-)
common/cmd_mmc.c +5 -14
index c1916c9b56a6..572aa895fa1c 100644
@@ -193,7 +193,7 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		print_mmc_devices('\n');
 		return 0;
 	} else if (strcmp(argv[1], "dev") == 0) {
-		int dev, part = -1;
+		int dev, part = -1, ret;
 		struct mmc *mmc;
 
 		if (argc == 2)
@@ -219,20 +219,11 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 		mmc_init(mmc);
 		if (part != -1) {
-			int ret;
-			if (mmc->part_config == MMCPART_NOAVAILABLE) {
-				printf("Card doesn't support part_switch\n");
+			ret = mmc_select_hwpart(dev, part);
+			printf("switch to partitions #%d, %s\n",
+			       part, (!ret) ? "OK" : "ERROR");
+			if (ret)
 				return 1;
-			}
-
-			if (part != mmc->part_num) {
-				ret = mmc_switch_part(dev, part);
-				if (!ret)
-					mmc->part_num = part;
-
-				printf("switch to partitions #%d, %s\n",
-						part, (!ret) ? "OK" : "ERROR");
-			}
 		}
 		curr_device = dev;
 		if (mmc->part_config == MMCPART_NOAVAILABLE)
Signature · 1 line
1.8.1.5

Due to patch order mangling, I've applied but with some manual placement. Please verify that it works properly on your end after the patches land at u-boot-mmc.

Thanks

-- Pantelis

#15 lore raw

PATCH 4/4 cmd_mmc: use new mmc_select_hwpart() function

Quoted 11 lines · Pantelis Antoniou

Hi Stephen,

Quoted 4 lines · Stephen Warren

From: Stephen Warren <[email protected]>

The implementation of mmc_select_hwpart() was cribbed from do_mmcops(). Update do_mmcops() to call mmc_select_hwpart() to avoid duplication.

Due to patch order mangling, I've applied but with some manual placement. Please verify that it works properly on your end after the patches land at u-boot-mmc.

I think this looks fine, thanks.

#16 lore raw

PATCH 1/4 cmd_part: fix type in part command help text

In reply to Stephen Warren

Hi Stephen,

Quoted 3 lines · Stephen Warren

From: Stephen Warren <[email protected]>

All the sub-commands start with the main command anme, but it was

anme=name

Quoted 17 lines

missing from one of the help texts.

---
common/cmd_part.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
common/cmd_part.c +0 -0
index 14248548d9fe..c84bc27b4042 100644
@@ -82,7 +82,7 @@ int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])

U_BOOT_CMD(

	part,	5,	1,	do_part,
	"disk partition related commands",
common/cmd_part.c +1 -1
-	"uuid <interface> <dev>:<part>\n"
+	"part uuid <interface> <dev>:<part>\n"
Quoted 6 lines

" - print partition UUID\n"
"part uuid <interface> <dev>:<part> <varname>\n"
" - set environment variable to partition UUID\n"

Signature · 1 line
1.8.1.5

Fixed typos and applied.

Thanks

-- Pantelis