[PATCH v2 6/8] pwm: mediatek: Fix various issues in the .apply() callback

AngeloGioacchino Del Regno angelogioacchino.delregno at collabora.com
Mon Aug 4 01:49:36 PDT 2025


Il 25/07/25 17:45, Uwe Kleine-König ha scritto:
> duty_cycle and period were silently cast from u64 to int losing
> relevant bits. Dividing by the result of a division (resolution) looses
> precision. clkdiv was determined using a loop while it can be done
> without one. Also too low period values were not catched.
> 
> Improve all these issues. Handling period and duty_cycle being u64 now
> requires a bit more care to prevent overflows, so mul_u64_u64_div_u64()
> is used.
> 
> The changes implemented in this change also align the chosen hardware
> settings to match the usual PWM rules (i.e. round down instead round
> nearest) and so .apply() also matches .get_state() silencing several
> warnings with PWM_DEBUG=y. While this probably doesn't result in
> problems, this aspect makes this change---though it might be considered
> a fix---unsuitable for backporting.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig at baylibre.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno at collabora.com>





More information about the Linux-mediatek mailing list