linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Eric Miao <eric.y.miao@gmail.com>
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 11:00:51 +0100	[thread overview]
Message-ID: <20080904100051.GC10426@flint.arm.linux.org.uk> (raw)
In-Reply-To: <f17812d70809040221u606f5bfaxe4ae41fae644391f@mail.gmail.com>

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?

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?

  reply	other threads:[~2008-09-04 10:01 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 [this message]
2008-09-04 10:38   ` Eric Miao
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=20080904100051.GC10426@flint.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=eric.y.miao@gmail.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-input@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).