* [PATCH RESEND] gpio: Add support for GPIOF_ACTIVE_LOW to gpio_request_one functions
@ 2014-07-21 18:12 Guenter Roeck
2014-07-23 15:32 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Guenter Roeck @ 2014-07-21 18:12 UTC (permalink / raw)
To: linux-gpio; +Cc: linux-kernel, Linus Walleij, Alexandre Courbot, Guenter Roeck
The gpio include file and the gpio documentation declare and document
GPIOF_ACTIVE_LOW as one of the flags to be passed to gpio_request_one
and related functions. However, the flag is not evaluated or used.
This can cause problems in at least two areas: First, the same API can
be used to auto-export pins to user space. The missing support for
GPIOF_ACTIVE_LOW results in unexpected behavior for such auto-exported
pins. Second, the requested gpio pin can be convered for use by
gpiod functions with gpio_to_desc(). While gpio API functions do not
support GPIOF_ACTIVE_LOW, gpiod functions do, which again results in
unexpected behavior.
Check the flag in gpio_request_one and set the gpio internal flag
FLAG_ACTIVE_LOW if it is set to address those problems.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
---
Resent with added rationale.
drivers/gpio/gpiolib.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 2ebc907..43d9e34 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1842,6 +1842,9 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
if (flags & GPIOF_OPEN_SOURCE)
set_bit(FLAG_OPEN_SOURCE, &desc->flags);
+ if (flags & GPIOF_ACTIVE_LOW)
+ set_bit(FLAG_ACTIVE_LOW, &desc->flags);
+
if (flags & GPIOF_DIR_IN)
err = gpiod_direction_input(desc);
else
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH RESEND] gpio: Add support for GPIOF_ACTIVE_LOW to gpio_request_one functions
2014-07-21 18:12 [PATCH RESEND] gpio: Add support for GPIOF_ACTIVE_LOW to gpio_request_one functions Guenter Roeck
@ 2014-07-23 15:32 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2014-07-23 15:32 UTC (permalink / raw)
To: Guenter Roeck; +Cc: linux-gpio, linux-kernel, Alexandre Courbot
On Mon, Jul 21, 2014 at 8:12 PM, Guenter Roeck <linux@roeck-us.net> wrote:
> The gpio include file and the gpio documentation declare and document
> GPIOF_ACTIVE_LOW as one of the flags to be passed to gpio_request_one
> and related functions. However, the flag is not evaluated or used.
>
> This can cause problems in at least two areas: First, the same API can
> be used to auto-export pins to user space. The missing support for
> GPIOF_ACTIVE_LOW results in unexpected behavior for such auto-exported
> pins. Second, the requested gpio pin can be convered for use by
> gpiod functions with gpio_to_desc(). While gpio API functions do not
> support GPIOF_ACTIVE_LOW, gpiod functions do, which again results in
> unexpected behavior.
>
> Check the flag in gpio_request_one and set the gpio internal flag
> FLAG_ACTIVE_LOW if it is set to address those problems.
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Patch applied after manually rebasing so it hits gpiolib-legacy.c.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-07-23 15:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-21 18:12 [PATCH RESEND] gpio: Add support for GPIOF_ACTIVE_LOW to gpio_request_one functions Guenter Roeck
2014-07-23 15:32 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).