Skip to content

Commit 47b3ad6

Browse files
Christophe Kerellostorulf
authored andcommitted
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: 8266c58 ("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]>
1 parent e6f9e59 commit 47b3ad6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/mmc/host/mmci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,8 @@ static void mmci_set_max_busy_timeout(struct mmc_host *mmc)
17351735
return;
17361736

17371737
if (host->variant->busy_timeout && mmc->actual_clock)
1738-
max_busy_timeout = ~0UL / (mmc->actual_clock / MSEC_PER_SEC);
1738+
max_busy_timeout = U32_MAX / DIV_ROUND_UP(mmc->actual_clock,
1739+
MSEC_PER_SEC);
17391740

17401741
mmc->max_busy_timeout = max_busy_timeout;
17411742
}

0 commit comments

Comments
 (0)