Re: [RESEND v6 1/2] pwm: Convert drivers to use 64-bit period and duty cycle

From: Uwe Kleine-König
Date: Fri Mar 06 2020 - 02:44:47 EST


Hello,

On Mon, Mar 02, 2020 at 11:34:22AM -0800, Guru Das Srinagesh wrote:
> Because period and duty cycle are defined in the PWM framework structs
> as ints with units of nanoseconds, the maximum time duration that can be
> set is limited to ~2.147 seconds. Redefining them as u64 values will
> enable larger time durations to be set.
>
> As a first step, prepare drivers to handle the switch to u64 period and
> duty_cycle by making the relevant fixes to those drivers that use the
> period and duty_cycle pwm struct members in division operations, viz.
> replacing the division operations with 64-bit division macros as
> appropriate. The actual switch to u64 period and duty_cycle follows as a
> separate patch.
>
> Where the dividend is 64-bit but the divisor is 32-bit, use *_ULL
> macros:
> - DIV_ROUND_UP_ULL
> - DIV_ROUND_CLOSEST_ULL
> - div_u64
>
> Where the divisor is 64-bit (dividend may be 32-bit or 64-bit), use
> DIV64_* macros:
> - DIV64_U64_ROUND_CLOSEST
> - div64_u64
>
> The kbuild test robot helped to improve this patch by catching a couple
> of code sites that had to be adapted.
>
> Signed-off-by: Guru Das Srinagesh <gurus@xxxxxxxxxxxxxx>
> ---
> drivers/clk/clk-pwm.c | 2 +-
> drivers/gpu/drm/i915/display/intel_panel.c | 2 +-
> drivers/hwmon/pwm-fan.c | 2 +-
> drivers/media/rc/ir-rx51.c | 3 ++-
> drivers/pwm/pwm-clps711x.c | 2 +-
> drivers/pwm/pwm-imx-tpm.c | 2 +-
> drivers/pwm/pwm-imx27.c | 5 ++---
> drivers/pwm/pwm-sifive.c | 2 +-
> drivers/pwm/pwm-sti.c | 5 +++--
> drivers/pwm/pwm-stm32-lp.c | 2 +-
> drivers/pwm/pwm-sun4i.c | 2 +-
> drivers/video/backlight/pwm_bl.c | 3 ++-

I guess we need acks from the affected maintainers. While I think the
changes are fine I think you won't evade having to expand the audience
of your patch and (depending on feedback) maybe split this patch up
further.

Best regards
Uwe

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