Skip to content

Commit fd3ddd4

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: tegra: 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 <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 57c95fa commit fd3ddd4

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

drivers/pwm/pwm-tegra.c

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,34 @@ static void tegra_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
230230
pm_runtime_put_sync(pc->dev);
231231
}
232232

233+
static int tegra_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
234+
const struct pwm_state *state)
235+
{
236+
int err;
237+
bool enabled = pwm->state.enabled;
238+
239+
if (state->polarity != PWM_POLARITY_NORMAL)
240+
return -EINVAL;
241+
242+
if (!state->enabled) {
243+
if (enabled)
244+
tegra_pwm_disable(chip, pwm);
245+
246+
return 0;
247+
}
248+
249+
err = tegra_pwm_config(pwm->chip, pwm, state->duty_cycle, state->period);
250+
if (err)
251+
return err;
252+
253+
if (!enabled)
254+
err = tegra_pwm_enable(chip, pwm);
255+
256+
return err;
257+
}
258+
233259
static const struct pwm_ops tegra_pwm_ops = {
234-
.config = tegra_pwm_config,
235-
.enable = tegra_pwm_enable,
236-
.disable = tegra_pwm_disable,
260+
.apply = tegra_pwm_apply,
237261
.owner = THIS_MODULE,
238262
};
239263

0 commit comments

Comments
 (0)