Modify sysfs gpio export so that "value" displays as 0 or 1
PATCH 1/1 Modify sysfs gpio export so that "value" displays as 0 or 1
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>
---
drivers/gpio/gpiolib.c +1 -1
@@ -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;
Quoted 5 lines · Steven A. Falco
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. :(
Quoted 17 lines
---
drivers/gpio/gpiolib.c +1
-1@@ -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;