[U-Boot] [PATCH 16/23] dm: mmc: Adjust mmc_switch_part() to use a struct mmc

Simon Glass sjg at chromium.org
Mon Apr 11 03:12:36 CEST 2016


Instead of looking up the MMC device by number, just pass it in. This makes
it possible to use this function with driver model.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 drivers/mmc/mmc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 48aedc2..4ba13a1 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -560,14 +560,10 @@ static int mmc_set_capacity(struct mmc *mmc, int part_num)
 	return 0;
 }
 
-int mmc_switch_part(int dev_num, unsigned int part_num)
+static int mmc_switch_part(struct mmc *mmc, unsigned int part_num)
 {
-	struct mmc *mmc = find_mmc_device(dev_num);
 	int ret;
 
-	if (!mmc)
-		return -1;
-
 	ret = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF,
 			 (mmc->part_config & ~PART_ACCESS_MASK)
 			 | (part_num & PART_ACCESS_MASK));
@@ -578,7 +574,7 @@ int mmc_switch_part(int dev_num, unsigned int part_num)
 	 */
 	if ((ret == 0) || ((ret == -ENODEV) && (part_num == 0))) {
 		ret = mmc_set_capacity(mmc, part_num);
-		mmc->block_dev.hwpart = part_num;
+		mmc_get_blk_desc(mmc)->hwpart = part_num;
 	}
 
 	return ret;
@@ -598,7 +594,7 @@ static int mmc_select_hwpartp(struct blk_desc *desc, int hwpart)
 	if (mmc->part_config == MMCPART_NOAVAILABLE)
 		return -EMEDIUMTYPE;
 
-	ret = mmc_switch_part(desc->devnum, hwpart);
+	ret = mmc_switch_part(mmc, hwpart);
 	if (ret)
 		return ret;
 
@@ -619,7 +615,7 @@ int mmc_select_hwpart(int dev_num, int hwpart)
 	if (mmc->part_config == MMCPART_NOAVAILABLE)
 		return -EMEDIUMTYPE;
 
-	ret = mmc_switch_part(dev_num, hwpart);
+	ret = mmc_switch_part(mmc, hwpart);
 	if (ret)
 		return ret;
 
-- 
2.8.0.rc3.226.g39d4020



More information about the U-Boot mailing list