diff mbox

Modify sysfs gpio export so that "value" displays as 0 or 1

Message ID 48EF60F1.1010001@harris.com (mailing list archive)
State Accepted, archived
Commit e3274e915061a65717454106301d4a5ea8f71783
Headers show

Commit Message

Steven A. Falco Oct. 10, 2008, 2:04 p.m. UTC
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>
---

Comments

David Brownell Oct. 16, 2008, 7:46 p.m. UTC | #1
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;
> 
>
diff mbox

Patch

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;