From: Steven A. Falco Date: Sun, 19 Oct 2008 03:27:48 +0000 (-0700) Subject: gpio: modify sysfs gpio export so that "value" displays as 0 or 1 X-Git-Tag: v2.6.28-rc1~170 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=e3274e915061a65717454106301d4a5ea8f71783;p=linux-2.6-omap-h63xx.git gpio: 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 Signed-off-by: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 9112830107a..70de72c443e 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -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;