Skip to content

Commit 9a22993

Browse files
Uwe Kleine-Königvijay-suman
authored andcommitted
pwm: sti: Implement .apply() callback
[ Upstream commit b2e60b3 ] 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]> Stable-dep-of: 5f62383 ("pwm: sti: Fix capture for st,pwm-num-chan < st,capture-num-chan") Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 55908ea9812e0f4b9d40e1af81d3765430309f0c) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 4d0fa7a commit 9a22993

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
@@ -392,11 +392,34 @@ static int sti_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm,
392392
return ret;
393393
}
394394

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

0 commit comments

Comments
 (0)