From 76daf0a743099aef81b098e09031927daf2c7704 Mon Sep 17 00:00:00 2001 From: Haibo Chen Date: Sat, 24 Feb 2018 17:32:01 +0800 Subject: [PATCH] MLK-17621-1 mmc: remove the feature of setting slot index via devicetree alias This patch remove the commit 3d8a438c53f3 ("mmc: Allow setting slot index via devicetree alias"),which wrongly use the function ida_simple_get(), causing this function return unexpected result when the reserved alias index value is not 0. In the meantime, the 'devidx' in the mmc block layer code just impact the minor device number, no need to align the minor device number and the slot index. Here remove upper mentioned patch, and will reform the feature of setting slot index via devicetree alias in the next few patches. This patch also remove one other related patch: commit 82f323ade111 ("MLK-12617 mmc: Fix compile error when CONFIG_MMC=m"). Reported-by: Leonard Crestez Acked-by: Dong Aisheng Signed-off-by: Haibo Chen --- drivers/mmc/core/block.c | 14 +++----------- drivers/mmc/core/core.c | 40 ---------------------------------------- drivers/mmc/core/host.c | 25 ++----------------------- drivers/of/base.c | 1 - include/linux/mmc/core.h | 3 --- 5 files changed, 5 insertions(+), 78 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index db5c8d61e867..f42a2b639ba0 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -2108,17 +2108,9 @@ again: if (!ida_pre_get(&mmc_blk_ida, GFP_KERNEL)) return ERR_PTR(-ENOMEM); - devidx = mmc_get_reserved_index(card->host); - if (devidx >= 0) - devidx = ida_simple_get(&mmc_blk_ida, devidx, devidx, - GFP_NOWAIT); - ret = 0; - if (devidx < 0) { - spin_lock(&mmc_blk_lock); - ret = ida_get_new_above(&mmc_blk_ida, - mmc_first_nonreserved_index(), &devidx); - spin_unlock(&mmc_blk_lock); - } + spin_lock(&mmc_blk_lock); + ret = ida_get_new(&mmc_blk_ida, &devidx); + spin_unlock(&mmc_blk_lock); if (ret == -EAGAIN) goto again; diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 2c49f2c7ecff..316b633f2fa6 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -3166,49 +3165,10 @@ void mmc_init_context_info(struct mmc_host *host) init_waitqueue_head(&host->context_info.wait); } -static int __mmc_max_reserved_idx = -1; - -/** - * mmc_first_nonreserved_index() - get the first index that is not reserved - */ -int mmc_first_nonreserved_index(void) -{ - return __mmc_max_reserved_idx + 1; -} -EXPORT_SYMBOL(mmc_first_nonreserved_index); - -/** - * mmc_get_reserved_index() - get the index reserved for this host - * - * Return: The index reserved for this host or negative error value if - * no index is reserved for this host - */ -int mmc_get_reserved_index(struct mmc_host *host) -{ - return of_alias_get_id(host->parent->of_node, "mmc"); -} -EXPORT_SYMBOL(mmc_get_reserved_index); - -static void mmc_of_reserve_idx(void) -{ - int max; - - max = of_alias_max_index("mmc"); - if (max < 0) - return; - - __mmc_max_reserved_idx = max; - - pr_debug("MMC: reserving %d slots for of aliases\n", - __mmc_max_reserved_idx + 1); -} - static int __init mmc_init(void) { int ret; - mmc_of_reserve_idx(); - ret = mmc_register_bus(); if (ret) return ret; diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 882844c17959..5aad8c3e376e 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -346,8 +346,6 @@ int mmc_of_parse(struct mmc_host *host) EXPORT_SYMBOL(mmc_of_parse); -int mmc_max_reserved_idx(void); - /** * mmc_alloc_host - initialise the per-host structure. * @extra: sizeof private data structure @@ -359,7 +357,6 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) { int err; struct mmc_host *host; - int alias_id, min_idx, max_idx; host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); if (!host) @@ -367,7 +364,6 @@ 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; again: if (!ida_pre_get(&mmc_host_ida, GFP_KERNEL)) { @@ -375,26 +371,8 @@ again: return NULL; } - alias_id = mmc_get_reserved_index(host); - - if (alias_id >= 0) { - min_idx = alias_id; - max_idx = alias_id + 1; - } else { - min_idx = mmc_first_nonreserved_index(); - max_idx = 0; - } - spin_lock(&mmc_host_lock); - - err = ida_get_new_above(&mmc_host_ida, min_idx, &host->index); - if (!err) { - if (host->index > max_idx) { - ida_remove(&mmc_host_ida, host->index); - err = -ENOSPC; - } - } - + err = ida_get_new(&mmc_host_ida, &host->index); spin_unlock(&mmc_host_lock); if (err == -EAGAIN) { @@ -406,6 +384,7 @@ again: 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); diff --git a/drivers/of/base.c b/drivers/of/base.c index 4d6cbfe6a111..5fbd49290175 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2077,7 +2077,6 @@ int of_alias_max_index(const char *stem) return max; } -EXPORT_SYMBOL_GPL(of_alias_max_index); /** * of_alias_scan - Scan all properties of the 'aliases' node diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h index 80f36b704531..1974fcfd4284 100644 --- a/include/linux/mmc/core.h +++ b/include/linux/mmc/core.h @@ -182,7 +182,4 @@ int mmc_cqe_recovery(struct mmc_host *host); int mmc_hw_reset(struct mmc_host *host); void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card); -int mmc_first_nonreserved_index(void); -int mmc_get_reserved_index(struct mmc_host *host); - #endif /* LINUX_MMC_CORE_H */ -- 2.17.1