Skip to content

Commit

Permalink
gpio: modify sysfs gpio export so that "value" displays as 0 or 1
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Steven A. Falco authored and Linus Torvalds committed Oct 20, 2008
1 parent c8fc40c commit e3274e9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e3274e9

Please sign in to comment.