[PATCH v1 3/6] leds: gpio: Avoid using GPIOF_ACTIVE_LOW

Geert Uytterhoeven geert at linux-m68k.org
Mon Nov 11 02:21:15 PST 2024


Hi Andy,

On Mon, Nov 11, 2024 at 10:57 AM Andy Shevchenko
<andriy.shevchenko at linux.intel.com> wrote:
> On Mon, Nov 11, 2024 at 10:45:13AM +0100, Geert Uytterhoeven wrote:
> > On Mon, Nov 4, 2024 at 10:37 AM Andy Shevchenko
> > <andriy.shevchenko at linux.intel.com> wrote:
>
> ...
>
> > > -       if (template->active_low)
> > > -               flags |= GPIOF_ACTIVE_LOW;
> > > -
> > > -       ret = devm_gpio_request_one(dev, template->gpio, flags,
> > > +       ret = devm_gpio_request_one(dev, template->gpio, GPIOF_OUT_INIT_LOW,
> > >                                     template->name);
> >
> > Just wondering, as I am not 100% sure: can this change change the
> > initial state of the GPIO?
>
> You probably wonder how ACTIVE_LOW affects the OUT_INIT_LOW given above.
> I have an answer to you, however I might be mistaken as well, but I spent some
> time to investigate.
>
> The above mentioned call ends up in the gpiod_direction_output_raw_commit() which
> uses the value (low in this case) as an absolute value. It does not include the
> ACTIVE_LOW in the value calculations. Hence, setting ACTIVE_LOW before or afterwards
> has no effect on the existing flow.
>
> If you notice a mistake, please elaborate this, so I can fix the approach!

Thanks, I had discovered the same, but wanted to double-check!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

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



More information about the linux-arm-kernel mailing list