Skip to content

Commit b2c71e9

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
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: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
1 parent 8c89fd8 commit b2c71e9

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/pwm/pwm-stmpe.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ static int stmpe_24xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
6161
return 0;
6262
}
6363

64-
static void stmpe_24xx_pwm_disable(struct pwm_chip *chip,
65-
struct pwm_device *pwm)
64+
static int stmpe_24xx_pwm_disable(struct pwm_chip *chip,
65+
struct pwm_device *pwm)
6666
{
6767
struct stmpe_pwm *stmpe_pwm = to_stmpe_pwm(chip);
6868
u8 value;
@@ -72,17 +72,16 @@ static void stmpe_24xx_pwm_disable(struct pwm_chip *chip,
7272
if (ret < 0) {
7373
dev_err(chip->dev, "error reading PWM#%u control\n",
7474
pwm->hwpwm);
75-
return;
75+
return ret;
7676
}
7777

7878
value = ret & ~BIT(pwm->hwpwm);
7979

8080
ret = stmpe_reg_write(stmpe_pwm->stmpe, STMPE24XX_PWMCS, value);
81-
if (ret) {
81+
if (ret)
8282
dev_err(chip->dev, "error writing PWM#%u control\n",
8383
pwm->hwpwm);
84-
return;
85-
}
84+
return ret;
8685
}
8786

8887
/* STMPE 24xx PWM instructions */
@@ -111,7 +110,9 @@ static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
111110

112111
/* Make sure we are disabled */
113112
if (pwm_is_enabled(pwm)) {
114-
stmpe_24xx_pwm_disable(chip, pwm);
113+
ret = stmpe_24xx_pwm_disable(chip, pwm);
114+
if (ret)
115+
return ret;
115116
} else {
116117
/* Connect the PWM to the pin */
117118
pin = pwm->hwpwm;
@@ -269,7 +270,7 @@ static int stmpe_24xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
269270

270271
if (!state->enabled) {
271272
if (pwm->state.enabled)
272-
stmpe_24xx_pwm_disable(chip, pwm);
273+
return stmpe_24xx_pwm_disable(chip, pwm);
273274

274275
return 0;
275276
}

0 commit comments

Comments
 (0)