Move PWM activation from the legacy request() callback into the pwm_ops apply() path. Activation is now performed when the PWM transitions from disabled to enabled (state.enabled = true), so request() is no longer required. This aligns the driver with modern PWM core expectations: activation happens when the channel is actually enabled, and the device free path still performs deactivation.
Signed-off-by: Ayaan Mirza Baig ayaanmirzabaig85@gmail.com --- drivers/staging/greybus/pwm.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/greybus/pwm.c b/drivers/staging/greybus/pwm.c index 1cb7b9089ead..c80f42100e3b 100644 --- a/drivers/staging/greybus/pwm.c +++ b/drivers/staging/greybus/pwm.c @@ -174,10 +174,6 @@ static int gb_pwm_disable_operation(struct pwm_chip *chip, u8 which) return ret; }
-static int gb_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) -{ - return gb_pwm_activate_operation(chip, pwm->hwpwm); -};
static void gb_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) { @@ -206,6 +202,7 @@ static int gb_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, return err; }
+ /* Disable if requested */ if (!state->enabled) { if (enabled) gb_pwm_disable_operation(chip, pwm->hwpwm); @@ -228,15 +225,21 @@ static int gb_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, if (err) return err;
- /* enable/disable */ - if (!enabled) - return gb_pwm_enable_operation(chip, pwm->hwpwm); + /* Activate and enable on transition from disabled to enabled */ + if (state->enabled && !enabled) { + err = gb_pwm_activate_operation(chip, pwm->hwpwm); + if (err) + return err; + + /* Activate hardware channel before enabling input */ + err = gb_pwm_enable_operation(chip, pwm->hwpwm); + return err; + }
return 0; }
static const struct pwm_ops gb_pwm_ops = { - .request = gb_pwm_request, .free = gb_pwm_free, .apply = gb_pwm_apply, };