Re: [PATCH v4 07/11] pwm: imx: Provide atomic PWM support for i.MX PWMv2

From: Boris Brezillon
Date: Fri Jan 06 2017 - 02:07:13 EST


On Thu, 5 Jan 2017 23:15:06 +0200
Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:

> On Thu, Jan 5, 2017 at 11:19 AM, Boris Brezillon
> <boris.brezillon@xxxxxxxxxxxxxxxxxx> wrote:
> > On Thu, 5 Jan 2017 10:03:47 +0100
> > Lukasz Majewski <lukma@xxxxxxx> wrote:
> >> > /*
> >> > * Wait for a free FIFO slot if the PWM is already
> >> > enabled, and
> >> > * flush the FIFO if the PWM was disabled and is
> >> > about to be
> >> > * enabled.
> >> > */
>
> >> > if (cstate.enabled) {
>
> if (pwm_is_enabled()) ?
>
> I think it's better to do whatever API provides to be less error prone.

Both pwm_is_enabled() and pwm_get_state()+struct pwm_state are part of
the PWM API, and I don't see how 'if (pwm_is_enabled())' is less error
prone than 'if (cstate.enabled)'.

This being said, I don't care much. It's mainly a matter of taste IMO,
so if others agree to switch to pwm_is_enabled() I'm fine with that.

>
> >> > imx_pwm_wait_fifo_slot(chip, pwm);
> >> > } else {
> >> > ret = clk_prepare_enable(imx->clk_per);
> >> > if (ret)
> >> > return ret;
>
> >> if (state.enabled && !cstate.enabled)
> >> clk_preapre_enable();
> >
> > Yep, and that's correct.
>
> !pwm_is_enabled() ?
>