Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>

authored by

Uwe Kleine-König and committed by
Thierry Reding
b2e60b32 cb696e74

+26 -3
+26 -3
drivers/pwm/pwm-sti.c
··· 391 391 return ret; 392 392 } 393 393 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 + 394 419 static const struct pwm_ops sti_pwm_ops = { 395 420 .capture = sti_pwm_capture, 396 - .config = sti_pwm_config, 397 - .enable = sti_pwm_enable, 398 - .disable = sti_pwm_disable, 421 + .apply = sti_pwm_apply, 399 422 .free = sti_pwm_free, 400 423 .owner = THIS_MODULE, 401 424 };