Skip to content

Commit 0829c35

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
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 ec00cd5 ("pwm: renesas-tpu: Implement .apply() callback") for an example of the needed conversion for your driver. Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent f2906aa commit 0829c35

File tree

2 files changed

+1
-93
lines changed

2 files changed

+1
-93
lines changed

drivers/pwm/core.c

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,8 @@ EXPORT_SYMBOL_GPL(pwm_get_chip_data);
235235

236236
static bool pwm_ops_check(const struct pwm_chip *chip)
237237
{
238-
239238
const struct pwm_ops *ops = chip->ops;
240239

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-
250240
if (!ops->apply)
251241
return false;
252242

@@ -548,73 +538,6 @@ static void pwm_apply_state_debug(struct pwm_device *pwm,
548538
}
549539
}
550540

551-
static int pwm_apply_legacy(struct pwm_chip *chip, struct pwm_device *pwm,
552-
const struct pwm_state *state)
553-
{
554-
int err;
555-
struct pwm_state initial_state = pwm->state;
556-
557-
if (state->polarity != pwm->state.polarity) {
558-
if (!chip->ops->set_polarity)
559-
return -EINVAL;
560-
561-
/*
562-
* Changing the polarity of a running PWM is only allowed when
563-
* the PWM driver implements ->apply().
564-
*/
565-
if (pwm->state.enabled) {
566-
chip->ops->disable(chip, pwm);
567-
568-
/*
569-
* Update pwm->state already here in case
570-
* .set_polarity() or another callback depend on that.
571-
*/
572-
pwm->state.enabled = false;
573-
}
574-
575-
err = chip->ops->set_polarity(chip, pwm, state->polarity);
576-
if (err)
577-
goto rollback;
578-
579-
pwm->state.polarity = state->polarity;
580-
}
581-
582-
if (!state->enabled) {
583-
if (pwm->state.enabled)
584-
chip->ops->disable(chip, pwm);
585-
586-
return 0;
587-
}
588-
589-
/*
590-
* We cannot skip calling ->config even if state->period ==
591-
* pwm->state.period && state->duty_cycle == pwm->state.duty_cycle
592-
* because we might have exited early in the last call to
593-
* pwm_apply_state because of !state->enabled and so the two values in
594-
* pwm->state might not be configured in hardware.
595-
*/
596-
err = chip->ops->config(pwm->chip, pwm,
597-
state->duty_cycle,
598-
state->period);
599-
if (err)
600-
goto rollback;
601-
602-
pwm->state.period = state->period;
603-
pwm->state.duty_cycle = state->duty_cycle;
604-
605-
if (!pwm->state.enabled) {
606-
err = chip->ops->enable(chip, pwm);
607-
if (err)
608-
goto rollback;
609-
}
610-
611-
return 0;
612-
613-
rollback:
614-
pwm->state = initial_state;
615-
return err;
616-
}
617-
618541
/**
619542
* pwm_apply_state() - atomically apply a new state to a PWM device
620543
* @pwm: PWM device
@@ -647,10 +570,7 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)
647570
state->usage_power == pwm->state.usage_power)
648571
return 0;
649572

650-
if (chip->ops->apply)
651-
err = chip->ops->apply(chip, pwm, state);
652-
else
653-
err = pwm_apply_legacy(chip, pwm, state);
573+
err = chip->ops->apply(chip, pwm, state);
654574
if (err)
655575
return err;
656576

include/linux/pwm.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,6 @@ pwm_set_relative_duty_cycle(struct pwm_state *state, unsigned int duty_cycle,
261261
* called once per PWM device when the PWM chip is
262262
* registered.
263263
* @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
268264
*/
269265
struct pwm_ops {
270266
int (*request)(struct pwm_chip *chip, struct pwm_device *pwm);
@@ -276,14 +272,6 @@ struct pwm_ops {
276272
void (*get_state)(struct pwm_chip *chip, struct pwm_device *pwm,
277273
struct pwm_state *state);
278274
struct module *owner;
279-
280-
/* Only used by legacy drivers */
281-
int (*config)(struct pwm_chip *chip, struct pwm_device *pwm,
282-
int duty_ns, int period_ns);
283-
int (*set_polarity)(struct pwm_chip *chip, struct pwm_device *pwm,
284-
enum pwm_polarity polarity);
285-
int (*enable)(struct pwm_chip *chip, struct pwm_device *pwm);
286-
void (*disable)(struct pwm_chip *chip, struct pwm_device *pwm);
287275
};
288276

289277
/**

0 commit comments

Comments
 (0)