public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] pwm: correct pwm->state.enabled handling to allow fops control
@ 2024-11-26 21:24 Rafael V. Volkmer
  2024-11-27  8:56 ` Uwe Kleine-König
  0 siblings, 1 reply; 7+ messages in thread
From: Rafael V. Volkmer @ 2024-11-26 21:24 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: linux-pwm, linux-kernel, Rafael V. Volkmer

Ensure pwm->state.enabled is consistently updated during enable and
disable operations in ehrpwm_pwm_apply() to resolve this issue.

Previously, when attempting to interact with the ti PWM driver through
fops, the pwm->state.enabled field was not updated correctly after
applying enable or disable. This led to a state mismatch where the
driver's state detection logic prevented disabling the PWM through
fops once it had been activated.

Signed-off-by: Rafael V. Volkmer <rafael.v.volkmer@gmail.com>
---
 drivers/pwm/pwm-tiehrpwm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index 0125e73b98df..9f939d535440 100644
--- a/drivers/pwm/pwm-tiehrpwm.c
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -420,6 +420,7 @@ static int ehrpwm_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 	if (!state->enabled) {
 		if (enabled)
 			ehrpwm_pwm_disable(chip, pwm);
+			pwm->state.enabled = false;
 		return 0;
 	}
 
@@ -429,6 +430,7 @@ static int ehrpwm_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 	if (!enabled)
 		err = ehrpwm_pwm_enable(chip, pwm);
+		pwm->state.enabled = true;
 
 	return err;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-11-29 18:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-26 21:24 [PATCH 2/2] pwm: correct pwm->state.enabled handling to allow fops control Rafael V. Volkmer
2024-11-27  8:56 ` Uwe Kleine-König
2024-11-27 22:26   ` [PATCH v2] pwm: improve state handling in ehrpwm driver Rafael V. Volkmer
2024-11-28  9:59     ` Uwe Kleine-König
2024-11-29  3:43       ` [PATCH] pwm: tiehrpwm: ensures that state.enabled is synchronized during .probe() Rafael V. Volkmer
2024-11-29 11:30         ` kernel test robot
2024-11-29 18:40         ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox