Skip to content

Commit

Permalink
pwm: stmpe: Handle errors when disabling the signal
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
  • Loading branch information
Uwe Kleine-König authored and Thierry Reding committed Jul 28, 2023
1 parent 8c89fd8 commit b2c71e9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions drivers/pwm/pwm-stmpe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b2c71e9

Please sign in to comment.