Re: [PATCH] pwm: tegra: Fix 32 bit build

From: Uwe Kleine-König
Date: Thu Nov 10 2022 - 09:53:37 EST


Hello,

On Thu, Nov 10, 2022 at 11:45:48AM +0000, Steven Price wrote:
> The value of NSEC_PER_SEC << PWM_DUTY_WIDTH doesn't fix within a 32 bit
> integer causing a build warning/error (and the value truncated):
>
> drivers/pwm/pwm-tegra.c: In function ‘tegra_pwm_config’:
> drivers/pwm/pwm-tegra.c:148:53: error: result of ‘1000000000 << 8’ requires 39 bits to represent, but ‘long int’ only has 32 bits [-Werror=shift-overflow=]
> 148 | required_clk_rate = DIV_ROUND_UP_ULL(NSEC_PER_SEC << PWM_DUTY_WIDTH,
> | ^~
>
> Explicitly cast to a u64 to ensure the correct result.

Hmm, ideally this should have popped up earlier :-\

Anyhow:

Reviewed-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>

Thanks
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |

Attachment: signature.asc
Description: PGP signature