]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
cmd_mmc: default to HW partition 0 if not specified
authorStephen Warren <swarren@nvidia.com>
Fri, 23 May 2014 18:48:10 +0000 (12:48 -0600)
committerPantelis Antoniou <panto@antoniou-consulting.com>
Thu, 12 Jun 2014 12:21:12 +0000 (15:21 +0300)
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>
Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
common/cmd_mmc.c

index eea337506c3f21829c3a4dff9e832f26d505ac93..9e6a26fe62a26bbc53e4ebc0f074d2abd15cd704 100644 (file)
@@ -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);