mmc: block: Support the fixed index for mmcblk with aliases nodes 89/199889/2
authorJaehoon Chung <jh80.chung@samsung.com>
Tue, 29 Mar 2016 10:43:34 +0000 (19:43 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 19 Feb 2019 03:59:09 +0000 (03:59 +0000)
Now, index of mmcblk is allocated in accordance with probing time.
If want to use the mmcblk1 for some device, it can use alias.

aliases {
mmc0 = &mmc0; /* mmcblk0 for eMMC */
mmc1 = &mmc2; /* mmcblk1 for SD */
mmc2 = &mmc1; /* mmcblk2 for SDIO*/
};

If there are no corresponding values, it might be allocated with
existing scheme.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
[sw0312.kim: port to v4.14
 - apply to host index instead of name_idx because host index is used in this version
]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I44673d62e546ea0aeedd9cac314dbfd31fdcce66

Documentation/devicetree/bindings/mmc/mmc.txt
drivers/mmc/core/host.c

index b32ade6..a6f51dd 100644 (file)
@@ -76,6 +76,11 @@ Optional SDIO properties:
 - wakeup-source: Enables wake up of host system on SDIO IRQ assertion
                 (Legacy property supported: "enable-sdio-wakeup")
 
+Aliases (Optional):
+- If you want to use the fixed index for block device like mmcblkX, should be
+represented in the aliases node using following format "mmc(X)".
+(X is an unique number for the alias.)
+
 MMC power
 ---------
 
@@ -162,3 +167,10 @@ mmc3: mmc@01c12000 {
                interrupt-names = "host-wake";
        };
 };
+
+Example with aliases nodes:
+
+aliases {
+       mmc0 = &mmc0;   /* Fixed to mmcblk0 for &mmc0 */
+       mmc1 = &mmc2;   /* Fixed to mmcblk1 for &mmc2 */
+};
index ad88deb..390e676 100644 (file)
@@ -349,6 +349,7 @@ EXPORT_SYMBOL(mmc_of_parse);
 struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
 {
        int err;
+       int idx = 0;
        struct mmc_host *host;
 
        host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL);
@@ -358,7 +359,10 @@ 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);
+       if (dev->of_node)
+               idx = of_alias_get_id(dev->of_node, "mmc");
+
+       err = ida_simple_get(&mmc_host_ida, (idx < 0) ? 0 : idx, 0, GFP_KERNEL);
        if (err < 0) {
                kfree(host);
                return NULL;