2022-09-14 06:52:55

by Wenchao Chen

[permalink] [raw]
Subject: [PATCH] mmc: sdhci-sprd: Fix the limitation of div

From: Wenchao Chen <[email protected]>

Because the bit field size of the divider coefficient register is 1023, it is
limited before returning the value.

Signed-off-by: Wenchao Chen <[email protected]>
---
drivers/mmc/host/sdhci-sprd.c | 6 +++---
1 file 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;
}

--
2.17.1


2022-09-21 13:44:02

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH] mmc: sdhci-sprd: Fix the limitation of div

On Wed, 14 Sept 2022 at 08:37, Wenchao Chen <[email protected]> wrote:
>
> From: Wenchao Chen <[email protected]>
>
> Because the bit field size of the divider coefficient register is 1023, it is
> limited before returning the value.
>
> Signed-off-by: Wenchao Chen <[email protected]>

Applied for next, thanks!

Kind regards
Uffe


> ---
> drivers/mmc/host/sdhci-sprd.c | 6 +++---
> 1 file 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;
> }
>
> --
> 2.17.1
>