gpio: Get rid of deprecated GPIOF_ACTIVE_LOW
Subsystems (7)
cover gpio: Get rid of deprecated GPIOF_ACTIVE_LOW
This series targets the deprecated GPIOF_ACTIVE_LOW as only a few users left. Convert those users to call modern APIs and drop this legacy piece from the source tree.
The idea is to route this via GPIO tree, please Ack.
Andy Shevchenko (6):
Input: gpio_keys - avoid using GPIOF_ACTIVE_LOW
Input: gpio_keys_polled - avoid using GPIOF_ACTIVE_LOW
leds: gpio: Avoid using GPIOF_ACTIVE_LOW
pcmcia: soc_common: Avoid using GPIOF_ACTIVE_LOW
USB: gadget: pxa27x_udc: Avoid using GPIOF_ACTIVE_LOW
gpio: Get rid of GPIOF_ACTIVE_LOW
drivers/gpio/gpiolib-legacy.c | 3 --- drivers/input/keyboard/gpio_keys.c | 10 ++++------ drivers/input/keyboard/gpio_keys_polled.c | 12 +++++------- drivers/leds/leds-gpio.c | 9 ++++----- drivers/pcmcia/soc_common.c | 12 +++++------- drivers/usb/gadget/udc/pxa27x_udc.c | 7 ++++--- include/linux/gpio.h | 3 --- 7 files changed, 22 insertions(+), 34 deletions(-)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 1/6 Input: gpio_keys - avoid using GPIOF_ACTIVE_LOW
Avoid using GPIOF_ACTIVE_LOW as it's deprecated and subject to remove.
--- drivers/input/keyboard/gpio_keys.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/input/keyboard/gpio_keys.c +4 -6
@@ -531,12 +531,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,* Legacy GPIO number, so request the GPIO here and * convert it to descriptor. */ -unsigned flags =GPIOF_IN ; - -if (button->active_low) - flags |=GPIOF_ACTIVE_LOW ; - - error =devm_gpio_request_one (dev, button->gpio, flags, desc); + error =devm_gpio_request_one (dev, button->gpio,GPIOF_IN , desc);if (error <0 ) {dev_err (dev,"Failed to request GPIO %d, error %d\n" , button->gpio, error);
@@ -546,6 +541,9 @@ static int gpio_keys_setup_key(struct platform_device *pdev, bdata->gpiod =gpio_to_desc (button->gpio);if (!bdata->gpiod)return -EINVAL ; + +if (button->active_low ^gpiod_is_active_low (bdata->gpiod)) +gpiod_toggle_active_low (bdata->gpiod); }if (bdata->gpiod) {
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 2/6 Input: gpio_keys_polled - avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoAvoid using GPIOF_ACTIVE_LOW as it's deprecated and subject to remove.
--- drivers/input/keyboard/gpio_keys_polled.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/input/keyboard/gpio_keys_polled.c +5 -7
@@ -306,13 +306,8 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)* Legacy GPIO number so request the GPIO here and * convert it to descriptor. */ -unsigned flags =GPIOF_IN ; - -if (button->active_low) - flags |=GPIOF_ACTIVE_LOW ; - - error =devm_gpio_request_one (dev, button->gpio, - flags, button->desc ? :DRV_NAME ); + error =devm_gpio_request_one (dev, button->gpio,GPIOF_IN , + button->desc ? :DRV_NAME );if (error) return dev_err_probe(dev, error, "unable to claim gpio %u\n",
@@ -325,6 +320,9 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) button->gpio);return -EINVAL ; } + +if (button->active_low ^gpiod_is_active_low (bdata->gpiod)) +gpiod_toggle_active_low (bdata->gpiod); } bdata->last_state =-1 ;
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 3/6 leds: gpio: Avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoAvoid using GPIOF_ACTIVE_LOW as it's deprecated and subject to remove.
--- drivers/leds/leds-gpio.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/leds/leds-gpio.c +4 -5
@@ -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);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; }
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 4/6 pcmcia: soc_common: Avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoAvoid using GPIOF_ACTIVE_LOW as it's deprecated and subject to remove.
--- drivers/pcmcia/soc_common.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/pcmcia/soc_common.c +5 -7
@@ -204,14 +204,8 @@ static int soc_pcmcia_hw_init(struct soc_pcmcia_socket *skt)for (i =0 ; i <ARRAY_SIZE (skt->stat); i++) {if (gpio_is_valid (skt->stat[i].gpio)) { -unsigned long flags =GPIOF_IN ; - -/* CD is active low by default */ -if (i ==SOC_STAT_CD ) - flags |=GPIOF_ACTIVE_LOW ; - ret =devm_gpio_request_one (skt->socket.dev.parent, - skt->stat[i].gpio, flags, + skt->stat[i].gpio,GPIOF_IN , skt->stat[i].name);if (ret) {__soc_pcmcia_hw_shutdown (skt, i);
@@ -219,6 +213,10 @@ static int soc_pcmcia_hw_init(struct soc_pcmcia_socket *skt) } skt->stat[i].desc =gpio_to_desc (skt->stat[i].gpio); + +/* CD is active low by default */ +if ((i ==SOC_STAT_CD ) ^gpiod_is_active_low (skt->stat[i].desc)) +gpiod_toggle_active_low (skt->stat[i].desc); }if (i <SOC_STAT_VS1 && skt->stat[i].desc) {
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 6/6 gpio: Get rid of GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoNo more users.
--- drivers/gpio/gpiolib-legacy.c | 3 --- include/linux/gpio.h | 3 --- 2 files changed, 6 deletions(-)
drivers/gpio/gpiolib-legacy.c +0 -3
@@ -46,9 +46,6 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)if (err)return err; -if (flags &GPIOF_ACTIVE_LOW ) -set_bit (FLAG_ACTIVE_LOW , &desc->flags); -if (flags &GPIOF_IN ) err =gpiod_direction_input (desc);else
include/linux/gpio.h +0 -3
@@ -21,9 +21,6 @@ struct device;#define GPIOF_OUT_INIT_LOW ((0 << 0) | (0 << 1))#define GPIOF_OUT_INIT_HIGH ((0 << 0) | (1 << 1)) -/* Gpio pin is active-low */ -#define GPIOF_ACTIVE_LOW (1 << 2) -/** * struct gpio - a structure describing a GPIO with configuration * @gpio: the GPIO number
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 5/6 USB: gadget: pxa27x_udc: Avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoAvoid using GPIOF_ACTIVE_LOW as it's deprecated and subject to remove.
--- drivers/usb/gadget/udc/pxa27x_udc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/gadget/udc/pxa27x_udc.c +4 -3
@@ -2355,18 +2355,19 @@ static int pxa_udc_probe(struct platform_device *pdev)struct pxa_udc *udc = &memory;int retval =0 , gpio;struct pxa2xx_udc_mach_info *mach =dev_get_platdata (&pdev->dev); -unsigned long gpio_flags;if (mach) { - gpio_flags = mach->gpio_pullup_inverted ?GPIOF_ACTIVE_LOW :0 ; gpio = mach->gpio_pullup;if (gpio_is_valid (gpio)) { retval =devm_gpio_request_one (&pdev->dev, gpio, - gpio_flags, +GPIOF_OUT_INIT_LOW ,"USB D+ pullup" );if (retval)return retval; udc->gpiod =gpio_to_desc (mach->gpio_pullup); + +if (mach->gpio_pullup_inverted ^gpiod_is_active_low (udc->gpiod)) +gpiod_toggle_active_low (udc->gpiod); } udc->udc_command = mach->udc_command; }else {
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Re: [PATCH v1 1/6] Input: gpio_keys - avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoQuoted 3 lines · Andy Shevchenko
Avoid using
GPIOF_ACTIVE_LOWas it's deprecated and subject to remove.Signed-off-by Andy Shevchenko <[email protected]>
Quoted 35 lines
--- drivers/input/keyboard/gpio_keys.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)drivers/input/keyboard/gpio_keys.c +4
-6@@ -531,12 +531,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,* Legacy GPIO number, so request the GPIO here and * convert it to descriptor. */ -unsigned flags =GPIOF_IN ; - -if (button->active_low) - flags |=GPIOF_ACTIVE_LOW ; - - error =devm_gpio_request_one (dev, button->gpio, flags, desc); + error =devm_gpio_request_one (dev, button->gpio,GPIOF_IN , desc);if (error <0 ) {dev_err (dev,"Failed to request GPIO %d, error %d\n" , button->gpio, error);@@ -546,6 +541,9 @@ static int gpio_keys_setup_key(struct platform_device *pdev, bdata->gpiod =gpio_to_desc (button->gpio);if (!bdata->gpiod)return -EINVAL ; + +if (button->active_low ^gpiod_is_active_low (bdata->gpiod)) +gpiod_toggle_active_low (bdata->gpiod); }if (bdata->gpiod) {Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Signature · 1 line
Dmitry
Re: [PATCH v1 2/6] Input: gpio_keys_polled - avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoQuoted 3 lines · Andy Shevchenko
Avoid using
GPIOF_ACTIVE_LOWas it's deprecated and subject to remove.Signed-off-by Andy Shevchenko <[email protected]>
Quoted 37 lines
--- drivers/input/keyboard/gpio_keys_polled.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)drivers/input/keyboard/gpio_keys_polled.c +5
-7@@ -306,13 +306,8 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)* Legacy GPIO number so request the GPIO here and * convert it to descriptor. */ -unsigned flags =GPIOF_IN ; - -if (button->active_low) - flags |=GPIOF_ACTIVE_LOW ; - - error =devm_gpio_request_one (dev, button->gpio, - flags, button->desc ? :DRV_NAME ); + error =devm_gpio_request_one (dev, button->gpio,GPIOF_IN , + button->desc ? :DRV_NAME );if (error) return dev_err_probe(dev, error, "unable to claim gpio %u\n",@@ -325,6 +320,9 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) button->gpio);return -EINVAL ; } + +if (button->active_low ^gpiod_is_active_low (bdata->gpiod)) +gpiod_toggle_active_low (bdata->gpiod); } bdata->last_state =-1 ;Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Signature · 1 line
Dmitry
Re: [PATCH v1 5/6] USB: gadget: pxa27x_udc: Avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoQuoted 6 lines · Andy Shevchenko
Avoid using
GPIOF_ACTIVE_LOWas it's deprecated and subject to remove.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/usb/gadget/udc/pxa27x_udc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
Re: [PATCH v1 3/6] leds: gpio: Avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoQuoted 6 lines · Andy Shevchenko
Avoid using
GPIOF_ACTIVE_LOWas it's deprecated and subject to remove.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/leds/leds-gpio.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
Quoted 37 lines
drivers/leds/leds-gpio.c +4
-5@@ -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);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; }Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Signature · 1 line
Lee Jones [李琼斯]
Quoted 5 lines · Andy Shevchenko
This series targets the deprecated
GPIOF_ACTIVE_LOWas only a few users left. Convert those users to call modern APIs and drop this legacy piece from the source tree.The idea is to route this via GPIO tree, please Ack.
Thank you for Acks, folks!
Dominik, is it possible to get yours or are you inactive nowadays (I saw last mention of your name ca. 2023).
Bart, we have all Acks except pcmcia (see also above), and the change is the same all over the places, do you think it's okay to apply if Dominik won't respond for a few days?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 8 lines · Andy Shevchenko
Quoted 5 lines · Andy Shevchenko
This series targets the deprecated
GPIOF_ACTIVE_LOWas only a few users left. Convert those users to call modern APIs and drop this legacy piece from the source tree.The idea is to route this via GPIO tree, please Ack.
Quoted 9 lines
Thank you for Acks, folks!
Dominik, is it possible to get yours or are you inactive nowadays (I saw last mention of your name ca. 2023).
Bart, we have all Acks except pcmcia (see also above), and the change is the same all over the places, do you think it's okay to apply if Dominik won't respond for a few days?
If we don't get an ack until Friday, I will take it as is.
Bart
Re: [PATCH v1 4/6] pcmcia: soc_common: Avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoQuoted 3 lines · Andy Shevchenko
Avoid using
GPIOF_ACTIVE_LOWas it's deprecated and subject to remove.Signed-off-by Andy Shevchenko <[email protected]>
Looks right to me, some testing would be even better because I never trust these flags to get right.
Yours,
Linus Walleij
Re: [PATCH v1 6/6] gpio: Get rid of GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoQuoted 3 lines · Andy Shevchenko
No more users.
Signed-off-by Andy Shevchenko <[email protected]>
If the series flies, by all means:
Thanks for working on this!
Yours,
Linus Walleij
Re: [PATCH v1 1/6] Input: gpio_keys - avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoQuoted 3 lines · Andy Shevchenko
Avoid using
GPIOF_ACTIVE_LOWas it's deprecated and subject to remove.Signed-off-by Andy Shevchenko <[email protected]>
Yours,
Linus Walleij
Re: [PATCH v1 2/6] Input: gpio_keys_polled - avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoQuoted 3 lines · Andy Shevchenko
Avoid using
GPIOF_ACTIVE_LOWas it's deprecated and subject to remove.Signed-off-by Andy Shevchenko <[email protected]>
Yours,
Linus Walleij
Re: [PATCH v1 5/6] USB: gadget: pxa27x_udc: Avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoQuoted 3 lines · Andy Shevchenko
Avoid using
GPIOF_ACTIVE_LOWas it's deprecated and subject to remove.Signed-off-by Andy Shevchenko <[email protected]>
Yours,
Linus Walleij
Re: [PATCH v1 4/6] pcmcia: soc_common: Avoid using GPIOF_ACTIVE_LOW
In reply to Linus WalleijQuoted 9 lines · Linus Walleij
Quoted 3 lines · Andy Shevchenko
Avoid using
GPIOF_ACTIVE_LOWas it's deprecated and subject to remove.Signed-off-by Andy Shevchenko <[email protected]>Looks right to me, some testing would be even better because I never trust these flags to get right.
I also would like to have this, but seems the only odd fixer was active ca. 2023 last time, I'm not sure we may hear from Dominik in time, otherwise the series will be postponed for unknown period of time, which I do not prefer, rather I will fix any regressions later (but I doubt there are here).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 3/6] leds: gpio: Avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoQuoted 3 lines · Andy Shevchenko
Avoid using
GPIOF_ACTIVE_LOWas it's deprecated and subject to remove.Signed-off-by Andy Shevchenko <[email protected]>
Yours,
Linus Walleij
Re: [PATCH v1 4/6] pcmcia: soc_common: Avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoAm Fri, Nov 08, 2024 at 10:35:41AM +0200 schrieb Andy Shevchenko:
Quoted 8 lines · Linus Walleij
Quoted 7 lines
Quoted 3 lines · Andy Shevchenko
Avoid using
GPIOF_ACTIVE_LOWas it's deprecated and subject to remove.Signed-off-by Andy Shevchenko <[email protected]>
Quoted 7 lines
Quoted 2 lines
Looks right to me, some testing would be even better because I never trust these flags to get right.
I also would like to have this, but seems the only odd fixer was active ca. 2023 last time, I'm not sure we may hear from Dominik in time, otherwise the series will be postponed for unknown period of time, which I do not prefer, rather I will fix any regressions later (but I doubt there are here).
As I don't have such hardware, I cannot help with testing, but from the PCMCIA point of view:
Thanks,
Dominik
Bartosz Golaszewski
AppliedFrom: Bartosz Golaszewski <[email protected]>
Quoted 14 lines · Andy Shevchenko
This series targets the deprecated
GPIOF_ACTIVE_LOWas only a few users left. Convert those users to call modern APIs and drop this legacy piece from the source tree.The idea is to route this via GPIO tree, please Ack.
Andy Shevchenko (6):
Input:gpio_keys- avoid usingGPIOF_ACTIVE_LOW
Input:gpio_keys_polled- avoid usingGPIOF_ACTIVE_LOW
leds: gpio: Avoid usingGPIOF_ACTIVE_LOW
pcmcia:soc_common: Avoid usingGPIOF_ACTIVE_LOW
USB: gadget:pxa27x_udc: Avoid usingGPIOF_ACTIVE_LOW
gpio: Get rid ofGPIOF_ACTIVE_LOW
Quoted 1 line
[...]
Applied, thanks!
[1/6] Input: gpio_keys - avoid using GPIOF_ACTIVE_LOW
commit: a04abf25fb1ac47dd2bf1e1b7ca24ca78688b175
[2/6] Input: gpio_keys_polled - avoid using GPIOF_ACTIVE_LOW
commit: 081aaf2dfcfa10fa5cb5444b77b154cce4355708
[3/6] leds: gpio: Avoid using GPIOF_ACTIVE_LOW
commit: e6a2f0ea519fd2478920d02ce3de07a14fe36b2f
[4/6] pcmcia: soc_common: Avoid using GPIOF_ACTIVE_LOW
commit: 15998583b19749e63c5cd0431a2517f524352762
[5/6] USB: gadget: pxa27x_udc: Avoid using GPIOF_ACTIVE_LOW
commit: 62d2a940f29e6aa5a1d844a90820ca6240a99b34
[6/6] gpio: Get rid of GPIOF_ACTIVE_LOW
commit: fffb9fff12250018a6f4d3e411f9d289210da329Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>
Re: [PATCH v1 4/6] pcmcia: soc_common: Avoid using GPIOF_ACTIVE_LOW
In reply to Dominik BrodowskiQuoted 17 lines · Dominik Brodowski
Am Fri, Nov 08, 2024 at 10:35:41AM +0200 schrieb Andy Shevchenko:
Quoted 8 lines · Linus Walleij
Quoted 7 lines
Quoted 3 lines · Andy Shevchenko
Avoid using
GPIOF_ACTIVE_LOWas it's deprecated and subject to remove.Signed-off-by Andy Shevchenko <[email protected]>Quoted 7 lines
Quoted 2 lines
Looks right to me, some testing would be even better because I never trust these flags to get right.
I also would like to have this, but seems the only odd fixer was active ca. 2023 last time, I'm not sure we may hear from Dominik in time, otherwise the series will be postponed for unknown period of time, which I do not prefer, rather I will fix any regressions later (but I doubt there are here).
Quoted 4 lines
As I don't have such hardware, I cannot help with testing, but from the PCMCIA point of view:
Thanks for chiming in!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 3/6] leds: gpio: Avoid using GPIOF_ACTIVE_LOW
In reply to Andy ShevchenkoHi Andy,
Quoted 3 lines · Andy Shevchenko
Avoid using
GPIOF_ACTIVE_LOWas it's deprecated and subject to remove.Signed-off-by Andy Shevchenko <[email protected]>
Thanks for your patch, which is now commit e6a2f0ea519fd247 ("leds: gpio: Avoid using GPIOF_ACTIVE_LOW") in gpio/gpio/for-next.
Quoted 11 lines
drivers/leds/leds-gpio.c +0
-1@@ -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;/*
drivers/leds/leds-gpio.c static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx, · line 242
Quoted 9 lines
drivers/leds/leds-gpio.c +1
-4@@ -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?
drivers/leds/leds-gpio.c static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx, · line 254
Quoted 11 lines
drivers/leds/leds-gpio.c +3
-0if (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
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] 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
Re: [PATCH v1 3/6] leds: gpio: Avoid using GPIOF_ACTIVE_LOW
Quoted 2 lines · Geert Uytterhoeven
On Mon, Nov 4, 2024 at 10:37 AM Andy Shevchenko
<[email protected]> wrote:
...
Quoted 9 lines
drivers/leds/leds-gpio.c static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx, · line 242
Quoted 6 lines
drivers/leds/leds-gpio.c +1
-4-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!
Quoted 2 lines
Quoted 2 lines
if (ret < 0) return ERR_PTR(ret);
...
Quoted 3 lines
Quoted 3 lines
drivers/leds/leds-gpio.c +3
-0+if (template->active_low ^gpiod_is_active_low (gpiod)) +gpiod_toggle_active_low (gpiod); +
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 3/6] leds: gpio: Avoid using GPIOF_ACTIVE_LOW
Hi Andy,
Quoted 20 lines · Andy Shevchenko
Quoted 2 lines · Geert Uytterhoeven
On Mon, Nov 4, 2024 at 10:37 AM Andy Shevchenko
<[email protected]> wrote:...
Quoted 9 lines
drivers/leds/leds-gpio.c static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx, · line 242
Quoted 6 lines
drivers/leds/leds-gpio.c +1
-4-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_LOWaffects theOUT_INIT_LOWgiven above. I have an answer to you, however I might be mistaken as well, but I spent some time to investigate.
Quoted 6 lines
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 theACTIVE_LOWin the value calculations. Hence, settingACTIVE_LOWbefore 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
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] 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