gpio: modify sysfs gpio export so that "value" displays as 0 or 1
authorSteven A. Falco <sfalco@harris.com>
Sun, 19 Oct 2008 03:27:48 +0000 (20:27 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 20 Oct 2008 15:52:36 +0000 (08:52 -0700)
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@harris.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/gpio/gpiolib.c

index 9112830107a53d4c208b5a8cbf1934026549bac1..70de72c443e41f2969367d0686542c8bc8e7e156 100644 (file)
@@ -248,7 +248,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;