From: Bjorn Andersson <bjorn.andersson@sonymobile.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>
Cc: "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>
Subject: Re: [PATCH] input: gpio_keys: Don't report events on gpio failure
Date: Mon, 10 Aug 2015 15:41:09 -0700 [thread overview]
Message-ID: <20150810224109.GN6519@usrtlx11787.corpusers.net> (raw)
In-Reply-To: <20150728210040.GE19610@dtor-ws>
On Tue 28 Jul 14:00 PDT 2015, Dmitry Torokhov wrote:
> Hi Bjorn,
>
> On Mon, Jul 27, 2015 at 06:50:04PM -0700, Bjorn Andersson wrote:
> > In the cases where the gpio chip fails to acquire the current state an
> > error is reported back to gpio_keys. This is currently interpreted as if
> > the line went high, which just confuses the developer.
> >
> > This patch introduces an error print in this case and skipps the
> > reporting of a input event; to aid in debugging this issue.
> >
> > Reported-by: John Stultz <john.stultz@linaro.org>
> > Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
> > ---
> > drivers/input/keyboard/gpio_keys.c | 8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> > index ddf4045de084..3ce3298ac09e 100644
> > --- a/drivers/input/keyboard/gpio_keys.c
> > +++ b/drivers/input/keyboard/gpio_keys.c
> > @@ -336,8 +336,14 @@ static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
> > const struct gpio_keys_button *button = bdata->button;
> > struct input_dev *input = bdata->input;
> > unsigned int type = button->type ?: EV_KEY;
> > - int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
> > + int state = gpio_get_value_cansleep(button->gpio);
> >
> > + if (state < 0) {
> > + dev_err(input->dev.parent, "failed to get gpio state\n");
>
> As far as I can see:
>
> static inline int gpio_get_value_cansleep(unsigned gpio)
> {
> return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio));
> }
>
> int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc)
> {
> might_sleep_if(extra_checks);
> if (!desc)
> return 0;
> return _gpiod_get_raw_value(desc);
> }
>
> static bool _gpiod_get_raw_value(const struct gpio_desc *desc)
> {
> ...
> }
>
> So how exactly do we get negative here?
I'm sorry, I obviously didn't pay enough attention when running through
that callstack...
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).
Should we change _gpiod_get_raw_value() to propagate this error? Or
should we just ignore this issue and propagate an error as GPIO high
reading?
Regards,
Bjorn
next prev parent reply other threads:[~2015-08-10 22:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-28 1:50 Bjorn Andersson
2015-07-28 21:00 ` Dmitry Torokhov
2015-08-10 22:41 ` Bjorn Andersson [this message]
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
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=20150810224109.GN6519@usrtlx11787.corpusers.net \
--to=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
all inboxes | Powered by JetHome®