lkml.org 
[lkml]   [2010]   [Apr]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] gpio: max732x: fix input configuration for open-drain pins
> 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;
> }


\
 
 \ /
  Last update: 2010-04-21 01:55    [W:0.546 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site