[PATCH] gpiolib: trim userspace representation of "value" to 0/1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



According to Documentation/gpio/sysfs.txt:
  ...
  "value" ... reads as either 0 (low) or 1 (high).

Since some gpio implementations return non-zero if GPIO is set
but not 1, filter the return value to fit the documentation.

Signed-off-by: Michael Heimpold <mhei@xxxxxxxxxxx>
---
 drivers/gpio/gpiolib.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 50c4922..45aa695 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -376,7 +376,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", gpiod_get_value_cansleep(desc));
+		status = sprintf(buf, "%d\n", !!gpiod_get_value_cansleep(desc));
 
 	mutex_unlock(&sysfs_lock);
 	return status;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux