diff options
author | Wenchao Chen <wenchao.chen@unisoc.com> | 2022-09-14 09:37:02 +0300 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2022-09-20 12:34:06 +0300 |
commit | d252e9b1073a12fee68fc9a626a83035cd03cf70 (patch) | |
tree | fb04efd75975b79353b86e3b88465df805ff56a8 /drivers/mmc | |
parent | 627a78b2dec669c4efa216d827341c948eb3f42d (diff) | |
download | linux-d252e9b1073a12fee68fc9a626a83035cd03cf70.tar.xz |
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: Wenchao Chen <wenchao.chen@unisoc.com>
Link: https://lore.kernel.org/r/20220914063702.20283-1-wenchao.chen666@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/sdhci-sprd.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c index f33e9349e4e6..46c55ab4884c 100644 --- a/drivers/mmc/host/sdhci-sprd.c +++ b/drivers/mmc/host/sdhci-sprd.c @@ -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; } |