* [PATCH] pwm: Drop support for legacy drivers
@ 2022-05-21 11:02 Uwe Kleine-König
2022-06-19 20:07 ` Uwe Kleine-König
2022-06-22 13:33 ` Thierry Reding
0 siblings, 2 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2022-05-21 11:02 UTC (permalink / raw)
To: Thierry Reding, Lee Jones; +Cc: linux-pwm, kernel
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>
---
Hello,
on top of current Thierry's for-next branch this compiles just fine
an allmodconfig on arm64, m68k, powerpc, riscv, s390, sparc64 and x86_64
after cherry-picking 357ad4d89828 ("sound/oss/dmasound: fix
'dmasound_setup' defined but not used") to fix an unrelated problem.
Still I think it would be nice to have this cooking in next for some
time after the next merge window closes.
Best regards
Uwe
drivers/pwm/core.c | 82 +--------------------------------------------
include/linux/pwm.h | 12 -------
2 files changed, 1 insertion(+), 93 deletions(-)
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index c7552df32082..0e042410f6b9 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -235,18 +235,8 @@ EXPORT_SYMBOL_GPL(pwm_get_chip_data);
static bool pwm_ops_check(const struct pwm_chip *chip)
{
-
const struct pwm_ops *ops = chip->ops;
- /* driver supports legacy, non-atomic operation */
- if (ops->config && ops->enable && ops->disable) {
- if (IS_ENABLED(CONFIG_PWM_DEBUG))
- dev_warn(chip->dev,
- "Driver needs updating to atomic API\n");
-
- return true;
- }
-
if (!ops->apply)
return false;
@@ -548,73 +538,6 @@ static void pwm_apply_state_debug(struct pwm_device *pwm,
}
}
-static int pwm_apply_legacy(struct pwm_chip *chip, struct pwm_device *pwm,
- const struct pwm_state *state)
-{
- int err;
- struct pwm_state initial_state = pwm->state;
-
- if (state->polarity != pwm->state.polarity) {
- if (!chip->ops->set_polarity)
- return -EINVAL;
-
- /*
- * Changing the polarity of a running PWM is only allowed when
- * the PWM driver implements ->apply().
- */
- if (pwm->state.enabled) {
- chip->ops->disable(chip, pwm);
-
- /*
- * Update pwm->state already here in case
- * .set_polarity() or another callback depend on that.
- */
- pwm->state.enabled = false;
- }
-
- err = chip->ops->set_polarity(chip, pwm, state->polarity);
- if (err)
- goto rollback;
-
- pwm->state.polarity = state->polarity;
- }
-
- if (!state->enabled) {
- if (pwm->state.enabled)
- chip->ops->disable(chip, pwm);
-
- return 0;
- }
-
- /*
- * We cannot skip calling ->config even if state->period ==
- * pwm->state.period && state->duty_cycle == pwm->state.duty_cycle
- * because we might have exited early in the last call to
- * pwm_apply_state because of !state->enabled and so the two values in
- * pwm->state might not be configured in hardware.
- */
- err = chip->ops->config(pwm->chip, pwm,
- state->duty_cycle,
- state->period);
- if (err)
- goto rollback;
-
- pwm->state.period = state->period;
- pwm->state.duty_cycle = state->duty_cycle;
-
- if (!pwm->state.enabled) {
- err = chip->ops->enable(chip, pwm);
- if (err)
- goto rollback;
- }
-
- return 0;
-
-rollback:
- pwm->state = initial_state;
- return err;
-}
-
/**
* pwm_apply_state() - atomically apply a new state to a PWM device
* @pwm: PWM device
@@ -647,10 +570,7 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)
state->usage_power == pwm->state.usage_power)
return 0;
- if (chip->ops->apply)
- err = chip->ops->apply(chip, pwm, state);
- else
- err = pwm_apply_legacy(chip, pwm, state);
+ err = chip->ops->apply(chip, pwm, state);
if (err)
return err;
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index 9771a0761a40..76463b71ad4e 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -261,10 +261,6 @@ pwm_set_relative_duty_cycle(struct pwm_state *state, unsigned int duty_cycle,
* called once per PWM device when the PWM chip is
* registered.
* @owner: helps prevent removal of modules exporting active PWMs
- * @config: configure duty cycles and period length for this PWM
- * @set_polarity: configure the polarity of this PWM
- * @enable: enable PWM output toggling
- * @disable: disable PWM output toggling
*/
struct pwm_ops {
int (*request)(struct pwm_chip *chip, struct pwm_device *pwm);
@@ -276,14 +272,6 @@ struct pwm_ops {
void (*get_state)(struct pwm_chip *chip, struct pwm_device *pwm,
struct pwm_state *state);
struct module *owner;
-
- /* Only used by legacy drivers */
- int (*config)(struct pwm_chip *chip, struct pwm_device *pwm,
- int duty_ns, int period_ns);
- int (*set_polarity)(struct pwm_chip *chip, struct pwm_device *pwm,
- enum pwm_polarity polarity);
- int (*enable)(struct pwm_chip *chip, struct pwm_device *pwm);
- void (*disable)(struct pwm_chip *chip, struct pwm_device *pwm);
};
/**
base-commit: 3d593b6e80ad2c911b5645af28d83eabb96e7c1b
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] pwm: Drop support for legacy drivers
2022-05-21 11:02 [PATCH] pwm: Drop support for legacy drivers Uwe Kleine-König
@ 2022-06-19 20:07 ` Uwe Kleine-König
2022-06-22 13:33 ` Thierry Reding
1 sibling, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2022-06-19 20:07 UTC (permalink / raw)
To: Thierry Reding, Lee Jones; +Cc: linux-pwm, kernel
[-- Attachment #1: Type: text/plain, Size: 1363 bytes --]
Hello Thierry,
On Sat, May 21, 2022 at 01:02:03PM +0200, Uwe Kleine-König wrote:
> 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>
> ---
> Hello,
>
> on top of current Thierry's for-next branch this compiles just fine
> an allmodconfig on arm64, m68k, powerpc, riscv, s390, sparc64 and x86_64
> after cherry-picking 357ad4d89828 ("sound/oss/dmasound: fix
> 'dmasound_setup' defined but not used") to fix an unrelated problem.
FTR said commit is in 5.18-rc4. So no problem assuming the next for-next
will start on something later. (But even if not, not a big deal ...)
> Still I think it would be nice to have this cooking in next for some
> time after the next merge window closes.
Ping! Would be great to get this change into next soon such that it can
cook a while before going to Linus. (All assuming you also like this
patch of course.)
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pwm: Drop support for legacy drivers
2022-05-21 11:02 [PATCH] pwm: Drop support for legacy drivers Uwe Kleine-König
2022-06-19 20:07 ` Uwe Kleine-König
@ 2022-06-22 13:33 ` Thierry Reding
1 sibling, 0 replies; 3+ messages in thread
From: Thierry Reding @ 2022-06-22 13:33 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: Lee Jones, linux-pwm, kernel
[-- Attachment #1: Type: text/plain, Size: 1086 bytes --]
On Sat, May 21, 2022 at 01:02:03PM +0200, Uwe Kleine-König wrote:
> 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>
> ---
> Hello,
>
> on top of current Thierry's for-next branch this compiles just fine
> an allmodconfig on arm64, m68k, powerpc, riscv, s390, sparc64 and x86_64
> after cherry-picking 357ad4d89828 ("sound/oss/dmasound: fix
> 'dmasound_setup' defined but not used") to fix an unrelated problem.
>
> Still I think it would be nice to have this cooking in next for some
> time after the next merge window closes.
>
> Best regards
> Uwe
>
> drivers/pwm/core.c | 82 +--------------------------------------------
> include/linux/pwm.h | 12 -------
> 2 files changed, 1 insertion(+), 93 deletions(-)
Applied, thanks.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-22 13:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-21 11:02 [PATCH] pwm: Drop support for legacy drivers Uwe Kleine-König
2022-06-19 20:07 ` Uwe Kleine-König
2022-06-22 13:33 ` Thierry Reding
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.