Commit d252e9b1 authored by Wenchao Chen's avatar Wenchao Chen Committed by Ulf Hansson

mmc: sdhci-sprd: Fix the limitation of div

Because the bit field size of the divider coefficient register is 1023, it is
limited before returning the value.
Signed-off-by: default avatarWenchao Chen <wenchao.chen@unisoc.com>
Link: https://lore.kernel.org/r/20220914063702.20283-1-wenchao.chen666@gmail.comSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 627a78b2
......@@ -205,14 +205,14 @@ static inline u32 sdhci_sprd_calc_div(u32 base_clk, u32 clk)
if ((base_clk / div) > (clk * 2))
div++;
if (div > SDHCI_SPRD_CLK_MAX_DIV)
div = SDHCI_SPRD_CLK_MAX_DIV;
if (div % 2)
div = (div + 1) / 2;
else
div = div / 2;
if (div > SDHCI_SPRD_CLK_MAX_DIV)
div = SDHCI_SPRD_CLK_MAX_DIV;
return div;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment