Messages in this thread | | | From | David Brownell <> | Subject | Re: [PATCH v2] cs5535-gpio: change input/output enable to match gpiolib expectations | Date | Sat, 27 Feb 2010 11:18:51 -0800 |
| |
On Saturday 27 February 2010, Ben Gardner wrote:
Patch seems OK, but the comment could stand correction:
> The intent of the gpiolib set_direction_xxx functions is as follows:
Clarification: it's not "gpiolib" which expects that; "gpiolib" is just an optional implementation infrastructure for the GPIO programming interface.
That behavior is better described as a "weak expectation" than an intent. It comes from the GPIO programming interface, as described in Documentation/gpio.txt ...
And the reason it describes that weak expectation is that it's how most GPIO hardware behaves ... in particular, how the GPIO banks of most System-on-Chip (SoC) processors behave. (Even on boards with external GPIO controllers, the SoC GPIOs generally outnumber the external GPIOs by one or more orders of magnitude.)
Since the behavior of reading an "output" GPIO's value needs to be specified ... this issue comes up.
> output: enable both input and output > input: disable output, enable input
... the expectation is "weak" in that output-only is very much allowed. However, if a gpio is going to provide that model, (a) it needs to report its value as 0/low/false when asked, which (b) may well trigger some odd behavior in some other driver code that expects more typical behavior
(You *could* also return 0/low/false for output-only GPIOs. But this behavior is more typical, and much more useful.)
So a better explanation of this patch would emphasize that it's providing "more typical behavior" to reduce surprises.
- Dave
| |