diff mbox series

pwm: rcar: Simplify multiplication/shift logic

Message ID 4ddca410da1f52a8e2049e0f51f14196cc797200.1645460845.git.geert+renesas@glider.be
State Accepted
Headers show
Series pwm: rcar: Simplify multiplication/shift logic | expand

Commit Message

Geert Uytterhoeven Feb. 21, 2022, 4:28 p.m. UTC
- Remove the superfluous cast; the multiplication will yield a 64-bit
    result due to the "100ULL" anyway,
  - "a * (1 << b)" == "a << b".

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/pwm/pwm-rcar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Uwe Kleine-König Feb. 21, 2022, 6:22 p.m. UTC | #1
On Mon, Feb 21, 2022 at 05:28:16PM +0100, Geert Uytterhoeven wrote:
>   - Remove the superfluous cast; the multiplication will yield a 64-bit
>     result due to the "100ULL" anyway,
>   - "a * (1 << b)" == "a << b".
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Thanks
Uwe
Thierry Reding Feb. 24, 2022, 2:15 p.m. UTC | #2
On Mon, Feb 21, 2022 at 07:22:13PM +0100, Uwe Kleine-König wrote:
> On Mon, Feb 21, 2022 at 05:28:16PM +0100, Geert Uytterhoeven wrote:
> >   - Remove the superfluous cast; the multiplication will yield a 64-bit
> >     result due to the "100ULL" anyway,
> >   - "a * (1 << b)" == "a << b".
> > 
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Applied, thanks.

Thierry
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-rcar.c b/drivers/pwm/pwm-rcar.c
index b437192380e23520..55f46d09602b1907 100644
--- a/drivers/pwm/pwm-rcar.c
+++ b/drivers/pwm/pwm-rcar.c
@@ -110,7 +110,7 @@  static int rcar_pwm_set_counter(struct rcar_pwm_chip *rp, int div, int duty_ns,
 	unsigned long clk_rate = clk_get_rate(rp->clk);
 	u32 cyc, ph;
 
-	one_cycle = (unsigned long long)NSEC_PER_SEC * 100ULL * (1 << div);
+	one_cycle = NSEC_PER_SEC * 100ULL << div;
 	do_div(one_cycle, clk_rate);
 
 	tmp = period_ns * 100ULL;