* [PATCH v2 2/2]remove the erase calculation part from core.c
@ 2010-12-08 11:45 Chuanxiao Dong
0 siblings, 0 replies; only message in thread
From: Chuanxiao Dong @ 2010-12-08 11:45 UTC (permalink / raw)
To: linux-mmc, adrian.hunter; +Cc: linux-kernel
remove the erase calculation part from core.c
change the mmc_set_erase_timeout rountine to directly get
the erase timeout value according to arg type and erase
groups count.
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
---
drivers/mmc/core/core.c | 120 ++++++++++++++--------------------------------
1 files changed, 37 insertions(+), 83 deletions(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 6286898..6d1b9e5 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1171,99 +1171,53 @@ void mmc_init_erase(struct mmc_card *card)
}
}
-static void mmc_set_mmc_erase_timeout(struct mmc_card *card,
- struct mmc_command *cmd,
- unsigned int arg, unsigned int qty)
+/*
+ * mmc_set_erase_timeout: set the cmd erase_timeout according
+ * to the argument type and erase groups count
+ */
+static void mmc_set_erase_timeout(struct mmc_card *card,
+ struct mmc_command *cmd, unsigned int arg,
+ unsigned int qty)
{
unsigned int erase_timeout;
- if (card->ext_csd.erase_group_def & 1) {
- /* High Capacity Erase Group Size uses HC timeouts */
- if (arg == MMC_TRIM_ARG)
- erase_timeout = card->ext_csd.trim_timeout;
- else
- erase_timeout = card->ext_csd.hc_erase_timeout;
+ if (mmc_card_sd(card)) {
+ erase_timeout = card->erase_timeout * qty;
+ if (card->ssr.erase_timeout)
+ /*
+ * Erase timeout specified in SSR,
+ * plus erase_offset
+ * */
+ erase_timeout += card->ssr.erase_offset;
+ /* Must not be less than 1 second */
+ if (erase_timeout < 1000)
+ erase_timeout = 1000;
} else {
- /* CSD Erase Group Size uses write timeout */
- unsigned int mult = (10 << card->csd.r2w_factor);
- unsigned int timeout_clks = card->csd.tacc_clks * mult;
- unsigned int timeout_us;
-
- /* Avoid overflow: e.g. tacc_ns=80000000 mult=1280 */
- if (card->csd.tacc_ns < 1000000)
- timeout_us = (card->csd.tacc_ns * mult) / 1000;
- else
- timeout_us = (card->csd.tacc_ns / 1000) * mult;
-
- /*
- * ios.clock is only a target. The real clock rate might be
- * less but not that much less, so fudge it by multiplying by 2.
- */
- timeout_clks <<= 1;
- timeout_us += (timeout_clks * 1000) /
- (card->host->ios.clock / 1000);
-
- erase_timeout = timeout_us / 1000;
-
+ if (arg & MMC_SECURE_ARGS) {
+ if (arg == MMC_SECURE_ERASE_ARG)
+ erase_timeout = qty *
+ card->sec_erase_timeout;
+ else
+ erase_timeout = qty *
+ card->sec_trim_timeout;
+ } else {
+ if (arg == MMC_TRIM_ARG)
+ erase_timeout = qty *
+ card->trim_timeout;
+ else
+ erase_timeout = qty *
+ card->erase_timeout;
+ }
/*
- * Theoretically, the calculation could underflow so round up
- * to 1ms in that case.
+ * Ensure at least a 1 second timeout for SPI as per
+ * 'mmc_set_data_timeout()'
*/
- if (!erase_timeout)
- erase_timeout = 1;
- }
-
- /* Multiplier for secure operations */
- if (arg & MMC_SECURE_ARGS) {
- if (arg == MMC_SECURE_ERASE_ARG)
- erase_timeout *= card->ext_csd.sec_erase_mult;
- else
- erase_timeout *= card->ext_csd.sec_trim_mult;
+ if (mmc_host_is_spi(card->host) && erase_timeout < 1000)
+ erase_timeout = 1000;
}
-
- erase_timeout *= qty;
-
- /*
- * Ensure at least a 1 second timeout for SPI as per
- * 'mmc_set_data_timeout()'
- */
- if (mmc_host_is_spi(card->host) && erase_timeout < 1000)
- erase_timeout = 1000;
-
cmd->erase_timeout = erase_timeout;
}
-static void mmc_set_sd_erase_timeout(struct mmc_card *card,
- struct mmc_command *cmd, unsigned int arg,
- unsigned int qty)
-{
- if (card->ssr.erase_timeout) {
- /* Erase timeout specified in SD Status Register (SSR) */
- cmd->erase_timeout = card->ssr.erase_timeout * qty +
- card->ssr.erase_offset;
- } else {
- /*
- * Erase timeout not specified in SD Status Register (SSR) so
- * use 250ms per write block.
- */
- cmd->erase_timeout = 250 * qty;
- }
-
- /* Must not be less than 1 second */
- if (cmd->erase_timeout < 1000)
- cmd->erase_timeout = 1000;
-}
-
-static void mmc_set_erase_timeout(struct mmc_card *card,
- struct mmc_command *cmd, unsigned int arg,
- unsigned int qty)
-{
- if (mmc_card_sd(card))
- mmc_set_sd_erase_timeout(card, cmd, arg, qty);
- else
- mmc_set_mmc_erase_timeout(card, cmd, arg, qty);
-}
-
static int mmc_do_erase(struct mmc_card *card, unsigned int from,
unsigned int to, unsigned int arg)
{
--
1.6.6.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2010-12-08 11:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-08 11:45 [PATCH v2 2/2]remove the erase calculation part from core.c Chuanxiao Dong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.