devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: linux-kernel@lists.codethink.co.uk, ulf.hansson@linaro.org,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	kejia.hu@codethink.co.uk
Cc: devicetree@vger.kernel.org, Ben Dooks <ben.dooks@codethink.co.uk>
Subject: [PATCH] mmc: read alias from device-tree if probing via of.
Date: Fri,  2 Oct 2015 17:36:53 +0100	[thread overview]
Message-ID: <1443803813-13369-1-git-send-email-ben.dooks@codethink.co.uk> (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


                 reply	other threads:[~2015-10-02 16:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443803813-13369-1-git-send-email-ben.dooks@codethink.co.uk \
    --to=ben.dooks@codethink.co.uk \
    --cc=devicetree@vger.kernel.org \
    --cc=kejia.hu@codethink.co.uk \
    --cc=linux-kernel@lists.codethink.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).