From: Douglas Anderson <dianders@chromium.org>
To: ulf.hansson@linaro.org, jh80.chung@samsung.com
Cc: shawn.lin@rock-chips.com, adrian.hunter@intel.com,
stefan@agner.ch, linux-mmc@vger.kernel.org,
computersforpeace@gmail.com, dmitry.torokhov@gmail.com,
Dmitry Torokhov <dtor@chromium.org>,
Douglas Anderson <dianders@chromium.org>,
vbyravarasu@nvidia.com, huangtao@rock-chips.com, lars@metafoo.de,
sergei.shtylyov@cogentembedded.com, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] mmc: read mmc alias from device tree
Date: Thu, 28 Apr 2016 16:06:44 -0700 [thread overview]
Message-ID: <1461884805-29466-3-git-send-email-dianders@chromium.org> (raw)
In-Reply-To: <1461884805-29466-1-git-send-email-dianders@chromium.org>
From: Stefan Agner <stefan@agner.ch>
To get the SD/MMC host device ID, read the alias from the device
tree.
This is useful in case a SoC has multipe SD/MMC host controllers while
the second controller should logically be the first device (e.g. if
the second controller is connected to an internal eMMC). Combined
with block device numbering using MMC/SD host device ID, this
results in predictable name assignment of the internal eMMC block
device.
Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
[dianders: rebase + roll in http://crosreview.com/259916]
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
drivers/mmc/core/host.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 71bb2372f71d..7ecb6a6351b3 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -321,8 +321,8 @@ EXPORT_SYMBOL(mmc_of_parse);
*/
struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
{
- int err;
struct mmc_host *host;
+ int of_id = -1, id = -1;
host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL);
if (!host)
@@ -330,14 +330,29 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
/* scanning will be enabled when we're ready */
host->rescan_disable = 1;
+
+ if (dev->of_node)
+ of_id = of_alias_get_id(dev->of_node, "mmc");
+
idr_preload(GFP_KERNEL);
spin_lock(&mmc_host_lock);
- err = idr_alloc(&mmc_host_idr, host, 0, 0, GFP_NOWAIT);
- if (err >= 0)
- host->index = err;
+
+ if (of_id >= 0) {
+ id = idr_alloc(&mmc_host_idr, host, of_id, of_id + 1,
+ GFP_NOWAIT);
+ if (id < 0)
+ dev_warn(dev, "/aliases ID %d not available\n", of_id);
+ }
+
+ if (id < 0)
+ id = idr_alloc(&mmc_host_idr, host, 0, 0, GFP_NOWAIT);
+
+ if (id >= 0)
+ host->index = id;
+
spin_unlock(&mmc_host_lock);
idr_preload_end();
- if (err < 0) {
+ if (id < 0) {
kfree(host);
return NULL;
}
--
2.8.0.rc3.226.g39d4020
next prev parent reply other threads:[~2016-04-28 23:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-28 23:06 [PATCH 0/3] Patches to allow consistent mmc / mmcblk numbering Douglas Anderson
2016-04-28 23:06 ` [PATCH 1/3] Documentation: mmc: Document mmc aliases Douglas Anderson
2016-04-28 23:06 ` Douglas Anderson [this message]
2016-04-28 23:06 ` [PATCH 3/3] mmc: use SD/MMC host ID for block device name ID Douglas Anderson
[not found] ` <1461884805-29466-1-git-send-email-dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2016-04-29 2:18 ` [PATCH 0/3] Patches to allow consistent mmc / mmcblk numbering Jisheng Zhang
2016-04-29 7:21 ` Ulf Hansson
2016-04-29 17:32 ` Doug Anderson
2016-04-29 17:39 ` Arnd Bergmann
2016-05-10 11:09 ` Ulf Hansson
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=1461884805-29466-3-git-send-email-dianders@chromium.org \
--to=dianders@chromium.org \
--cc=adrian.hunter@intel.com \
--cc=computersforpeace@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=dtor@chromium.org \
--cc=huangtao@rock-chips.com \
--cc=jh80.chung@samsung.com \
--cc=lars@metafoo.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=sergei.shtylyov@cogentembedded.com \
--cc=shawn.lin@rock-chips.com \
--cc=stefan@agner.ch \
--cc=ulf.hansson@linaro.org \
--cc=vbyravarasu@nvidia.com \
/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).