Commit e3274e915061a65717454106301d4a5ea8f71783

Authored by Steven A. Falco
Committed by Linus Torvalds
1 parent c8fc40cd34

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 <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>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

drivers/gpio/gpiolib.c
... ... @@ -248,7 +248,7 @@
248 248 if (!test_bit(FLAG_EXPORT, &desc->flags))
249 249 status = -EIO;
250 250 else
251   - status = sprintf(buf, "%d\n", gpio_get_value_cansleep(gpio));
  251 + status = sprintf(buf, "%d\n", !!gpio_get_value_cansleep(gpio));
252 252  
253 253 mutex_unlock(&sysfs_lock);
254 254 return status;