Skip to content

Commit

Permalink
mmc: mmci: stm32: fix max busy timeout calculation
Browse files Browse the repository at this point in the history
The way that the timeout is currently calculated could lead
to a u64 timeout value. this value is then cast in a u32 register
that leads to mmc erase failed issue with some SD cards.

Change-Id: Ibe2682ba42e878c30b61471672800f5fc04ce87c
Signed-off-by: Christophe Kerello <[email protected]>
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/311057
Tested-by: Eric FOURMONT <[email protected]>
Reviewed-by: Eric FOURMONT <[email protected]>
Domain-Review: Eric FOURMONT <[email protected]>
  • Loading branch information
Christophe Kerello authored and fourmone committed Jun 16, 2023
1 parent e689673 commit d33b43a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/mmc/host/mmci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,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;
}
Expand Down

0 comments on commit d33b43a

Please sign in to comment.