diff mbox series

[2/2] pwm: Check actual period and duty_cycle for ignored polarity test

Message ID bc511c0250ea2f6390e4209ab1ea9c08a3c18612.1751994988.git.u.kleine-koenig@baylibre.com
State Accepted
Headers show
Series pwm: Improvements for PWM_DEBUG checks | expand

Commit Message

Uwe Kleine-König (The Capable Hub) July 8, 2025, 5:18 p.m. UTC
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>
---
 drivers/pwm/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index d9d9badf7a8e..cc043a49c7d9 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -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 &&