Commit b2c71e9f authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Thierry Reding

pwm: stmpe: Handle errors when disabling the signal

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: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent 8c89fd86
...@@ -61,7 +61,7 @@ static int stmpe_24xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) ...@@ -61,7 +61,7 @@ static int stmpe_24xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
return 0; return 0;
} }
static void stmpe_24xx_pwm_disable(struct pwm_chip *chip, static int stmpe_24xx_pwm_disable(struct pwm_chip *chip,
struct pwm_device *pwm) struct pwm_device *pwm)
{ {
struct stmpe_pwm *stmpe_pwm = to_stmpe_pwm(chip); struct stmpe_pwm *stmpe_pwm = to_stmpe_pwm(chip);
...@@ -72,17 +72,16 @@ static void stmpe_24xx_pwm_disable(struct pwm_chip *chip, ...@@ -72,17 +72,16 @@ static void stmpe_24xx_pwm_disable(struct pwm_chip *chip,
if (ret < 0) { if (ret < 0) {
dev_err(chip->dev, "error reading PWM#%u control\n", dev_err(chip->dev, "error reading PWM#%u control\n",
pwm->hwpwm); pwm->hwpwm);
return; return ret;
} }
value = ret & ~BIT(pwm->hwpwm); value = ret & ~BIT(pwm->hwpwm);
ret = stmpe_reg_write(stmpe_pwm->stmpe, STMPE24XX_PWMCS, value); ret = stmpe_reg_write(stmpe_pwm->stmpe, STMPE24XX_PWMCS, value);
if (ret) { if (ret)
dev_err(chip->dev, "error writing PWM#%u control\n", dev_err(chip->dev, "error writing PWM#%u control\n",
pwm->hwpwm); pwm->hwpwm);
return; return ret;
}
} }
/* STMPE 24xx PWM instructions */ /* STMPE 24xx PWM instructions */
...@@ -111,7 +110,9 @@ static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -111,7 +110,9 @@ static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
/* Make sure we are disabled */ /* Make sure we are disabled */
if (pwm_is_enabled(pwm)) { if (pwm_is_enabled(pwm)) {
stmpe_24xx_pwm_disable(chip, pwm); ret = stmpe_24xx_pwm_disable(chip, pwm);
if (ret)
return ret;
} else { } else {
/* Connect the PWM to the pin */ /* Connect the PWM to the pin */
pin = pwm->hwpwm; pin = pwm->hwpwm;
...@@ -269,7 +270,7 @@ static int stmpe_24xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -269,7 +270,7 @@ static int stmpe_24xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
if (!state->enabled) { if (!state->enabled) {
if (pwm->state.enabled) if (pwm->state.enabled)
stmpe_24xx_pwm_disable(chip, pwm); return stmpe_24xx_pwm_disable(chip, pwm);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment