Re: [patch/rfc 2/4] pcf875x I2C GPIO expander driver
From: David Brownell
Date: Fri Apr 04 2008 - 23:21:30 EST
On Friday 04 April 2008, Trent Piepho wrote:
> >> + if (test_bit(FLAG_IS_OUT, &gdesc->flags)) {
> >> + return -EINVAL;
> >> + /* strcpy(buf, "-1\n"); return 4; */ /* Or this? */
> >
> > Why not just return gpio_get_value(n) in all cases?
That's the right answer...
> > User might want to
> > know which value is currently being output.
>
> I thought the gpiolib layer didn't let you read an output, but I see that's
> not the case now. Maybe it's changed since the first revision? I've changed
> this to call gpio_get_value(n) for outputs too.
I don't recall ever disallowing reading output values ... the
exact behavior is platform-specific, though it "should" be the
value actually sensed at the pin, which might not be the same
as what's being driven.
> Though for the MPC8572 GPIO driver I wrote, it doesn't support reading
> outputs. The hardware doesn't allow it (IMHO, a design flaw), and working
> around this significantly slows down GPIO functions.
Then don't worry about it. Any portable code can't rely on
being able to do that.
- Dave
> What I'm trying to do
> with the GPIO lines is going to be slower than desired no matter how fast I
> make the gpio code (which is almost entirely responsible for the final speed),
> so slowing down reads by a factor of four or more just to read back outputs
> isn't desirable.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/