diff options
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/core/core.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index e55cde6d436d..59b452d5dc81 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -58,6 +58,9 @@ */ #define MMC_BKOPS_MAX_TIMEOUT (4 * 60 * 1000) /* max time to wait in ms */ +/* The max erase timeout, used when host->max_busy_timeout isn't specified */ +#define MMC_ERASE_TIMEOUT_MS (60 * 1000) /* 60 s */ + static const unsigned freqs[] = { 400000, 300000, 200000, 100000 }; /* @@ -2352,6 +2355,8 @@ static unsigned int mmc_do_calc_max_discard(struct mmc_card *card, struct mmc_host *host = card->host; unsigned int max_discard, x, y, qty = 0, max_qty, min_qty, timeout; unsigned int last_timeout = 0; + unsigned int max_busy_timeout = host->max_busy_timeout ? + host->max_busy_timeout : MMC_ERASE_TIMEOUT_MS; if (card->erase_shift) { max_qty = UINT_MAX >> card->erase_shift; @@ -2374,15 +2379,15 @@ static unsigned int mmc_do_calc_max_discard(struct mmc_card *card, * matter what size of 'host->max_busy_timeout', but if the * 'host->max_busy_timeout' is large enough for more discard sectors, * then we can continue to increase the max discard sectors until we - * get a balance value. + * get a balance value. In cases when the 'host->max_busy_timeout' + * isn't specified, use the default max erase timeout. */ do { y = 0; for (x = 1; x && x <= max_qty && max_qty - x >= qty; x <<= 1) { timeout = mmc_erase_timeout(card, arg, qty + x); - if (qty + x > min_qty && - timeout > host->max_busy_timeout) + if (qty + x > min_qty && timeout > max_busy_timeout) break; if (timeout < last_timeout) @@ -2427,9 +2432,6 @@ unsigned int mmc_calc_max_discard(struct mmc_card *card) struct mmc_host *host = card->host; unsigned int max_discard, max_trim; - if (!host->max_busy_timeout) - return UINT_MAX; - /* * Without erase_group_def set, MMC erase timeout depends on clock * frequence which can change. In that case, the best choice is @@ -2447,7 +2449,8 @@ unsigned int mmc_calc_max_discard(struct mmc_card *card) max_discard = 0; } pr_debug("%s: calculated max. discard sectors %u for timeout %u ms\n", - mmc_hostname(host), max_discard, host->max_busy_timeout); + mmc_hostname(host), max_discard, host->max_busy_timeout ? + host->max_busy_timeout : MMC_ERASE_TIMEOUT_MS); return max_discard; } EXPORT_SYMBOL(mmc_calc_max_discard); |