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

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

 




Zitat von Alexandre Courbot <gnurou@xxxxxxxxx>:

On Thu, Mar 27, 2014 at 8:09 AM, Michael Heimpold <mhei@xxxxxxxxxxx> wrote:
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));

Patch 23600969ff137cf4c3bc9098f77e381de334e3f7 ("gpio: clamp returned
values to the boolean range") in -next already takes care of this at a
lower level, so I don't expect this to be needed?

Ah... seems I missed this patch, so yes we do not need this one.
Sorry for the noise.

Regards,
Michael



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