All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: rcar-du: Simplify division/shift logic
@ 2022-02-21 16:26 ` Geert Uytterhoeven
  0 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2022-02-21 16:26 UTC (permalink / raw)
  To: Laurent Pinchart, Kieran Bingham, David Airlie, Daniel Vetter
  Cc: dri-devel, linux-renesas-soc, Geert Uytterhoeven

"a / (1 << b)" == "a >> b".

No change in generated code.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/gpu/drm/rcar-du/rcar_lvds.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c
index 72a272cfc11ee129..30afc1d3482a9670 100644
--- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
+++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
@@ -229,7 +229,7 @@ static void rcar_lvds_d3_e3_pll_calc(struct rcar_lvds *lvds, struct clk *clk,
 				 * the PLL, followed by a an optional fixed /7
 				 * divider.
 				 */
-				fout = fvco / (1 << e) / div7;
+				fout = (fvco >> e) / div7;
 				div = max(1UL, DIV_ROUND_CLOSEST(fout, target));
 				diff = abs(fout / div - target);
 
@@ -249,7 +249,7 @@ static void rcar_lvds_d3_e3_pll_calc(struct rcar_lvds *lvds, struct clk *clk,
 	}
 
 done:
-	output = fin * pll->pll_n / pll->pll_m / (1 << pll->pll_e)
+	output = (fin * pll->pll_n / pll->pll_m >> pll->pll_e)
 	       / div7 / pll->div;
 	error = (long)(output - target) * 10000 / (long)target;
 
-- 
2.25.1


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

* [PATCH] drm: rcar-du: Simplify division/shift logic
@ 2022-02-21 16:26 ` Geert Uytterhoeven
  0 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2022-02-21 16:26 UTC (permalink / raw)
  To: Laurent Pinchart, Kieran Bingham, David Airlie, Daniel Vetter
  Cc: linux-renesas-soc, Geert Uytterhoeven, dri-devel

"a / (1 << b)" == "a >> b".

No change in generated code.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/gpu/drm/rcar-du/rcar_lvds.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c
index 72a272cfc11ee129..30afc1d3482a9670 100644
--- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
+++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
@@ -229,7 +229,7 @@ static void rcar_lvds_d3_e3_pll_calc(struct rcar_lvds *lvds, struct clk *clk,
 				 * the PLL, followed by a an optional fixed /7
 				 * divider.
 				 */
-				fout = fvco / (1 << e) / div7;
+				fout = (fvco >> e) / div7;
 				div = max(1UL, DIV_ROUND_CLOSEST(fout, target));
 				diff = abs(fout / div - target);
 
@@ -249,7 +249,7 @@ static void rcar_lvds_d3_e3_pll_calc(struct rcar_lvds *lvds, struct clk *clk,
 	}
 
 done:
-	output = fin * pll->pll_n / pll->pll_m / (1 << pll->pll_e)
+	output = (fin * pll->pll_n / pll->pll_m >> pll->pll_e)
 	       / div7 / pll->div;
 	error = (long)(output - target) * 10000 / (long)target;
 
-- 
2.25.1


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

* Re: [PATCH] drm: rcar-du: Simplify division/shift logic
  2022-02-21 16:26 ` Geert Uytterhoeven
@ 2022-02-21 17:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2022-02-21 17:23 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Kieran Bingham, David Airlie, Daniel Vetter, dri-devel,
	linux-renesas-soc

Hi Geert,

Thank you for the patch.

On Mon, Feb 21, 2022 at 05:26:15PM +0100, Geert Uytterhoeven wrote:
> "a / (1 << b)" == "a >> b".
> 
> No change in generated code.

If there's no change in generated code, isn't the current code more
readable ? :-)

> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
>  drivers/gpu/drm/rcar-du/rcar_lvds.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> index 72a272cfc11ee129..30afc1d3482a9670 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> @@ -229,7 +229,7 @@ static void rcar_lvds_d3_e3_pll_calc(struct rcar_lvds *lvds, struct clk *clk,
>  				 * the PLL, followed by a an optional fixed /7
>  				 * divider.
>  				 */
> -				fout = fvco / (1 << e) / div7;
> +				fout = (fvco >> e) / div7;
>  				div = max(1UL, DIV_ROUND_CLOSEST(fout, target));
>  				diff = abs(fout / div - target);
>  
> @@ -249,7 +249,7 @@ static void rcar_lvds_d3_e3_pll_calc(struct rcar_lvds *lvds, struct clk *clk,
>  	}
>  
>  done:
> -	output = fin * pll->pll_n / pll->pll_m / (1 << pll->pll_e)
> +	output = (fin * pll->pll_n / pll->pll_m >> pll->pll_e)
>  	       / div7 / pll->div;
>  	error = (long)(output - target) * 10000 / (long)target;
>  

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH] drm: rcar-du: Simplify division/shift logic
@ 2022-02-21 17:23   ` Laurent Pinchart
  0 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2022-02-21 17:23 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: David Airlie, linux-renesas-soc, Kieran Bingham, dri-devel

Hi Geert,

Thank you for the patch.

On Mon, Feb 21, 2022 at 05:26:15PM +0100, Geert Uytterhoeven wrote:
> "a / (1 << b)" == "a >> b".
> 
> No change in generated code.

If there's no change in generated code, isn't the current code more
readable ? :-)

> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
>  drivers/gpu/drm/rcar-du/rcar_lvds.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> index 72a272cfc11ee129..30afc1d3482a9670 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> @@ -229,7 +229,7 @@ static void rcar_lvds_d3_e3_pll_calc(struct rcar_lvds *lvds, struct clk *clk,
>  				 * the PLL, followed by a an optional fixed /7
>  				 * divider.
>  				 */
> -				fout = fvco / (1 << e) / div7;
> +				fout = (fvco >> e) / div7;
>  				div = max(1UL, DIV_ROUND_CLOSEST(fout, target));
>  				diff = abs(fout / div - target);
>  
> @@ -249,7 +249,7 @@ static void rcar_lvds_d3_e3_pll_calc(struct rcar_lvds *lvds, struct clk *clk,
>  	}
>  
>  done:
> -	output = fin * pll->pll_n / pll->pll_m / (1 << pll->pll_e)
> +	output = (fin * pll->pll_n / pll->pll_m >> pll->pll_e)
>  	       / div7 / pll->div;
>  	error = (long)(output - target) * 10000 / (long)target;
>  

-- 
Regards,

Laurent Pinchart

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

end of thread, other threads:[~2022-02-21 17:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-21 16:26 [PATCH] drm: rcar-du: Simplify division/shift logic Geert Uytterhoeven
2022-02-21 16:26 ` Geert Uytterhoeven
2022-02-21 17:23 ` Laurent Pinchart
2022-02-21 17:23   ` Laurent Pinchart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.