Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1391309
| From | Douglas Anderson <dianders@chromium.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 2/4] mmc: read mmc alias from device tree |
| Date | 2016-04-29 19:40 +0200 |
| Message-ID | <rtkyv-1rQ-31@gated-at.bofh.it> (permalink) |
| References | <rtkyu-1rQ-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Douglas Anderson <dianders@chromium.org> - 2016-04-29 19:40 +0200
[PATCH v2 1/4] Documentation: mmc: Document mmc aliases Douglas Anderson <dianders@chromium.org> - 2016-04-29 19:40 +0200
[PATCH v2 2/4] mmc: read mmc alias from device tree Douglas Anderson <dianders@chromium.org> - 2016-04-29 19:40 +0200
[PATCH v2 4/4] ARM: dts: rockchip: Add mmc aliases for rk3288 platform Douglas Anderson <dianders@chromium.org> - 2016-04-29 19:40 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Rob Herring <robh+dt@kernel.org> - 2016-04-29 20:20 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Doug Anderson <dianders@chromium.org> - 2016-04-29 21:40 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-04-29 22:00 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Doug Anderson <dianders@chromium.org> - 2016-04-29 22:10 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-04-29 20:20 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Doug Anderson <dianders@chromium.org> - 2016-04-29 21:50 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-04-29 22:00 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Doug Anderson <dianders@chromium.org> - 2016-04-29 22:10 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Doug Anderson <dianders@chromium.org> - 2016-04-29 23:20 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Doug Anderson <dianders@chromium.org> - 2016-04-29 23:40 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-04-30 00:00 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Doug Anderson <dianders@chromium.org> - 2016-04-30 00:00 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-04-30 00:20 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Doug Anderson <dianders@chromium.org> - 2016-04-30 00:30 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-04-30 00:50 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Doug Anderson <dianders@chromium.org> - 2016-04-30 01:10 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Peter Hurley <peter@hurleysoftware.com> - 2016-04-30 02:00 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Peter Hurley <peter@hurleysoftware.com> - 2016-04-30 02:40 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Doug Anderson <dianders@chromium.org> - 2016-04-30 04:30 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-04-30 10:40 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Rob Herring <robh+dt@kernel.org> - 2016-04-30 15:30 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Javier Martinez Canillas <javier@dowhile0.org> - 2016-04-30 00:50 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-04-30 12:50 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Trent Piepho <tpiepho@kymetacorp.com> - 2016-05-03 21:30 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-04-29 23:40 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-04-29 23:20 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Pavel Machek <pavel@ucw.cz> - 2016-05-04 09:20 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Rob Herring <robh+dt@kernel.org> - 2016-05-04 14:30 +0200
Re: [PATCH v2 0/4] Patches to allow consistent mmc / mmcblk numbering w/ device tree Pavel Machek <pavel@ucw.cz> - 2016-05-04 14:50 +0200
csiph-web