Skip to content

Commit 57c95fa

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: stmpe: Implement .apply() callback
To eventually get rid of all legacy drivers convert this driver to the modern world implementing .apply(). This just pushed a variant of pwm_apply_legacy() into the driver that was slightly simplified because the driver doesn't provide a .set_polarity() callback. Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent b2e60b3 commit 57c95fa

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

drivers/pwm/pwm-stmpe.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,33 @@ static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
259259
return 0;
260260
}
261261

262+
static int stmpe_24xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
263+
const struct pwm_state *state)
264+
{
265+
int err;
266+
267+
if (state->polarity != PWM_POLARITY_NORMAL)
268+
return -EINVAL;
269+
270+
if (!state->enabled) {
271+
if (pwm->state.enabled)
272+
stmpe_24xx_pwm_disable(chip, pwm);
273+
274+
return 0;
275+
}
276+
277+
err = stmpe_24xx_pwm_config(pwm->chip, pwm, state->duty_cycle, state->period);
278+
if (err)
279+
return err;
280+
281+
if (!pwm->state.enabled)
282+
err = stmpe_24xx_pwm_enable(chip, pwm);
283+
284+
return err;
285+
}
286+
262287
static const struct pwm_ops stmpe_24xx_pwm_ops = {
263-
.config = stmpe_24xx_pwm_config,
264-
.enable = stmpe_24xx_pwm_enable,
265-
.disable = stmpe_24xx_pwm_disable,
288+
.apply = stmpe_24xx_pwm_apply,
266289
.owner = THIS_MODULE,
267290
};
268291

0 commit comments

Comments
 (0)