[U-Boot] [PATCH v5 1/8] dm: mmc: use block layer in mmc driver

Yinbo Zhu yinbo.zhu at nxp.com
Fri Aug 10 07:52:24 UTC 2018


At present the MMC subsystem maintains its own list
of MMC devices. This cannot work with driver model
when CONFIG_BLK is enabled, use blk_dread to
replace previous mmc read interface,
use mmc_get_blk_desc to get the mmc device property

Signed-off-by: Yinbo Zhu <yinbo.zhu at nxp.com>
---
Change in v5:
		use block layer in mmc driver

 arch/arm/cpu/armv8/fsl-layerscape/ppa.c |    5 ++---
 drivers/mmc/mmc_legacy.c                |   10 +++++-----
 drivers/net/fm/fm.c                     |    2 +-
 drivers/qe/qe.c                         |    2 +-
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ppa.c b/arch/arm/cpu/armv8/fsl-layerscape/ppa.c
index a31c4d9..95875d3 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/ppa.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/ppa.c
@@ -99,7 +99,7 @@ int ppa_init(void)
 	cnt = DIV_ROUND_UP(fdt_header_len, 512);
 	debug("%s: MMC read PPA FIT header: dev # %u, block # %u, count %u\n",
 	      __func__, dev, blk, cnt);
-	ret = mmc->block_dev.block_read(&mmc->block_dev, blk, cnt, fitp);
+	ret = blk_dread(mmc_get_blk_desc(mmc), blk, cnt, fitp);
 	if (ret != cnt) {
 		free(fitp);
 		printf("MMC/SD read of PPA FIT header at offset 0x%x failed\n",
@@ -149,8 +149,7 @@ int ppa_init(void)
 	cnt = DIV_ROUND_UP(fw_length, 512);
 	debug("%s: MMC read PPA FIT image: dev # %u, block # %u, count %u\n",
 	      __func__, dev, blk, cnt);
-	ret = mmc->block_dev.block_read(&mmc->block_dev,
-					blk, cnt, ppa_fit_addr);
+	ret = blk_dread(mmc_get_blk_desc(mmc), blk, cnt, ppa_fit_addr);
 	if (ret != cnt) {
 		free(ppa_fit_addr);
 		printf("MMC/SD read of PPA FIT header at offset 0x%x failed\n",
diff --git a/drivers/mmc/mmc_legacy.c b/drivers/mmc/mmc_legacy.c
index 66a7cda..29d94e9 100644
--- a/drivers/mmc/mmc_legacy.c
+++ b/drivers/mmc/mmc_legacy.c
@@ -42,7 +42,7 @@ struct mmc *find_mmc_device(int dev_num)
 	list_for_each(entry, &mmc_devices) {
 		m = list_entry(entry, struct mmc, link);
 
-		if (m->block_dev.devnum == dev_num)
+		if (mmc_get_blk_desc(m)->devnum == dev_num)
 			return m;
 	}
 
@@ -60,7 +60,7 @@ int mmc_get_next_devnum(void)
 
 struct blk_desc *mmc_get_blk_desc(struct mmc *mmc)
 {
-	return &mmc->block_dev;
+	return mmc_get_blk_desc(mmc);
 }
 
 int get_mmc_num(void)
@@ -113,7 +113,7 @@ void print_mmc_devices(char separator)
 		else
 			mmc_type = NULL;
 
-		printf("%s: %d", m->cfg->name, m->block_dev.devnum);
+		printf("%s: %d", m->cfg->name, mmc_get_blk_desc(m)->devnum);
 		if (mmc_type)
 			printf(" (%s)", mmc_type);
 
@@ -218,7 +218,7 @@ static int mmc_select_hwpartp(struct blk_desc *desc, int hwpart)
 	if (!mmc)
 		return -ENODEV;
 
-	if (mmc->block_dev.hwpart == hwpart)
+	if (mmc_get_blk_desc(mmc)->hwpart == hwpart)
 		return 0;
 
 	if (mmc->part_config == MMCPART_NOAVAILABLE)
@@ -242,7 +242,7 @@ static int mmc_get_dev(int dev, struct blk_desc **descp)
 	if (ret)
 		return ret;
 
-	*descp = &mmc->block_dev;
+	*descp = mmc_get_blk_desc(mmc);
 
 	return 0;
 }
diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c
index 3327073..c5cf188 100644
--- a/drivers/net/fm/fm.c
+++ b/drivers/net/fm/fm.c
@@ -402,7 +402,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
 		printf("\nMMC read: dev # %u, block # %u, count %u ...\n",
 				dev, blk, cnt);
 		mmc_init(mmc);
-		(void)mmc->block_dev.block_read(&mmc->block_dev, blk, cnt,
+		(void)blk_dread(mmc_get_blk_desc(mmc), blk, cnt,
 						addr);
 	}
 #elif defined(CONFIG_SYS_QE_FMAN_FW_IN_REMOTE)
diff --git a/drivers/qe/qe.c b/drivers/qe/qe.c
index 7654df8..7010bbc 100644
--- a/drivers/qe/qe.c
+++ b/drivers/qe/qe.c
@@ -218,7 +218,7 @@ void u_qe_init(void)
 		printf("\nMMC read: dev # %u, block # %u, count %u ...\n",
 		       dev, blk, cnt);
 		mmc_init(mmc);
-		(void)mmc->block_dev.block_read(&mmc->block_dev, blk, cnt,
+		(void)blk_dread(mmc_get_blk_desc(mmc), blk, cnt,
 						addr);
 	}
 #endif
-- 
1.7.1



More information about the U-Boot mailing list