]> www.infradead.org Git - users/hch/misc.git/commitdiff
pwm: Check actual period and duty_cycle for ignored polarity test
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>
Tue, 8 Jul 2025 17:18:01 +0000 (19:18 +0200)
committerUwe Kleine-König <ukleinek@kernel.org>
Mon, 15 Sep 2025 09:39:44 +0000 (11:39 +0200)
When a lowlevel driver configures the wrong period that might
(historically) be ok if the emitted signal has a 100% relative duty_cycle
as that just corresponds to rounding down the duty_cycle to 0 which is an
allowed thing to do for a lowlevel driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/bc511c0250ea2f6390e4209ab1ea9c08a3c18612.1751994988.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
drivers/pwm/core.c

index d5d2dfbe4adecfebed6eb9c01a828c3c78dfad84..2570ad6a7f59d018107c6b937f10d08696d32e60 100644 (file)
@@ -536,7 +536,7 @@ static void pwm_apply_debug(struct pwm_device *pwm,
        }
 
        if (s2.polarity != state->polarity &&
-           state->duty_cycle < state->period)
+           s2.duty_cycle < s2.period)
                dev_warn(pwmchip_parent(chip), ".apply ignored .polarity\n");
 
        if (last->polarity == state->polarity &&