diff options
author | Lukas Wunner <lukas@wunner.de> | 2017-10-12 06:40:10 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-10-19 16:32:39 -0400 |
commit | eec1d566cdf94b57e8f5ba9fe60eea214929bcfc (patch) | |
tree | f10fab2d393d231f711123fcf66c1b01fc893370 /include/linux/gpio/driver.h | |
parent | 5307e2ad69ab3b0e0622fdf8b254c1d4565eb924 (diff) |
gpio: Introduce ->get_multiple callback
SPI-attached GPIO controllers typically read out all inputs in one go.
If callers desire the values of multipe inputs, ideally a single readout
should take place to return the desired values. However the current
driver API only offers a ->get callback but no ->get_multiple (unlike
->set_multiple, which is present). Thus, to read multiple inputs, a
full readout needs to be performed for every single value (barring
driver-internal caching), which is inefficient.
In fact, the lack of a ->get_multiple callback has been bemoaned
repeatedly by the gpio subsystem maintainer:
http://www.spinics.net/lists/linux-gpio/msg10571.html
http://www.spinics.net/lists/devicetree/msg121734.html
Introduce the missing callback. Add corresponding consumer functions
such as gpiod_get_array_value(). Amend linehandle_ioctl() to take
advantage of the newly added infrastructure. Update the documentation.
Cc: Rojhalat Ibrahim <imr@rtschenk.de>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'include/linux/gpio/driver.h')
-rw-r--r-- | include/linux/gpio/driver.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 6bbda879fb8b..bda95a9b7b8c 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h | |||
@@ -35,6 +35,8 @@ struct module; | |||
35 | * @direction_input: configures signal "offset" as input, or returns error | 35 | * @direction_input: configures signal "offset" as input, or returns error |
36 | * @direction_output: configures signal "offset" as output, or returns error | 36 | * @direction_output: configures signal "offset" as output, or returns error |
37 | * @get: returns value for signal "offset", 0=low, 1=high, or negative error | 37 | * @get: returns value for signal "offset", 0=low, 1=high, or negative error |
38 | * @get_multiple: reads values for multiple signals defined by "mask" and | ||
39 | * stores them in "bits", returns 0 on success or negative error | ||
38 | * @set: assigns output value for signal "offset" | 40 | * @set: assigns output value for signal "offset" |
39 | * @set_multiple: assigns output values for multiple signals defined by "mask" | 41 | * @set_multiple: assigns output values for multiple signals defined by "mask" |
40 | * @set_config: optional hook for all kinds of settings. Uses the same | 42 | * @set_config: optional hook for all kinds of settings. Uses the same |
@@ -125,6 +127,9 @@ struct gpio_chip { | |||
125 | unsigned offset, int value); | 127 | unsigned offset, int value); |
126 | int (*get)(struct gpio_chip *chip, | 128 | int (*get)(struct gpio_chip *chip, |
127 | unsigned offset); | 129 | unsigned offset); |
130 | int (*get_multiple)(struct gpio_chip *chip, | ||
131 | unsigned long *mask, | ||
132 | unsigned long *bits); | ||
128 | void (*set)(struct gpio_chip *chip, | 133 | void (*set)(struct gpio_chip *chip, |
129 | unsigned offset, int value); | 134 | unsigned offset, int value); |
130 | void (*set_multiple)(struct gpio_chip *chip, | 135 | void (*set_multiple)(struct gpio_chip *chip, |