All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Marc Zyngier <maz@misterjones.org>
Cc: Eric Miao <eric.y.miao@gmail.com>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] gpio: max732x: fix input configuration for open-drain pins
Date: Tue, 20 Apr 2010 16:51:48 -0700	[thread overview]
Message-ID: <20100420165148.49711c3c.akpm@linux-foundation.org> (raw)
In-Reply-To: <c2d04a7116b74b3717366148db5f7e54@localhost>

> On Tue, 16 Mar 2010 10:19:00 +0100

I bet you thought I'd forgotten.

Marc Zyngier <maz@misterjones.org> wrote:

> max732x datasheets indicate that open-drain pins must be
> configured as output-high to be used as input...
> 
> Signed-off-by: Marc Zyngier <maz@misterjones.org>
> ---
>  drivers/gpio/max732x.c |   12 +++++++++++-
>  1 files changed, 11 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/gpio/max732x.c b/drivers/gpio/max732x.c
> index f786824..3618feb 100644
> --- a/drivers/gpio/max732x.c
> +++ b/drivers/gpio/max732x.c
> @@ -179,15 +179,25 @@ static int max732x_gpio_direction_input(struct gpio_chip *gc, unsigned off)
>  {
>  	struct max732x_chip *chip;
>  	unsigned int mask = 1u << off;
> +	unsigned int is_input;
>  
>  	chip = container_of(gc, struct max732x_chip, gpio_chip);
>  
> -	if ((mask & chip->dir_input) == 0) {
> +	is_input = mask & chip->dir_input;
> +
> +	if (!is_input) {
>  		dev_dbg(&chip->client->dev, "%s port %d is output only\n",
>  			chip->client->name, off);
>  		return -EACCES;
>  	}
>  
> +	/*
> +	 * Open-drain pins must be set to high impedance (which is
> +	 * equivalent to output-high) to be turned into an input.
> +	 */
> +	if ((is_input & chip->dir_output))

You really did mean `&' here, but one very much expects a variable
called is_foo to be a boolean, and booleans want `&&'.

Can you think of a more appropriate name for this guy?  input_lines, maybe?

> +		max732x_gpio_set_value(gc, off, 1);
> +
>  	return 0;
>  }

  parent reply	other threads:[~2010-04-20 23:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-16  9:19 [PATCH] gpio: max732x: fix input configuration for open-drain pins Marc Zyngier
2010-04-15 13:10 ` Eric Miao
2010-04-20 23:51 ` Andrew Morton [this message]
2010-04-23 13:37   ` Marc Zyngier

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=20100420165148.49711c3c.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=eric.y.miao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@misterjones.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.