linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Eric Miao" <eric.y.miao@gmail.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: ARM Linux <linux-arm-kernel@lists.arm.linux.org.uk>,
	linux-input@vger.kernel.org
Subject: Re: [PATCH 1/3] Input: ads7846 - introduce .gpio_pendown to get pendown state
Date: Thu, 4 Sep 2008 18:38:15 +0800	[thread overview]
Message-ID: <f17812d70809040338u3f6345a2ja76ccb76b96cc9dc@mail.gmail.com> (raw)
In-Reply-To: <20080904100051.GC10426@flint.arm.linux.org.uk>

On Thu, Sep 4, 2008 at 6:00 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Thu, Sep 04, 2008 at 05:21:05PM +0800, Eric Miao wrote:
>> The GPIO connected to ADS7846 nPENIRQ signal is usually used to get
>> the pendown state as well. Introduce a .gpio_pendown, and use this
>> to decide the pendown state if .get_pendown_state is NULL.
>
>> +static int get_pendown_state(struct ads7846 *ts)
>> +{
>> +     if (ts->get_pendown_state)
>> +             return ts->get_pendown_state();
>> +
>> +     if (ts->gpio_pendown != -1)
>> +             return !gpio_get_value(ts->gpio_pendown);
>> +
>> +     return 0;
>> +}
>> +
>
>
>> +     int     gpio_pendown;           /* the GPIO usually connected to PENIRQ
>> +                                      * and used to decide pendown state
>> +                                      * (-1) to use (*get_pendown_state) */
>> +
>
> The comment doesn't match the code.  get_pendown_state() is used if it's
> non-NULL, otherwise, the GPIO if it's not -1.
>
> I'm getting a little worried about these tests for valid gpio numbers in
> drivers - some check for non-zero, this one checks for not -1.  I get the
> feeling that this is storing up problems for later.
>
> Maybe using gpio_is_valid() would be a good idea?
>

Indeed, I'll fix the other SPI GPIO CS patch as well.

> But... a related question: do we need to do the check here?  Surely either
> a pendown function is going to be supplied, or if not we're going to use
> a GPIO, in which case the GPIO better be valid.  Maybe something to check
> at driver initialisation time only?
>

There is a warning If none is provided, and probe() will fail.
So actually get_pendown_state() will never reach the last
"return 0" statement.

-- 
Cheers
- eric

  reply	other threads:[~2008-09-04 10:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-04  9:21 [PATCH 1/3] Input: ads7846 - introduce .gpio_pendown to get pendown state Eric Miao
2008-09-04 10:00 ` Russell King - ARM Linux
2008-09-04 10:38   ` Eric Miao [this message]
2008-09-04 10:39     ` Eric Miao
2008-09-04 10:50       ` Eric Miao
2008-09-10 16:18         ` 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=f17812d70809040338u3f6345a2ja76ccb76b96cc9dc@mail.gmail.com \
    --to=eric.y.miao@gmail.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-input@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    /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).