From: Alexandre Courbot <gnurou@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Evgeny Boger <boger@contactless.ru>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: Question about non-boolean gpio sysfs values
Date: Wed, 5 Feb 2014 22:24:50 +0900 [thread overview]
Message-ID: <CAAVeFuL2=jqz6hnOJ4E8mLk3Ucnxvsr1y9yNk0-VgKCs_vYBeQ@mail.gmail.com> (raw)
In-Reply-To: <CACRpkdaEMYmPx+qM-dcAW7QDwV8FpvRrYgGdZoA-uN4aMnr_fQ@mail.gmail.com>
On Wed, Feb 5, 2014 at 10:06 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Wed, Feb 5, 2014 at 2:54 AM, Alexandre Courbot <gnurou@gmail.com> wrote:
>> On Sun, Feb 2, 2014 at 8:35 AM, Evgeny Boger <boger@contactless.ru> wrote:
>>> 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.
Agree with the bool retyping, and while we are at it let's also change
the driver function's prototype. That's probably the shortest way to
fix this (yay to implicit type conversion!) and to make sure this
problem isn't reintroduced in the future.
Shall I make a patch for this? It will change every driver around, but
shouldn't be too intrusive.
Alex.
next prev parent reply other threads:[~2014-02-05 13:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-01 23:35 Question about non-boolean gpio sysfs values Evgeny Boger
2014-02-05 1:54 ` Alexandre Courbot
2014-02-05 13:06 ` Linus Walleij
2014-02-05 13:24 ` Alexandre Courbot [this message]
2014-02-05 13:46 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAAVeFuL2=jqz6hnOJ4E8mLk3Ucnxvsr1y9yNk0-VgKCs_vYBeQ@mail.gmail.com' \
--to=gnurou@gmail.com \
--cc=boger@contactless.ru \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).