diff options
author | Christophe Kerello <[email protected]> | 2023-06-13 15:41:46 +0200 |
---|---|---|
committer | Ulf Hansson <[email protected]> | 2023-06-13 16:19:50 +0200 |
commit | 47b3ad6b7842f49d374a01b054a4b1461a621bdc (patch) | |
tree | 9a0f4b713027b531340a2703d50bbbcdfa8ed097 | |
parent | e6f9e590b72e12bbb86b1b8be7e1981f357392ad (diff) |
mmc: mmci: stm32: fix max busy timeout calculation
The way that the timeout is currently calculated could lead to a u64
timeout value in mmci_start_command(). This value is then cast in a u32
register that leads to mmc erase failed issue with some SD cards.
Fixes: 8266c585f489 ("mmc: mmci: add hardware busy timeout feature")
Signed-off-by: Yann Gautier <[email protected]>
Signed-off-by: Christophe Kerello <[email protected]>
Cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Ulf Hansson <[email protected]>
-rw-r--r-- | drivers/mmc/host/mmci.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index f2b2e8b0574e..696cbef3ff7d 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1735,7 +1735,8 @@ static void mmci_set_max_busy_timeout(struct mmc_host *mmc) return; if (host->variant->busy_timeout && mmc->actual_clock) - max_busy_timeout = ~0UL / (mmc->actual_clock / MSEC_PER_SEC); + max_busy_timeout = U32_MAX / DIV_ROUND_UP(mmc->actual_clock, + MSEC_PER_SEC); mmc->max_busy_timeout = max_busy_timeout; } |