Patch "pwm: Assume a disabled PWM to emit a constant inactive output" has been added to the 6.11-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    pwm: Assume a disabled PWM to emit a constant inactive output

to the 6.11-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pwm-assume-a-disabled-pwm-to-emit-a-constant-inactiv.patch
and it can be found in the queue-6.11 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 8e9fec593440a1927d42bd4a8d56da79f8fb54bd
Author: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx>
Date:   Tue Nov 5 16:35:22 2024 +0100

    pwm: Assume a disabled PWM to emit a constant inactive output
    
    [ Upstream commit b2eaa1170e45dc18eb09dcc9abafbe9a7502e960 ]
    
    Some PWM hardwares (e.g. MC33XS2410) cannot implement a zero duty cycle
    but can instead disable the hardware which also results in a constant
    inactive output.
    
    There are some checks (enabled with CONFIG_PWM_DEBUG) to help
    implementing a driver without violating the normal rounding rules. Make
    them less strict to let above described hardware pass without warning.
    
    Reported-by: Dimitri Fedrau <dima.fedrau@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20241103205215.GA509903@debian
    Fixes: 3ad1f3a33286 ("pwm: Implement some checks for lowlevel drivers")
    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx>
    Reviewed-by: Dimitri Fedrau <dima.fedrau@xxxxxxxxx>
    Tested-by: Dimitri Fedrau <dima.fedrau@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20241105153521.1001864-2-u.kleine-koenig@xxxxxxxxxxxx
    Signed-off-by: Uwe Kleine-König <ukleinek@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 8acbcf5b66739..53c3a76a185ed 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -75,7 +75,7 @@ static void pwm_apply_debug(struct pwm_device *pwm,
 	    state->duty_cycle < state->period)
 		dev_warn(pwmchip_parent(chip), ".apply ignored .polarity\n");
 
-	if (state->enabled &&
+	if (state->enabled && s2.enabled &&
 	    last->polarity == state->polarity &&
 	    last->period > s2.period &&
 	    last->period <= state->period)
@@ -83,7 +83,11 @@ static void pwm_apply_debug(struct pwm_device *pwm,
 			 ".apply didn't pick the best available period (requested: %llu, applied: %llu, possible: %llu)\n",
 			 state->period, s2.period, last->period);
 
-	if (state->enabled && state->period < s2.period)
+	/*
+	 * Rounding period up is fine only if duty_cycle is 0 then, because a
+	 * flat line doesn't have a characteristic period.
+	 */
+	if (state->enabled && s2.enabled && state->period < s2.period && s2.duty_cycle)
 		dev_warn(pwmchip_parent(chip),
 			 ".apply is supposed to round down period (requested: %llu, applied: %llu)\n",
 			 state->period, s2.period);
@@ -99,7 +103,7 @@ static void pwm_apply_debug(struct pwm_device *pwm,
 			 s2.duty_cycle, s2.period,
 			 last->duty_cycle, last->period);
 
-	if (state->enabled && state->duty_cycle < s2.duty_cycle)
+	if (state->enabled && s2.enabled && state->duty_cycle < s2.duty_cycle)
 		dev_warn(pwmchip_parent(chip),
 			 ".apply is supposed to round down duty_cycle (requested: %llu/%llu, applied: %llu/%llu)\n",
 			 state->duty_cycle, state->period,




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux