Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1238404

[PATCH] mmc: read alias from device-tree if probing via of.

From Ben Dooks <ben.dooks@codethink.co.uk>
Newsgroups linux.kernel
Subject [PATCH] mmc: read alias from device-tree if probing via of.
Date 2015-10-02 18:40 +0200
Message-ID <qfbxh-od-29@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


The mmc host controller fails to check for the presence
of an aliases entry in the device tree when creating a
new mmc host. This means that  mmc bus numbers are not
as specified in the aliases node.

For example, the following on an imx6 would make mmc0
the second sdhci, and mmc2 the first sdhci:

aliases {
	mmc0 = &usdhc2;
	mmc2 = &usdhc0;
}

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Tested-by: Kejia Hu <kejia.hu@codethink.co.uk>
---
 drivers/mmc/core/host.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index abd933b..3bed4d0 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -561,7 +561,11 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
 	host->rescan_disable = 1;
 	idr_preload(GFP_KERNEL);
 	spin_lock(&mmc_host_lock);
-	err = idr_alloc(&mmc_host_idr, host, 0, 0, GFP_NOWAIT);
+	err = of_alias_get_id(dev->of_node, "mmc");
+	if (err >= 0)
+		err = idr_alloc(&mmc_host_idr, host, err, err+1, GFP_NOWAIT);
+	if (err < 0)
+		err = idr_alloc(&mmc_host_idr, host, 0, 0, GFP_NOWAIT);
 	if (err >= 0)
 		host->index = err;
 	spin_unlock(&mmc_host_lock);
-- 
2.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] mmc: read alias from device-tree if probing via of. Ben Dooks <ben.dooks@codethink.co.uk> - 2015-10-02 18:40 +0200

csiph-web