[U-Boot] [PATCH 05/23] dm: mmc: Implement the select_hwpart() method

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


Implement this method so that hardware partitions will work correctly with
MMC.

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

 drivers/mmc/mmc.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 2211ac6..e270f5f 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -606,6 +606,27 @@ int mmc_switch_part(int dev_num, unsigned int part_num)
 	return ret;
 }
 
+static int mmc_select_hwpartp(struct blk_desc *desc, int hwpart)
+{
+	struct mmc *mmc = find_mmc_device(desc->devnum);
+	int ret;
+
+	if (!mmc)
+		return -ENODEV;
+
+	if (mmc->block_dev.hwpart == hwpart)
+		return 0;
+
+	if (mmc->part_config == MMCPART_NOAVAILABLE)
+		return -EMEDIUMTYPE;
+
+	ret = mmc_switch_part(desc->devnum, hwpart);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 int mmc_select_hwpart(int dev_num, int hwpart)
 {
 	struct mmc *mmc = find_mmc_device(dev_num);
@@ -1973,4 +1994,5 @@ U_BOOT_LEGACY_BLK(mmc) = {
 	.if_type	= IF_TYPE_MMC,
 	.max_devs	= -1,
 	.get_dev	= mmc_get_dev,
+	.select_hwpart	= mmc_select_hwpartp,
 };
-- 
2.8.0.rc3.226.g39d4020



More information about the U-Boot mailing list