Skip to contentSkip to conversation

mmc: Add support for checking device number against alias index

PATCH Superseded Aswath Govindraju 3 participants 8 messages Mar 15, 2021 – Mar 25, 2021 MMC, SD and SDIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover mmc: Add support for checking device number against alias index

The following series of patches,
- add support to check for a device with a sequence number equal to device number before looking for matching index
- assign device number based on node's alias index in SPL too.

Aswath Govindraju (2):
mmc: Check for device with a seq number equal to num before checking
against index
mmc: mmc-uclass: Assign devnum as alias index in SPL too if
CONFIG_SPL_DM_SEQ_ALIAS is enabled

 drivers/mmc/mmc-uclass.c | 10 +++++-----
 drivers/mmc/mmc.c        |  8 +++++---
 2 files changed, 10 insertions(+), 8 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 mmc: Check for device with a seq number equal to num before checking against index

First check if there is an alias for the device tree node defined with the given num before checking against device index.

---
 drivers/mmc/mmc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/mmc/mmc.c +5 -3
index b4c8e7f293bd..1e83007286b2 100644
@@ -3052,9 +3052,11 @@ int mmc_init_device(int num)
 	struct mmc *m;
 	int ret;
 
-	ret = uclass_get_device(UCLASS_MMC, num, &dev);
-	if (ret)
-		return ret;
+	if (uclass_get_device_by_seq(UCLASS_MMC, num, &dev)) {
+		ret = uclass_get_device(UCLASS_MMC, num, &dev);
+		if (ret)
+			return ret;
+	}
 
 	m = mmc_get_mmc_dev(dev);
 	if (!m)
Signature · 1 line
2.17.1
#3 lore raw

PATCH 1/2 mmc: Check for device with a seq number equal to num before checking against index

In reply to Aswath Govindraju
Quoted 4 lines · Aswath Govindraju

First check if there is an alias for the device tree node defined with the given num before checking against device index.

Best Regards,
Jaehoon Chung

Quoted 24 lines
---
 drivers/mmc/mmc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/mmc/mmc.c +5 -3
index b4c8e7f293bd..1e83007286b2 100644
@@ -3052,9 +3052,11 @@ int mmc_init_device(int num)
 	struct mmc *m;
 	int ret;
 
-	ret = uclass_get_device(UCLASS_MMC, num, &dev);
-	if (ret)
-		return ret;
+	if (uclass_get_device_by_seq(UCLASS_MMC, num, &dev)) {
+		ret = uclass_get_device(UCLASS_MMC, num, &dev);
+		if (ret)
+			return ret;
+	}
 
 	m = mmc_get_mmc_dev(dev);
 	if (!m)
#4 lore raw

PATCH 2/2 mmc: mmc-uclass: Assign devnum as alias index in SPL too if CONFIG_SPL_DM_SEQ_ALIAS is enabled

In reply to Aswath Govindraju

Assign the nodes alias index as the device number in SPL too, if CONFIG_SPL_DM_SEQ_ALIAS is enabled.

---
 drivers/mmc/mmc-uclass.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mmc/mmc-uclass.c +5 -5
index 53eabc9e612d..67fcba3c207c 100644
@@ -387,11 +387,11 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
 
 	if (!mmc_get_ops(dev))
 		return -ENOSYS;
-#ifndef CONFIG_SPL_BUILD
-	/* Use the fixed index with aliase node's index */
-	ret = dev_read_alias_seq(dev, &devnum);
-	debug("%s: alias ret=%d, devnum=%d\n", __func__, ret, devnum);
-#endif
+	if (IS_ENABLED(CONFIG_SPL_DM_SEQ_ALIAS)) {
+		/* Use the fixed index with aliase node's index */
+		ret = dev_read_alias_seq(dev, &devnum);
+		debug("%s: alias ret=%d, devnum=%d\n", __func__, ret, devnum);
+	}
 
 	ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC,
 			devnum, 512, 0, &bdev);
Signature · 1 line
2.17.1
#5 lore raw

PATCH 2/2 mmc: mmc-uclass: Assign devnum as alias index in SPL too if CONFIG_SPL_DM_SEQ_ALIAS is enabled

Quoted 17 lines · Aswath Govindraju

Assign the nodes alias index as the device number in SPL too, if CONFIG_SPL_DM_SEQ_ALIAS is enabled.

---
 drivers/mmc/mmc-uclass.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mmc/mmc-uclass.c +0 -1
index 53eabc9e612d..67fcba3c207c 100644
@@ -387,11 +387,11 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
 
 	if (!mmc_get_ops(dev))
 		return -ENOSYS;
-#ifndef CONFIG_SPL_BUILD

drivers/mmc/mmc-uclass.c int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg) · line 395

Quoted 10 lines
drivers/mmc/mmc-uclass.c +5 -4
-	/* Use the fixed index with aliase node's index */
-	ret = dev_read_alias_seq(dev, &devnum);
-	debug("%s: alias ret=%d, devnum=%d\n", __func__, ret, devnum);
-#endif
+	if (IS_ENABLED(CONFIG_SPL_DM_SEQ_ALIAS)) {
+		/* Use the fixed index with aliase node's index */
+		ret = dev_read_alias_seq(dev, &devnum);
+		debug("%s: alias ret=%d, devnum=%d\n", __func__, ret, devnum);
+	}
 

Thanks and regards,
Lokesh

#6 lore raw

PATCH 2/2 mmc: mmc-uclass: Assign devnum as alias index in SPL too if CONFIG_SPL_DM_SEQ_ALIAS is enabled

In reply to Aswath Govindraju
Quoted 4 lines · Aswath Govindraju

Assign the nodes alias index as the device number in SPL too, if CONFIG_SPL_DM_SEQ_ALIAS is enabled.

Best Regards,
Jaehoon Chung

Quoted 26 lines
---
 drivers/mmc/mmc-uclass.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mmc/mmc-uclass.c +5 -5
index 53eabc9e612d..67fcba3c207c 100644
@@ -387,11 +387,11 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
 
 	if (!mmc_get_ops(dev))
 		return -ENOSYS;
-#ifndef CONFIG_SPL_BUILD
-	/* Use the fixed index with aliase node's index */
-	ret = dev_read_alias_seq(dev, &devnum);
-	debug("%s: alias ret=%d, devnum=%d\n", __func__, ret, devnum);
-#endif
+	if (IS_ENABLED(CONFIG_SPL_DM_SEQ_ALIAS)) {
+		/* Use the fixed index with aliase node's index */
+		ret = dev_read_alias_seq(dev, &devnum);
+		debug("%s: alias ret=%d, devnum=%d\n", __func__, ret, devnum);
+	}
 
 	ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC,
 			devnum, 512, 0, &bdev);
#7 lore raw

PATCH 2/2 mmc: mmc-uclass: Assign devnum as alias index in SPL too if CONFIG_SPL_DM_SEQ_ALIAS is enabled

In reply to Aswath Govindraju

Hi all,

Quoted 20 lines · Aswath Govindraju

Assign the nodes alias index as the device number in SPL too, if CONFIG_SPL_DM_SEQ_ALIAS is enabled.

---
 drivers/mmc/mmc-uclass.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mmc/mmc-uclass.c +0 -3
index 53eabc9e612d..67fcba3c207c 100644
@@ -387,11 +387,11 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
 
 	if (!mmc_get_ops(dev))
 		return -ENOSYS;
-#ifndef CONFIG_SPL_BUILD
-	/* Use the fixed index with aliase node's index */
-	ret = dev_read_alias_seq(dev, &devnum);

drivers/mmc/mmc-uclass.c int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg) · line 397

Quoted 10 lines
drivers/mmc/mmc-uclass.c +5 -2
-	debug("%s: alias ret=%d, devnum=%d\n", __func__, ret, devnum);
-#endif
+	if (IS_ENABLED(CONFIG_SPL_DM_SEQ_ALIAS)) {
+		/* Use the fixed index with aliase node's index */
+		ret = dev_read_alias_seq(dev, &devnum);
+		debug("%s: alias ret=%d, devnum=%d\n", __func__, ret, devnum);
+	}
 
 	ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC,
 			devnum, 512, 0, &bdev);

dev_read_alias_seq() has dependency on CONFIG_SPL_OF_LIBFDT. There is a possiblility that CONFIG_SPL_OF_LIBFDT is disabled and CONFIG_SPL_DM_SEQ_ALIAS is enabled, this would lead to break in builds.

To remove this dependency dev_seq() can be used instead of dev_read_alias_seq(). I will be respining this series after making this change.

Thanks,
Aswath