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

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 <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
57c95faa b2e60b32

+26 -3
+26 -3
drivers/pwm/pwm-stmpe.c
··· 259 259 return 0; 260 260 } 261 261 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 + 262 287 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, 266 289 .owner = THIS_MODULE, 267 290 }; 268 291