Re: Question about non-boolean gpio sysfs values
flat view
From: Linus Walleij <hidden>
Date: 2014-02-05 13:06:26
On Wed, Feb 5, 2014 at 2:54 AM, Alexandre Courbot [off-list ref] wrote:
On Sun, Feb 2, 2014 at 8:35 AM, Evgeny Boger [off-list ref] wrote:quoted
Hello, I'm now getting non-boolean values from gpio sysfs interface on 3.13, like this
You didn't get this before?
This seems wrong to me, a GPIO should always be 0 or 1.
Yup.
As it turns out, bgpio_get() does the following:
return bgc->read_reg(bgc->reg_dat) & bgc->pin2mask(bgc, gpio);OK lemme patch this.
But I suppose it would also be nice to make gpiod_get_value*() more consistent so the whole subsystem gets fixed in one shot (I suspect a few other drivers are doing the same). I mean, we never expect a GPIO to be something else than 0 or 1, do we?
We can clamp the returned value in gpiod_get_value() for sure. Maybe we should even print a warning there if the driver returns anything other that 0,1. Maybe we should even retype the function to a bool, atleast in the driver-facing API. Yours, Linus Walleij