summaryrefslogtreecommitdiff
path: root/drivers/mmc/core/host.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/core/host.c')
-rw-r--r--drivers/mmc/core/host.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 32801639e0be..ce13df598385 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -442,6 +442,7 @@ EXPORT_SYMBOL(mmc_of_parse_voltage);
struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
{
int err;
+ int alias_id;
struct mmc_host *host;
host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL);
@@ -450,8 +451,16 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
/* scanning will be enabled when we're ready */
host->rescan_disable = 1;
+ host->parent = dev;
- err = ida_simple_get(&mmc_host_ida, 0, 0, GFP_KERNEL);
+ alias_id = mmc_get_reserved_index(host);
+ if (alias_id >= 0)
+ err = ida_simple_get(&mmc_host_ida, alias_id,
+ alias_id + 1, GFP_KERNEL);
+ else
+ err = ida_simple_get(&mmc_host_ida,
+ mmc_first_nonreserved_index(),
+ 0, GFP_KERNEL);
if (err < 0) {
kfree(host);
return NULL;
@@ -461,7 +470,6 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
dev_set_name(&host->class_dev, "mmc%d", host->index);
- host->parent = dev;
host->class_dev.parent = dev;
host->class_dev.class = &mmc_host_class;
device_initialize(&host->class_dev);