mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Fwd: [PATCH] Modify sysfs gpio export so that "value" displays as 0 or 1
@ 2008-10-16 19:45 David Brownell
  0 siblings, 0 replies; only message in thread
From: David Brownell @ 2008-10-16 19:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: lkml


----------  Forwarded Message  ----------

Subject: [PATCH] Modify sysfs gpio export so that "value" displays as 0 or 1
Date: Friday 10 October 2008
From: "Steven A. Falco" <sfalco@harris.com>
To: "linuxppc-dev@ozlabs.org" <linuxppc-dev@ozlabs.org>, david-b@pacbell.net

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

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 8d29405..36bf72b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -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;


-------------------------------------------------------

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-10-16 19:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-16 19:45 Fwd: [PATCH] Modify sysfs gpio export so that "value" displays as 0 or 1 David Brownell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®