Re: [RFC PATCH v2 2/6] dt-bindings: pwm: document the PWM no-flag

From: Uwe Kleine-König
Date: Tue Apr 07 2020 - 07:18:57 EST


On Tue, Apr 07, 2020 at 01:51:42PM +0300, Oleksandr Suvorov wrote:
> On Tue, Apr 7, 2020 at 9:17 AM Uwe Kleine-König
> <u.kleine-koenig@xxxxxxxxxxxxxx> wrote:
> >
> > On Sun, Apr 05, 2020 at 10:22:42PM +0300, Oleksandr Suvorov wrote:
> > > Add the description of PWM_NOFLAGS flag property.
> > >
> > > Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@xxxxxxxxxxx>
> >
> > As I already wrote in reply to the v1 series I'd prefer a name for 0
> > that explicitly handles normal polarity.
>
> Uwe, AFAIU, there is no flag that forces normal polarity, the normal polarity
> is the default state if there is no flag to invert the polarity is set.

Yes, that's the status quo.

> '0' value in the bit flags cell really means there are no flags set
> for the PWM instance.

For me the relevance of giving 0 a name is mostly for human consumption.
Currently there is only a single flag encoded in the number in question.
But as soon as we add another, say PWM_AUTOSTART we have the following
possible settings:

PWM_NOFLAGS
PWM_POLARITY_INVERTED
PWM_AUTOSTART
PWM_POLARITY_INVERTED | PWM_AUTOSTART

Then for the first two a reader doesn't see if autostart is not in use
because the dt author doesn't know this feature (e.g. because autostart
is too new) or if they don't want autostart at all.

If however we had PWM_POLARITY_NORMAL and PWM_NO_AUTOSTART to complement
PWM_POLARITY_INVERTED and PWM_AUTOSTART every flag's setting could be
explicit and if there is a device tree that only has

PWM_POLARITY_NORMAL

it would be obvious that nobody thought enough about autostarting to
explicitly mention it.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |