mmc: mmci: stm32: fix max busy timeout calculation

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 <christophe.kerello@foss.st.com>
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/311057
Tested-by: Eric FOURMONT <eric.fourmont-ext@st.com>
Reviewed-by: Eric FOURMONT <eric.fourmont-ext@st.com>
Domain-Review: Eric FOURMONT <eric.fourmont-ext@st.com>
This commit is contained in:
Christophe Kerello
2023-06-06 14:50:02 +02:00
committed by Eric Fourmont
parent e689673817
commit d33b43a4dc

View File

@ -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;
}