diff options
Diffstat (limited to 'drivers/mmc/core/core.c')
-rw-r--r-- | drivers/mmc/core/core.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 8f94c2539508..ca4e640eafb1 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -52,6 +52,8 @@ static const unsigned freqs[] = { 400000, 300000, 200000, 100000 }; +static int __mmc_max_reserved_idx = -1; + /* * Enabling software CRCs on the data blocks can be a significant (30%) * performance cost, and for other reasons may not always be desired. @@ -2395,10 +2397,46 @@ void mmc_stop_host(struct mmc_host *host) mmc_release_host(host); } +/* + * 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; |