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

Configure Feed

Select the types of activity you want to include in your feed.

pwm: Drop support for legacy drivers

There are no drivers left providing the legacy callbacks. So drop
support for these.

If this commit breaks your out-of-tree pwm driver, look at e.g. commit
ec00cd5e63f0 ("pwm: renesas-tpu: Implement .apply() callback") for an
example of the needed conversion for your driver.

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
0829c35d f2906aa8

+1 -93
+1 -81
drivers/pwm/core.c
··· 235 235 236 236 static bool pwm_ops_check(const struct pwm_chip *chip) 237 237 { 238 - 239 238 const struct pwm_ops *ops = chip->ops; 240 - 241 - /* driver supports legacy, non-atomic operation */ 242 - if (ops->config && ops->enable && ops->disable) { 243 - if (IS_ENABLED(CONFIG_PWM_DEBUG)) 244 - dev_warn(chip->dev, 245 - "Driver needs updating to atomic API\n"); 246 - 247 - return true; 248 - } 249 239 250 240 if (!ops->apply) 251 241 return false; ··· 538 548 } 539 549 } 540 550 541 - static int pwm_apply_legacy(struct pwm_chip *chip, struct pwm_device *pwm, 542 - const struct pwm_state *state) 543 - { 544 - int err; 545 - struct pwm_state initial_state = pwm->state; 546 - 547 - if (state->polarity != pwm->state.polarity) { 548 - if (!chip->ops->set_polarity) 549 - return -EINVAL; 550 - 551 - /* 552 - * Changing the polarity of a running PWM is only allowed when 553 - * the PWM driver implements ->apply(). 554 - */ 555 - if (pwm->state.enabled) { 556 - chip->ops->disable(chip, pwm); 557 - 558 - /* 559 - * Update pwm->state already here in case 560 - * .set_polarity() or another callback depend on that. 561 - */ 562 - pwm->state.enabled = false; 563 - } 564 - 565 - err = chip->ops->set_polarity(chip, pwm, state->polarity); 566 - if (err) 567 - goto rollback; 568 - 569 - pwm->state.polarity = state->polarity; 570 - } 571 - 572 - if (!state->enabled) { 573 - if (pwm->state.enabled) 574 - chip->ops->disable(chip, pwm); 575 - 576 - return 0; 577 - } 578 - 579 - /* 580 - * We cannot skip calling ->config even if state->period == 581 - * pwm->state.period && state->duty_cycle == pwm->state.duty_cycle 582 - * because we might have exited early in the last call to 583 - * pwm_apply_state because of !state->enabled and so the two values in 584 - * pwm->state might not be configured in hardware. 585 - */ 586 - err = chip->ops->config(pwm->chip, pwm, 587 - state->duty_cycle, 588 - state->period); 589 - if (err) 590 - goto rollback; 591 - 592 - pwm->state.period = state->period; 593 - pwm->state.duty_cycle = state->duty_cycle; 594 - 595 - if (!pwm->state.enabled) { 596 - err = chip->ops->enable(chip, pwm); 597 - if (err) 598 - goto rollback; 599 - } 600 - 601 - return 0; 602 - 603 - rollback: 604 - pwm->state = initial_state; 605 - return err; 606 - } 607 - 608 551 /** 609 552 * pwm_apply_state() - atomically apply a new state to a PWM device 610 553 * @pwm: PWM device ··· 570 647 state->usage_power == pwm->state.usage_power) 571 648 return 0; 572 649 573 - if (chip->ops->apply) 574 - err = chip->ops->apply(chip, pwm, state); 575 - else 576 - err = pwm_apply_legacy(chip, pwm, state); 650 + err = chip->ops->apply(chip, pwm, state); 577 651 if (err) 578 652 return err; 579 653
-12
include/linux/pwm.h
··· 261 261 * called once per PWM device when the PWM chip is 262 262 * registered. 263 263 * @owner: helps prevent removal of modules exporting active PWMs 264 - * @config: configure duty cycles and period length for this PWM 265 - * @set_polarity: configure the polarity of this PWM 266 - * @enable: enable PWM output toggling 267 - * @disable: disable PWM output toggling 268 264 */ 269 265 struct pwm_ops { 270 266 int (*request)(struct pwm_chip *chip, struct pwm_device *pwm); ··· 272 276 void (*get_state)(struct pwm_chip *chip, struct pwm_device *pwm, 273 277 struct pwm_state *state); 274 278 struct module *owner; 275 - 276 - /* Only used by legacy drivers */ 277 - int (*config)(struct pwm_chip *chip, struct pwm_device *pwm, 278 - int duty_ns, int period_ns); 279 - int (*set_polarity)(struct pwm_chip *chip, struct pwm_device *pwm, 280 - enum pwm_polarity polarity); 281 - int (*enable)(struct pwm_chip *chip, struct pwm_device *pwm); 282 - void (*disable)(struct pwm_chip *chip, struct pwm_device *pwm); 283 279 }; 284 280 285 281 /**