linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci-sprd: Fix the limitation of div
@ 2022-09-14  6:37 Wenchao Chen
  2022-09-21 12:48 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Wenchao Chen @ 2022-09-14  6:37 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson, orsonzhai, baolin.wang, zhang.lyra
  Cc: linux-mmc, linux-kernel, megoo.tang, lzx.stg

From: Wenchao Chen <wenchao.chen@unisoc.com>

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>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mmc: sdhci-sprd: Fix the limitation of div
  2022-09-14  6:37 [PATCH] mmc: sdhci-sprd: Fix the limitation of div Wenchao Chen
@ 2022-09-21 12:48 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2022-09-21 12:48 UTC (permalink / raw)
  To: Wenchao Chen
  Cc: adrian.hunter, orsonzhai, baolin.wang, zhang.lyra, linux-mmc,
	linux-kernel, megoo.tang, lzx.stg

On Wed, 14 Sept 2022 at 08:37, Wenchao Chen <wenchao.chen666@gmail.com> wrote:
>
> From: Wenchao Chen <wenchao.chen@unisoc.com>
>
> 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>

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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-21 12:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14  6:37 [PATCH] mmc: sdhci-sprd: Fix the limitation of div Wenchao Chen
2022-09-21 12:48 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).