* [RESEND PATCH] leds: leds-gpio: set devm_gpio_request_one() flags correctly
@ 2012-12-21 15:07 ` Javier Martinez Canillas
0 siblings, 0 replies; 6+ messages in thread
From: Javier Martinez Canillas @ 2012-12-21 15:07 UTC (permalink / raw)
To: linux-leds
Cc: linux-omap, linux-arm-kernel, linux-kernel,
Javier Martinez Canillas
commit a99d76f leds: leds-gpio: use gpio_request_one
changed the leds-gpio driver to use gpio_request_one() instead
of gpio_request() + gpio_direction_output()
Unfortunately, it also made a semantic change that breaks the
leds-gpio driver.
The gpio_request_one() flags parameter was set to:
GPIOF_DIR_OUT | (led_dat->active_low ^ state)
Since GPIOF_DIR_OUT is 0, the final flags value will just be the
XOR'ed value of led_dat->active_low and state.
This value were used to distinguish between HIGH/LOW output initial
level and call gpio_direction_output() accordingly.
With this new semantic gpio_request_one() will take the flags value
of 1 as a configuration of input direction (GPIOF_DIR_IN) and will
call gpio_direction_input() instead of gpio_direction_output().
int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
{
..
if (flags & GPIOF_DIR_IN)
err = gpio_direction_input(gpio);
else
err = gpio_direction_output(gpio,
(flags & GPIOF_INIT_HIGH) ? 1 : 0);
..
}
The right semantic is to evaluate led_dat->active_low ^ state and
set the output initial level explicitly.
Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
This makes LEDs to work again on my IGEPv2 board (TI OMAP3 based SoC).
I sent this patch before but then realized that I only cc'ed to linux-leds.
So, I'm resending the patch cc'ing linux-omap,linux-arm-kernel and LKML to
reach a broader audience and have more people review/test the patch.
Sorry for the noise if someone got it twice.
drivers/leds/leds-gpio.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 1885a26..a0d931b 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -127,8 +127,9 @@ static int create_gpio_led(const struct gpio_led *template,
led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
ret = devm_gpio_request_one(parent, template->gpio,
- GPIOF_DIR_OUT | (led_dat->active_low ^ state),
- template->name);
+ (led_dat->active_low ^ state) ?
+ GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
+ template->name);
if (ret < 0)
return ret;
--
1.7.7.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RESEND PATCH] leds: leds-gpio: set devm_gpio_request_one() flags correctly
@ 2012-12-21 15:07 ` Javier Martinez Canillas
0 siblings, 0 replies; 6+ messages in thread
From: Javier Martinez Canillas @ 2012-12-21 15:07 UTC (permalink / raw)
To: linux-arm-kernel
commit a99d76f leds: leds-gpio: use gpio_request_one
changed the leds-gpio driver to use gpio_request_one() instead
of gpio_request() + gpio_direction_output()
Unfortunately, it also made a semantic change that breaks the
leds-gpio driver.
The gpio_request_one() flags parameter was set to:
GPIOF_DIR_OUT | (led_dat->active_low ^ state)
Since GPIOF_DIR_OUT is 0, the final flags value will just be the
XOR'ed value of led_dat->active_low and state.
This value were used to distinguish between HIGH/LOW output initial
level and call gpio_direction_output() accordingly.
With this new semantic gpio_request_one() will take the flags value
of 1 as a configuration of input direction (GPIOF_DIR_IN) and will
call gpio_direction_input() instead of gpio_direction_output().
int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
{
..
if (flags & GPIOF_DIR_IN)
err = gpio_direction_input(gpio);
else
err = gpio_direction_output(gpio,
(flags & GPIOF_INIT_HIGH) ? 1 : 0);
..
}
The right semantic is to evaluate led_dat->active_low ^ state and
set the output initial level explicitly.
Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
This makes LEDs to work again on my IGEPv2 board (TI OMAP3 based SoC).
I sent this patch before but then realized that I only cc'ed to linux-leds.
So, I'm resending the patch cc'ing linux-omap,linux-arm-kernel and LKML to
reach a broader audience and have more people review/test the patch.
Sorry for the noise if someone got it twice.
drivers/leds/leds-gpio.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 1885a26..a0d931b 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -127,8 +127,9 @@ static int create_gpio_led(const struct gpio_led *template,
led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
ret = devm_gpio_request_one(parent, template->gpio,
- GPIOF_DIR_OUT | (led_dat->active_low ^ state),
- template->name);
+ (led_dat->active_low ^ state) ?
+ GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
+ template->name);
if (ret < 0)
return ret;
--
1.7.7.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RESEND PATCH] leds: leds-gpio: set devm_gpio_request_one() flags correctly
2012-12-21 15:07 ` Javier Martinez Canillas
@ 2012-12-21 17:06 ` Ezequiel Garcia
-1 siblings, 0 replies; 6+ messages in thread
From: Ezequiel Garcia @ 2012-12-21 17:06 UTC (permalink / raw)
To: Javier Martinez Canillas
Cc: linux-leds, linux-omap, linux-arm-kernel, linux-kernel
On Fri, Dec 21, 2012 at 12:07 PM, Javier Martinez Canillas
<javier.martinez@collabora.co.uk> wrote:
> commit a99d76f leds: leds-gpio: use gpio_request_one
>
> changed the leds-gpio driver to use gpio_request_one() instead
> of gpio_request() + gpio_direction_output()
>
> Unfortunately, it also made a semantic change that breaks the
> leds-gpio driver.
>
> The gpio_request_one() flags parameter was set to:
>
> GPIOF_DIR_OUT | (led_dat->active_low ^ state)
>
> Since GPIOF_DIR_OUT is 0, the final flags value will just be the
> XOR'ed value of led_dat->active_low and state.
>
> This value were used to distinguish between HIGH/LOW output initial
> level and call gpio_direction_output() accordingly.
>
> With this new semantic gpio_request_one() will take the flags value
> of 1 as a configuration of input direction (GPIOF_DIR_IN) and will
> call gpio_direction_input() instead of gpio_direction_output().
>
> int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
> {
> ..
> if (flags & GPIOF_DIR_IN)
> err = gpio_direction_input(gpio);
> else
> err = gpio_direction_output(gpio,
> (flags & GPIOF_INIT_HIGH) ? 1 : 0);
> ..
> }
>
> The right semantic is to evaluate led_dat->active_low ^ state and
> set the output initial level explicitly.
>
> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
> ---
>
> This makes LEDs to work again on my IGEPv2 board (TI OMAP3 based SoC).
>
> I sent this patch before but then realized that I only cc'ed to linux-leds.
> So, I'm resending the patch cc'ing linux-omap,linux-arm-kernel and LKML to
> reach a broader audience and have more people review/test the patch.
>
> Sorry for the noise if someone got it twice.
>
> drivers/leds/leds-gpio.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
> index 1885a26..a0d931b 100644
> --- a/drivers/leds/leds-gpio.c
> +++ b/drivers/leds/leds-gpio.c
> @@ -127,8 +127,9 @@ static int create_gpio_led(const struct gpio_led *template,
> led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
>
> ret = devm_gpio_request_one(parent, template->gpio,
> - GPIOF_DIR_OUT | (led_dat->active_low ^ state),
> - template->name);
> + (led_dat->active_low ^ state) ?
> + GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
> + template->name);
> if (ret < 0)
> return ret;
>
> --
> 1.7.7.6
>
Without this patch my IGEP v2 LEDs were dead,
and this patch brings them back.
Tested-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Thanks,
Ezequiel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RESEND PATCH] leds: leds-gpio: set devm_gpio_request_one() flags correctly
@ 2012-12-21 17:06 ` Ezequiel Garcia
0 siblings, 0 replies; 6+ messages in thread
From: Ezequiel Garcia @ 2012-12-21 17:06 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Dec 21, 2012 at 12:07 PM, Javier Martinez Canillas
<javier.martinez@collabora.co.uk> wrote:
> commit a99d76f leds: leds-gpio: use gpio_request_one
>
> changed the leds-gpio driver to use gpio_request_one() instead
> of gpio_request() + gpio_direction_output()
>
> Unfortunately, it also made a semantic change that breaks the
> leds-gpio driver.
>
> The gpio_request_one() flags parameter was set to:
>
> GPIOF_DIR_OUT | (led_dat->active_low ^ state)
>
> Since GPIOF_DIR_OUT is 0, the final flags value will just be the
> XOR'ed value of led_dat->active_low and state.
>
> This value were used to distinguish between HIGH/LOW output initial
> level and call gpio_direction_output() accordingly.
>
> With this new semantic gpio_request_one() will take the flags value
> of 1 as a configuration of input direction (GPIOF_DIR_IN) and will
> call gpio_direction_input() instead of gpio_direction_output().
>
> int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
> {
> ..
> if (flags & GPIOF_DIR_IN)
> err = gpio_direction_input(gpio);
> else
> err = gpio_direction_output(gpio,
> (flags & GPIOF_INIT_HIGH) ? 1 : 0);
> ..
> }
>
> The right semantic is to evaluate led_dat->active_low ^ state and
> set the output initial level explicitly.
>
> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
> ---
>
> This makes LEDs to work again on my IGEPv2 board (TI OMAP3 based SoC).
>
> I sent this patch before but then realized that I only cc'ed to linux-leds.
> So, I'm resending the patch cc'ing linux-omap,linux-arm-kernel and LKML to
> reach a broader audience and have more people review/test the patch.
>
> Sorry for the noise if someone got it twice.
>
> drivers/leds/leds-gpio.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
> index 1885a26..a0d931b 100644
> --- a/drivers/leds/leds-gpio.c
> +++ b/drivers/leds/leds-gpio.c
> @@ -127,8 +127,9 @@ static int create_gpio_led(const struct gpio_led *template,
> led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
>
> ret = devm_gpio_request_one(parent, template->gpio,
> - GPIOF_DIR_OUT | (led_dat->active_low ^ state),
> - template->name);
> + (led_dat->active_low ^ state) ?
> + GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
> + template->name);
> if (ret < 0)
> return ret;
>
> --
> 1.7.7.6
>
Without this patch my IGEP v2 LEDs were dead,
and this patch brings them back.
Tested-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Thanks,
Ezequiel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RESEND PATCH] leds: leds-gpio: set devm_gpio_request_one() flags correctly
2012-12-21 17:06 ` Ezequiel Garcia
@ 2012-12-31 13:08 ` Javier Martinez Canillas
-1 siblings, 0 replies; 6+ messages in thread
From: Javier Martinez Canillas @ 2012-12-31 13:08 UTC (permalink / raw)
To: Ezequiel Garcia; +Cc: linux-leds, linux-omap, linux-arm-kernel, linux-kernel
On 12/21/2012 06:06 PM, Ezequiel Garcia wrote:
> On Fri, Dec 21, 2012 at 12:07 PM, Javier Martinez Canillas
> <javier.martinez@collabora.co.uk> wrote:
>> commit a99d76f leds: leds-gpio: use gpio_request_one
>>
>> changed the leds-gpio driver to use gpio_request_one() instead
>> of gpio_request() + gpio_direction_output()
>>
>> Unfortunately, it also made a semantic change that breaks the
>> leds-gpio driver.
>>
>> The gpio_request_one() flags parameter was set to:
>>
>> GPIOF_DIR_OUT | (led_dat->active_low ^ state)
>>
>> Since GPIOF_DIR_OUT is 0, the final flags value will just be the
>> XOR'ed value of led_dat->active_low and state.
>>
>> This value were used to distinguish between HIGH/LOW output initial
>> level and call gpio_direction_output() accordingly.
>>
>> With this new semantic gpio_request_one() will take the flags value
>> of 1 as a configuration of input direction (GPIOF_DIR_IN) and will
>> call gpio_direction_input() instead of gpio_direction_output().
>>
>> int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
>> {
>> ..
>> if (flags & GPIOF_DIR_IN)
>> err = gpio_direction_input(gpio);
>> else
>> err = gpio_direction_output(gpio,
>> (flags & GPIOF_INIT_HIGH) ? 1 : 0);
>> ..
>> }
>>
>> The right semantic is to evaluate led_dat->active_low ^ state and
>> set the output initial level explicitly.
>>
>> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
>> ---
>>
>> This makes LEDs to work again on my IGEPv2 board (TI OMAP3 based SoC).
>>
>> I sent this patch before but then realized that I only cc'ed to linux-leds.
>> So, I'm resending the patch cc'ing linux-omap,linux-arm-kernel and LKML to
>> reach a broader audience and have more people review/test the patch.
>>
>> Sorry for the noise if someone got it twice.
>>
>> drivers/leds/leds-gpio.c | 5 +++--
>> 1 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
>> index 1885a26..a0d931b 100644
>> --- a/drivers/leds/leds-gpio.c
>> +++ b/drivers/leds/leds-gpio.c
>> @@ -127,8 +127,9 @@ static int create_gpio_led(const struct gpio_led *template,
>> led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
>>
>> ret = devm_gpio_request_one(parent, template->gpio,
>> - GPIOF_DIR_OUT | (led_dat->active_low ^ state),
>> - template->name);
>> + (led_dat->active_low ^ state) ?
>> + GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
>> + template->name);
>> if (ret < 0)
>> return ret;
>>
>> --
>> 1.7.7.6
>>
>
> Without this patch my IGEP v2 LEDs were dead,
> and this patch brings them back.
>
> Tested-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
>
> Thanks,
>
> Ezequiel
>
Hello,
Any news on this?
GPIO LEDs support is still not working on latest mainline kernel and other
people report that this patch solves the issue for them.
Thanks a lot and best regards,
Javier
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RESEND PATCH] leds: leds-gpio: set devm_gpio_request_one() flags correctly
@ 2012-12-31 13:08 ` Javier Martinez Canillas
0 siblings, 0 replies; 6+ messages in thread
From: Javier Martinez Canillas @ 2012-12-31 13:08 UTC (permalink / raw)
To: linux-arm-kernel
On 12/21/2012 06:06 PM, Ezequiel Garcia wrote:
> On Fri, Dec 21, 2012 at 12:07 PM, Javier Martinez Canillas
> <javier.martinez@collabora.co.uk> wrote:
>> commit a99d76f leds: leds-gpio: use gpio_request_one
>>
>> changed the leds-gpio driver to use gpio_request_one() instead
>> of gpio_request() + gpio_direction_output()
>>
>> Unfortunately, it also made a semantic change that breaks the
>> leds-gpio driver.
>>
>> The gpio_request_one() flags parameter was set to:
>>
>> GPIOF_DIR_OUT | (led_dat->active_low ^ state)
>>
>> Since GPIOF_DIR_OUT is 0, the final flags value will just be the
>> XOR'ed value of led_dat->active_low and state.
>>
>> This value were used to distinguish between HIGH/LOW output initial
>> level and call gpio_direction_output() accordingly.
>>
>> With this new semantic gpio_request_one() will take the flags value
>> of 1 as a configuration of input direction (GPIOF_DIR_IN) and will
>> call gpio_direction_input() instead of gpio_direction_output().
>>
>> int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
>> {
>> ..
>> if (flags & GPIOF_DIR_IN)
>> err = gpio_direction_input(gpio);
>> else
>> err = gpio_direction_output(gpio,
>> (flags & GPIOF_INIT_HIGH) ? 1 : 0);
>> ..
>> }
>>
>> The right semantic is to evaluate led_dat->active_low ^ state and
>> set the output initial level explicitly.
>>
>> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
>> ---
>>
>> This makes LEDs to work again on my IGEPv2 board (TI OMAP3 based SoC).
>>
>> I sent this patch before but then realized that I only cc'ed to linux-leds.
>> So, I'm resending the patch cc'ing linux-omap,linux-arm-kernel and LKML to
>> reach a broader audience and have more people review/test the patch.
>>
>> Sorry for the noise if someone got it twice.
>>
>> drivers/leds/leds-gpio.c | 5 +++--
>> 1 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
>> index 1885a26..a0d931b 100644
>> --- a/drivers/leds/leds-gpio.c
>> +++ b/drivers/leds/leds-gpio.c
>> @@ -127,8 +127,9 @@ static int create_gpio_led(const struct gpio_led *template,
>> led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
>>
>> ret = devm_gpio_request_one(parent, template->gpio,
>> - GPIOF_DIR_OUT | (led_dat->active_low ^ state),
>> - template->name);
>> + (led_dat->active_low ^ state) ?
>> + GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
>> + template->name);
>> if (ret < 0)
>> return ret;
>>
>> --
>> 1.7.7.6
>>
>
> Without this patch my IGEP v2 LEDs were dead,
> and this patch brings them back.
>
> Tested-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
>
> Thanks,
>
> Ezequiel
>
Hello,
Any news on this?
GPIO LEDs support is still not working on latest mainline kernel and other
people report that this patch solves the issue for them.
Thanks a lot and best regards,
Javier
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-12-31 13:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-21 15:07 [RESEND PATCH] leds: leds-gpio: set devm_gpio_request_one() flags correctly Javier Martinez Canillas
2012-12-21 15:07 ` Javier Martinez Canillas
2012-12-21 17:06 ` Ezequiel Garcia
2012-12-21 17:06 ` Ezequiel Garcia
2012-12-31 13:08 ` Javier Martinez Canillas
2012-12-31 13:08 ` Javier Martinez Canillas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.