[U-Boot] [PATCH 4/4] cmd_mmc: use new mmc_select_hwpart() function

Stephen Warren
2014-05-07T18:19:03Z

From: Stephen Warren <swarren@nvidia.com>

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

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
common/cmd_mmc.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index c1916c9b56a6..572aa895fa1c 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -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)
--
1.8.1.5