linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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,
	Heiko Stuebner <heiko@sntech.de>,
	jszhang@marvell.com, linux-rockchip@lists.infradead.org,
	devicetree-spec@vger.kernel.org,
	Dmitry Torokhov <dtor@chromium.org>,
	Douglas Anderson <dianders@chromium.org>,
	vbyravarasu@nvidia.com, kirill.shutemov@linux.intel.com,
	chaotian.jing@mediatek.com, zhonghui.fu@linux.intel.com,
	sergei.shtylyov@cogentembedded.com, linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/4] mmc: read mmc alias from device tree
Date: Fri, 29 Apr 2016 10:32:17 -0700	[thread overview]
Message-ID: <1461951139-6109-3-git-send-email-dianders@chromium.org> (raw)
In-Reply-To: <1461951139-6109-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>
---
Changes in v2:
- Rebased atop mmc-next
- Stat dynamic allocation after fixed allocation; thanks Wolfram!

 drivers/mmc/core/host.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index e0a3ee16c0d3..e09f1d6207d3 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -314,11 +314,26 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
 {
 	int err;
 	struct mmc_host *host;
+	int id;
 
 	host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL);
 	if (!host)
 		return NULL;
 
+	/* If OF aliases exist, start dynamic assignment after highest */
+	id = of_alias_get_highest_id("mmc");
+	id = (id < 0) ? 0 : id + 1;
+
+	/* If this devices has OF node, maybe it has an alias */
+	if (dev->of_node) {
+		int of_id = of_alias_get_id(dev->of_node, "mmc");
+
+		if (of_id < 0)
+			dev_warn(dev, "/aliases ID not available\n");
+		else
+			id = of_id;
+	}
+
 	/* scanning will be enabled when we're ready */
 	host->rescan_disable = 1;
 
@@ -329,7 +344,7 @@ again:
 	}
 
 	spin_lock(&mmc_host_lock);
-	err = ida_get_new(&mmc_host_ida, &host->index);
+	err = ida_get_new_above(&mmc_host_ida, id, &host->index);
 	spin_unlock(&mmc_host_lock);
 
 	if (err == -EAGAIN) {
-- 
2.8.0.rc3.226.g39d4020

  parent reply	other threads:[~2016-04-29 17:32 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-29 17:32 [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Douglas Anderson
2016-04-29 17:32 ` [PATCH v2 1/4] Documentation: mmc: Document mmc aliases Douglas Anderson
2016-04-29 17:32 ` Douglas Anderson [this message]
2016-04-29 17:32 ` [PATCH v2 3/4] mmc: use SD/MMC host ID for block device name ID Douglas Anderson
2016-04-29 17:32 ` [PATCH v2 4/4] ARM: dts: rockchip: Add mmc aliases for rk3288 platform Douglas Anderson
2016-04-29 18:12 ` [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Rob Herring
2016-04-29 19:31   ` Doug Anderson
2016-04-29 19:50     ` Russell King - ARM Linux
2016-04-29 20:02       ` Doug Anderson
2016-04-29 18:12 ` Russell King - ARM Linux
2016-04-29 19:43   ` Doug Anderson
2016-04-29 19:57     ` Russell King - ARM Linux
2016-04-29 20:04       ` Doug Anderson
2016-04-29 21:13         ` Russell King - ARM Linux
2016-04-29 21:17           ` Doug Anderson
2016-04-29 21:29             ` Russell King - ARM Linux
2016-04-29 21:39               ` Doug Anderson
2016-04-29 21:50                 ` Russell King - ARM Linux
2016-04-29 21:56                   ` Doug Anderson
2016-04-29 22:16                     ` Russell King - ARM Linux
2016-04-29 22:22                       ` Doug Anderson
2016-04-29 22:44                         ` Russell King - ARM Linux
2016-04-29 23:01                           ` Doug Anderson
2016-04-29 23:58                             ` Peter Hurley
     [not found]                               ` <CAD=FV=V_YyfBOSs7BLkyhv=_5HBmf3djUWACbL6d-bwnrueDjA@mail.gmail.com>
2016-04-30  0:31                                 ` Peter Hurley
2016-04-30  2:29                                   ` Doug Anderson
2016-04-30  8:38                                   ` Russell King - ARM Linux
2016-04-30 13:23                             ` Rob Herring
2016-04-29 22:42                       ` Javier Martinez Canillas
2016-04-30 10:48                         ` Russell King - ARM Linux
2016-05-03 19:17                           ` Trent Piepho
2016-05-04  7:18   ` Pavel Machek
2016-05-04 12:25     ` Rob Herring
2016-05-04 12:46       ` Pavel Machek
2019-03-05 12:39 ` Måns Rullgård
2019-03-15 21:52   ` Tim Harvey
2019-03-15 23:00     ` Marek Vasut
2019-03-15 23:13       ` Tim Harvey
2019-03-15 23:23       ` Doug Anderson
     [not found]       ` <yw1xftrn2em9.fsf@mansr.com>
2019-03-16 12:33         ` Marek Vasut
2019-03-16 15:39           ` Russell King - ARM Linux admin
2019-03-17 15:05             ` Stefan Agner
2019-03-17 15:43               ` Russell King - ARM Linux admin
2019-03-17 15:50                 ` Marek Vasut
2019-03-17 16:48               ` Måns Rullgård
2019-03-17 16:59                 ` Russell King - ARM Linux admin
2019-03-27 17:37                   ` Tim Harvey
2019-03-27 20:54                     ` Russell King - ARM Linux admin

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=1461951139-6109-3-git-send-email-dianders@chromium.org \
    --to=dianders@chromium.org \
    --cc=adrian.hunter@intel.com \
    --cc=chaotian.jing@mediatek.com \
    --cc=computersforpeace@gmail.com \
    --cc=devicetree-spec@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dtor@chromium.org \
    --cc=heiko@sntech.de \
    --cc=jh80.chung@samsung.com \
    --cc=jszhang@marvell.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.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 \
    --cc=zhonghui.fu@linux.intel.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).