linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Modify sysfs gpio export so that "value" displays as 0 or 1
@ 2008-10-10 14:04 Steven A. Falco
  2008-10-16 19:46 ` David Brownell
  0 siblings, 1 reply; 2+ messages in thread
From: Steven A. Falco @ 2008-10-10 14:04 UTC (permalink / raw)
  To: linuxppc-dev, david-b

gpiolib can export GPIOs to userspace via sysfs.  This patch modifies
the gpio_value_show() so that any non-zero value is explicitly printed
as "1", rather than whatever numerical value the lower-level driver returns.

Signed-off-by: Steve Falco <sfalco at harris.com>
---

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 8d29405..36bf72b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -237,7 +237,7 @@ static ssize_t gpio_value_show(struct device *dev,
 	if (!test_bit(FLAG_EXPORT, &desc->flags))
 		status = -EIO;
 	else
-		status = sprintf(buf, "%d\n", gpio_get_value_cansleep(gpio));
+		status = sprintf(buf, "%d\n", !!gpio_get_value_cansleep(gpio));
 
 	mutex_unlock(&sysfs_lock);
 	return status;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Modify sysfs gpio export so that "value" displays as 0 or 1
  2008-10-10 14:04 [PATCH] Modify sysfs gpio export so that "value" displays as 0 or 1 Steven A. Falco
@ 2008-10-16 19:46 ` David Brownell
  0 siblings, 0 replies; 2+ messages in thread
From: David Brownell @ 2008-10-16 19:46 UTC (permalink / raw)
  To: Steven A. Falco; +Cc: linuxppc-dev

On Friday 10 October 2008, Steven A. Falco wrote:
> gpiolib can export GPIOs to userspace via sysfs.  This patch modifies
> the gpio_value_show() so that any non-zero value is explicitly printed
> as "1", rather than whatever numerical value the lower-level driver returns.
> 
> Signed-off-by: Steve Falco <sfalco at harris.com>

I just forwarded this to Andrew (cc LKML) with my
signoff ... sorry I forgot to add you to the CC.  :(


> ---
> 
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 8d29405..36bf72b 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -237,7 +237,7 @@ static ssize_t gpio_value_show(struct device *dev,
>  	if (!test_bit(FLAG_EXPORT, &desc->flags))
>  		status = -EIO;
>  	else
> -		status = sprintf(buf, "%d\n", gpio_get_value_cansleep(gpio));
> +		status = sprintf(buf, "%d\n", !!gpio_get_value_cansleep(gpio));
>  
>  	mutex_unlock(&sysfs_lock);
>  	return status;
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-16 19:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-10 14:04 [PATCH] Modify sysfs gpio export so that "value" displays as 0 or 1 Steven A. Falco
2008-10-16 19:46 ` David Brownell

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).