Skip to content

Commit b2e60b3

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: sti: 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 cb696e7 commit b2e60b3

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

drivers/pwm/pwm-sti.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,34 @@ static int sti_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm,
391391
return ret;
392392
}
393393

394+
static int sti_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
395+
const struct pwm_state *state)
396+
{
397+
int err;
398+
399+
if (state->polarity != PWM_POLARITY_NORMAL)
400+
return -EINVAL;
401+
402+
if (!state->enabled) {
403+
if (pwm->state.enabled)
404+
sti_pwm_disable(chip, pwm);
405+
406+
return 0;
407+
}
408+
409+
err = sti_pwm_config(pwm->chip, pwm, state->duty_cycle, state->period);
410+
if (err)
411+
return err;
412+
413+
if (!pwm->state.enabled)
414+
err = sti_pwm_enable(chip, pwm);
415+
416+
return err;
417+
}
418+
394419
static const struct pwm_ops sti_pwm_ops = {
395420
.capture = sti_pwm_capture,
396-
.config = sti_pwm_config,
397-
.enable = sti_pwm_enable,
398-
.disable = sti_pwm_disable,
421+
.apply = sti_pwm_apply,
399422
.free = sti_pwm_free,
400423
.owner = THIS_MODULE,
401424
};

0 commit comments

Comments
 (0)