From: Alexandre Courbot <gnurou@gmail.com>
To: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
John Stultz <john.stultz@linaro.org>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH] input: gpio_keys: Don't report events on gpio failure
Date: Mon, 31 Aug 2015 13:51:45 +0900 [thread overview]
Message-ID: <CAAVeFuJ4-0O8JM2A2FWG8ad42G=LtKYet2bfESpuEPPnQikVEw@mail.gmail.com> (raw)
In-Reply-To: <20150817193447.GS13472@usrtlx11787.corpusers.net>
On Tue, Aug 18, 2015 at 4:34 AM, Bjorn Andersson
<bjorn.andersson@sonymobile.com> wrote:
> On Sun 16 Aug 23:59 PDT 2015, Alexandre Courbot wrote:
>
>> On Thu, Aug 13, 2015 at 10:06 PM, Linus Walleij
>> <linus.walleij@linaro.org> wrote:
>> > On Tue, Aug 11, 2015 at 12:41 AM, Bjorn Andersson
>> > <bjorn.andersson@sonymobile.com> wrote:
>> >
>> >> But then the question first goes to Linus & co.
>> >>
>> >> gpio_chip->get() can return a negative value to indicate errors (and did
>> >> so in this case), all parts of the API seems indicates that we can get
>> >> an error (int vs bool).
>> >
>> > Ooops.
>> >
>> >> Should we change _gpiod_get_raw_value() to propagate this error?
>> >
>> > Yes for now. Can you patch it? :)
>> >
>> >> Or
>> >> should we just ignore this issue and propagate an error as GPIO high
>> >> reading?
>> >
>> > I don't know about the future. In some sense GPIOs are so smallish
>> > resources that errorhandling every call to read/write them seem to
>> > be a royal PITA. That is why I wanted to switch them to bool and get
>> > rid of the problem, but now I also see that maybe that was not such a
>> > smart idea, if errors do occur on the set/get_value path.
>>
>> Nowadays GPIOs may reside at the other end of an i2c bus, which means
>> that even the simplest operation like reading a GPIO value can
>> potentially fail. And it will probably not get better - wait until we
>> implement GPIO-over-IP! :)
>>
>
> Now that's progress! I can't wait ;)
>
>> So I'd say it makes sense to propagate errors returned by the driver's
>> get() hook. This might contradict some of our earlier statements about
>> simplifying the GPIO API, but is preferrable to having to make a
>> decision as to which valid value to return if the driver fails...
>>
>
> Sounds good.
>
> As we're patching up _gpiod_get_raw_value(), is the lack of a get()
> implementation the same as a LOW or is that -ENOTSUPP?
I don't see any reason why it should not be -ENOTSUPP if we start to
manage errors properly.
>
>> It should then be made very clear in the documentation that the only
>> positive values ever returned by the GPIO API will be 0 and 1 (we
>> already have a clamping mechanism for that IIRC), and that negative
>> values are propagated as-is.
>>
>
> That makes sense. I'm however not able to find such clamping
> macro/mechanism and it would be very beneficial here...
>
>> Linus, does that seem reasonable to you? Does anyone has the intention
>> to address that one or should I add it to my short-term TODO list?
>
> If you have some input on above (is lack of get() an error) I can hack
> up the patch.
Excellent - since Linus gave his thumb up, I think you can go ahead.
Looking forward to seeing this finally fixed.
Thanks!
Alex.
next prev parent reply other threads:[~2015-08-31 4:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-28 1:50 [PATCH] input: gpio_keys: Don't report events on gpio failure Bjorn Andersson
2015-07-28 21:00 ` Dmitry Torokhov
2015-08-10 22:41 ` Bjorn Andersson
2015-08-13 13:06 ` Linus Walleij
2015-08-17 6:59 ` Alexandre Courbot
2015-08-17 19:34 ` Bjorn Andersson
2015-08-31 4:51 ` Alexandre Courbot [this message]
2015-08-26 7:34 ` Linus Walleij
2015-09-21 4:19 ` Bjorn Andersson
2015-10-02 10:34 ` Linus Walleij
2015-10-02 17:44 ` Dmitry Torokhov
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='CAAVeFuJ4-0O8JM2A2FWG8ad42G=LtKYet2bfESpuEPPnQikVEw@mail.gmail.com' \
--to=gnurou@gmail.com \
--cc=bjorn.andersson@sonymobile.com \
--cc=dmitry.torokhov@gmail.com \
--cc=john.stultz@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@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).