All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] pwm: stmpe: Handle errors when disabling the signal
@ 2023-07-14 21:45 Uwe Kleine-König
  2023-07-14 21:45 ` [PATCH 2/2] pwm: stmpe: Don't issue error messages for problems in .apply_state() Uwe Kleine-König
  2023-07-28  7:50 ` (subset) [PATCH 1/2] pwm: stmpe: Handle errors when disabling the signal Thierry Reding
  0 siblings, 2 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2023-07-14 21:45 UTC (permalink / raw)
  To: Thierry Reding, Maxime Coquelin, Alexandre Torgue
  Cc: linux-pwm, linux-stm32, kernel

Before the pwm framework implementedatomic updates (with the .apply()
callback) the .disable() callback returned void. This is still visible
in the stmpe driver which drops errors in the disable path.

Improve the driver to forward failures in stmpe_24xx_pwm_disable() to
the caller of pwm_apply_state().

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-stmpe.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/pwm/pwm-stmpe.c b/drivers/pwm/pwm-stmpe.c
index 5d4a4762ce0c..e205405c4828 100644
--- a/drivers/pwm/pwm-stmpe.c
+++ b/drivers/pwm/pwm-stmpe.c
@@ -61,8 +61,8 @@ static int stmpe_24xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 	return 0;
 }
 
-static void stmpe_24xx_pwm_disable(struct pwm_chip *chip,
-				   struct pwm_device *pwm)
+static int stmpe_24xx_pwm_disable(struct pwm_chip *chip,
+				  struct pwm_device *pwm)
 {
 	struct stmpe_pwm *stmpe_pwm = to_stmpe_pwm(chip);
 	u8 value;
@@ -72,17 +72,16 @@ static void stmpe_24xx_pwm_disable(struct pwm_chip *chip,
 	if (ret < 0) {
 		dev_err(chip->dev, "error reading PWM#%u control\n",
 			pwm->hwpwm);
-		return;
+		return ret;
 	}
 
 	value = ret & ~BIT(pwm->hwpwm);
 
 	ret = stmpe_reg_write(stmpe_pwm->stmpe, STMPE24XX_PWMCS, value);
-	if (ret) {
+	if (ret)
 		dev_err(chip->dev, "error writing PWM#%u control\n",
 			pwm->hwpwm);
-		return;
-	}
+	return ret;
 }
 
 /* STMPE 24xx PWM instructions */
@@ -111,7 +110,9 @@ static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 
 	/* Make sure we are disabled */
 	if (pwm_is_enabled(pwm)) {
-		stmpe_24xx_pwm_disable(chip, pwm);
+		ret = stmpe_24xx_pwm_disable(chip, pwm);
+		if (ret)
+			return ret;
 	} else {
 		/* Connect the PWM to the pin */
 		pin = pwm->hwpwm;
@@ -269,7 +270,7 @@ static int stmpe_24xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 	if (!state->enabled) {
 		if (pwm->state.enabled)
-			stmpe_24xx_pwm_disable(chip, pwm);
+			return stmpe_24xx_pwm_disable(chip, pwm);
 
 		return 0;
 	}

base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
-- 
2.39.2


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

end of thread, other threads:[~2023-07-28  8:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-14 21:45 [PATCH 1/2] pwm: stmpe: Handle errors when disabling the signal Uwe Kleine-König
2023-07-14 21:45 ` [PATCH 2/2] pwm: stmpe: Don't issue error messages for problems in .apply_state() Uwe Kleine-König
2023-07-28  8:02   ` Thierry Reding
2023-07-28  8:18     ` Uwe Kleine-König
2023-07-28  7:50 ` (subset) [PATCH 1/2] pwm: stmpe: Handle errors when disabling the signal Thierry Reding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.