Hi Uwe, On Thu, Apr 14, 2022 at 11:18 AM Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote: > On Wed, Apr 13, 2022 at 10:51 AM Uwe Kleine-König > <u.kleine-koenig@xxxxxxxxxxxxxx> wrote: > > > > To eventually get rid of all legacy drivers convert this driver to the > > modern world implementing .apply(). > > > > As pwm->state might not be updated in tpu_pwm_apply() before calling > > tpu_pwm_config(), an additional parameter is needed for tpu_pwm_config() > > to not change the implemented logic. > > > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx> > > LGTM, so > Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx> > > The display backlight still works fine on r8a7740/armadillo, so > Tested-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx> Oops, I spoke too soon... > > @@ -366,13 +366,45 @@ static void tpu_pwm_disable(struct pwm_chip *chip, struct pwm_device *_pwm) > > tpu_pwm_timer_stop(pwm); > > } > > > > +static int tpu_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > > + const struct pwm_state *state) > > +{ > > + int err; > > + bool enabled = pwm->state.enabled; > > + > > + if (state->polarity != pwm->state.polarity) { > > + if (enabled) { > > + tpu_pwm_disable(chip, pwm); > > + enabled = false; > > + } > > + > > + err = tpu_pwm_set_polarity(chip, pwm, state->polarity); > > + if (err) > > + return err; > > + } > > + > > + if (!state->enabled) { > > + if (enabled) > > + chip->ops->disable(chip, pwm); tpu_pwm_disable else it crashes with a NULL-pointer dereference (e.g. during system shutdown). > > + > > + return 0; > > + } Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds