As with gpio, uart and others, allow specifying the name_idx via the aliases-node in the devicetree. Since commit 9aaf3437aa72 mmcblkX nodes are fixed against mmcX host. This extension allows embedded devices to keep the same rootfs device index between board versions using different MMC controllers. Rewritten for current kernel version from original patch by Sascha Hauer. > https://www.mail-archive.com/linux-mmc@xxxxxxxxxxxxxxx/msg26472.html Signed-off-by: Michał Mirosław <mirq-linux@xxxxxxxxxxxx> --- against v5.1.5 --- drivers/mmc/core/host.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 3a4402a79904..0ffab498b66f 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -411,7 +411,17 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) /* scanning will be enabled when we're ready */ host->rescan_disable = 1; - err = ida_simple_get(&mmc_host_ida, 0, 0, GFP_KERNEL); + err = of_alias_get_id(dev->of_node, "mmc"); + if (err >= 0) + err = ida_alloc_range(&mmc_host_ida, err, err, GFP_KERNEL); + if (err < 0) { + err = of_alias_get_highest_id("mmc"); + if (err < 0) + err = 0; + else + ++err; + err = ida_alloc_min(&mmc_host_ida, err, GFP_KERNEL); + } if (err < 0) { kfree(host); return NULL; -- 2.20.1