Commit ecdd57e27467593a864ca5437db45266e36e3a7b

Authored by Stephen Warren
Committed by Pantelis Antoniou
1 parent 60dc58f735

disk: default to HW partition 0 if not specified

Currently, get_device()/get_dev_hwpart() for MMC devices does not select
an explicit HW partition unless the user explicitly requests one, i.e. by
requesting device "mmc 0.0" rather than just "mmc 0". I think it makes
more sense if the default is to select HW partition 0 (main data area)
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

Attempts to access SW partition 1 on HW partition 1 (boot0), rather than
SW partition 1 on HW partition 0 (main data area):
ls mmc 0:1 /

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

Many device types don't support HW partitions at all, so if HW partition
0 is selected (either explicitly or as the default) and there's no
select_hwpart function, we simply skip attempting to select a HW
partition.

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>

Showing 1 changed file with 3 additions and 3 deletions Side-by-side Diff

... ... @@ -86,7 +86,7 @@
86 86 block_dev_desc_t *dev_desc = reloc_get_dev(dev);
87 87 if (!dev_desc)
88 88 return NULL;
89   - if (hwpart == -1)
  89 + if (hwpart == 0 && !select_hwpart)
90 90 return dev_desc;
91 91 if (!select_hwpart)
92 92 return NULL;
... ... @@ -102,7 +102,7 @@
102 102  
103 103 block_dev_desc_t *get_dev(const char *ifname, int dev)
104 104 {
105   - return get_dev_hwpart(ifname, dev, -1);
  105 + return get_dev_hwpart(ifname, dev, 0);
106 106 }
107 107 #else
108 108 block_dev_desc_t *get_dev_hwpart(const char *ifname, int dev, int hwpart)
... ... @@ -460,7 +460,7 @@
460 460 hwpart_str++;
461 461 } else {
462 462 dev_str = dev_hwpart_str;
463   - hwpart = -1;
  463 + hwpart = 0;
464 464 }
465 465  
466 466 dev = simple_strtoul(dev_str, &ep, 16);