Thread (26 messages) 26 messages, 8 authors, 2024-11-11

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

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2024-11-11 09:45:29
Also in: linux-arm-kernel, linux-gpio, linux-leds, linux-usb, lkml

Hi Andy,

On Mon, Nov 4, 2024 at 10:37 AM Andy Shevchenko
[off-list ref] wrote:
Avoid using GPIOF_ACTIVE_LOW as it's deprecated and subject to remove.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks for your patch, which is now commit e6a2f0ea519fd247
("leds: gpio: Avoid using GPIOF_ACTIVE_LOW") in gpio/gpio/for-next.
quoted hunk ↗ jump to hunk
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -212,7 +212,6 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,
                                            const struct gpio_led *template)
 {
        struct gpio_desc *gpiod;
-       unsigned long flags = GPIOF_OUT_INIT_LOW;
        int ret;

        /*
@@ -239,10 +238,7 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,
        if (!gpio_is_valid(template->gpio))
                return ERR_PTR(-ENOENT);

-       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?
quoted hunk ↗ jump to hunk
        if (ret < 0)
                return ERR_PTR(ret);
@@ -251,6 +247,9 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,
        if (!gpiod)
                return ERR_PTR(-EINVAL);

+       if (template->active_low ^ gpiod_is_active_low(gpiod))
+               gpiod_toggle_active_low(gpiod);
+
        return gpiod;
 }
Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help