mmc: Allow setting slot index via devicetree alias
authorSascha Hauer <s.hauer@pengutronix.de>
Fri, 20 Jun 2014 07:08:16 +0000 (15:08 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:48:47 +0000 (14:48 -0500)
commite1d3e89f26f19cb1d309ab16264dffdd57280906
tree582f6ee72ac9f61cf95dcb864e2bfc42564d9c28
parentda248c0308078f63386c8606e64c9eb96c124416
mmc: Allow setting slot index via devicetree alias

As with gpio, uart and others, allow specifying the name_idx via the
aliases-node in the devicetree.

On embedded devices, there is often a combination of removable (e.g.
SD card) and non-removable mmc devices (e.g. eMMC).
Therefore the name_idx might change depending on
- host of removable device
- removable card present or not

This makes it difficult to hard code the root device, if it is on the
non-removable device. E.g. if SD card is present eMMC will be mmcblk1,
if SD card is not present at boot, eMMC will be mmcblk0.

If the aliases-node is not found, the driver will act as before.

The original patch is from here:
https://www.mail-archive.com/linux-mmc@vger.kernel.org/msg26472.html

The patch requires additional alias_id fix or it won't work.
Because according to function definition the max_idx parameter of idx_alloc
is exclusive, so need add 1 or it will be unable to find the proper idx
within an invalid range.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Dong Aisheng <b29396@freescale.com>
(cherry picked from commit 35928d6c6a76a24a16edfa636f4c08293614a1e0)
drivers/mmc/card/block.c
drivers/mmc/core/core.c
drivers/mmc/core/host.c
include/linux/mmc/core.h