public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] cmd_mmc: default to HW partition 0 if not specified
@ 2014-05-23 18:48 Stephen Warren
  2014-05-23 18:48 ` [U-Boot] [PATCH 2/2] disk: " Stephen Warren
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Stephen Warren @ 2014-05-23 18:48 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

Currently, "mmc dev 0" does not change the selected HW partition. I
think it makes more sense if "mmc dev 0" is an alias for "mmc dev 0 0",
i.e. that HW partition 0 (main data area) is always selected by default
if the user didn't request a specific partition. Otherwise, the following
happens, which feels wrong:

Select HW partition 1 (boot0):
mmc dev 0 1

Doesn't change the HW partition, so it's still 1 (boot0):
mmc dev 0

With this patch, the second command above re-selects the main data area.

Note that some MMC devices (i.e. SD cards) don't support HW partitions.
However, this patch still works, since mmc_start_init() sets the current
partition number to 0, and mmc_select_hwpart() succeeds if the requested
partition is already selected.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
This series depends on "mmc: return meaningful error codes from
mmc_select_hwpart" (which I just sent) for context.

 common/cmd_mmc.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index eea337506c3f..9e6a26fe62a2 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -403,7 +403,7 @@ static int do_mmc_part(cmd_tbl_t *cmdtp, int flag,
 static int do_mmc_dev(cmd_tbl_t *cmdtp, int flag,
 		      int argc, char * const argv[])
 {
-	int dev, part = -1, ret;
+	int dev, part = 0, ret;
 	struct mmc *mmc;
 
 	if (argc == 1) {
@@ -426,13 +426,12 @@ static int do_mmc_dev(cmd_tbl_t *cmdtp, int flag,
 	if (!mmc)
 		return CMD_RET_FAILURE;
 
-	if (part != -1) {
-		ret = mmc_select_hwpart(dev, part);
-		printf("switch to partitions #%d, %s\n",
-			part, (!ret) ? "OK" : "ERROR");
-		if (ret)
-			return 1;
-	}
+	ret = mmc_select_hwpart(dev, part);
+	printf("switch to partitions #%d, %s\n",
+	       part, (!ret) ? "OK" : "ERROR");
+	if (ret)
+		return 1;
+
 	curr_device = dev;
 	if (mmc->part_config == MMCPART_NOAVAILABLE)
 		printf("mmc%d is current device\n", curr_device);
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-06-12 11:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-23 18:48 [U-Boot] [PATCH 1/2] cmd_mmc: default to HW partition 0 if not specified Stephen Warren
2014-05-23 18:48 ` [U-Boot] [PATCH 2/2] disk: " Stephen Warren
2014-06-12 11:23   ` Pantelis Antoniou
2014-05-30 21:11 ` [U-Boot] [PATCH 1/2] cmd_mmc: " Stephen Warren
2014-06-10 16:00   ` Stephen Warren
2014-06-12 11:21 ` Pantelis Antoniou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox