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 | |
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>
-rw-r--r-- | Documentation/gpio/consumer.txt | 41 | ||||
-rw-r--r-- | drivers/gpio/gpiolib.c | 179 | ||||
-rw-r--r-- | drivers/gpio/gpiolib.h | 4 | ||||
-rw-r--r-- | include/linux/gpio/consumer.h | 43 | ||||
-rw-r--r-- | include/linux/gpio/driver.h | 5 |
5 files changed, 250 insertions, 22 deletions
diff --git a/Documentation/gpio/consumer.txt b/Documentation/gpio/consumer.txt index ddbfa775a78a..63e1bd1d88e3 100644 --- a/Documentation/gpio/consumer.txt +++ b/Documentation/gpio/consumer.txt | |||
@@ -295,9 +295,22 @@ as possible, especially by drivers which should not care about the actual | |||
295 | physical line level and worry about the logical value instead. | 295 | physical line level and worry about the logical value instead. |
296 | 296 | ||
297 | 297 | ||
298 | Set multiple GPIO outputs with a single function call | 298 | Access multiple GPIOs with a single function call |
299 | ----------------------------------------------------- | 299 | ------------------------------------------------- |
300 | The following functions set the output values of an array of GPIOs: | 300 | The following functions get or set the values of an array of GPIOs: |
301 | |||
302 | int gpiod_get_array_value(unsigned int array_size, | ||
303 | struct gpio_desc **desc_array, | ||
304 | int *value_array); | ||
305 | int gpiod_get_raw_array_value(unsigned int array_size, | ||
306 | struct gpio_desc **desc_array, | ||
307 | int *value_array); | ||
308 | int gpiod_get_array_value_cansleep(unsigned int array_size, | ||
309 | struct gpio_desc **desc_array, | ||
310 | int *value_array); | ||
311 | int gpiod_get_raw_array_value_cansleep(unsigned int array_size, | ||
312 | struct gpio_desc **desc_array, | ||
313 | int *value_array); | ||
301 | 314 | ||
302 | void gpiod_set_array_value(unsigned int array_size, | 315 | void gpiod_set_array_value(unsigned int array_size, |
303 | struct gpio_desc **desc_array, | 316 | struct gpio_desc **desc_array, |
@@ -312,34 +325,40 @@ The following functions set the output values of an array of GPIOs: | |||
312 | struct gpio_desc **desc_array, | 325 | struct gpio_desc **desc_array, |
313 | int *value_array) | 326 | int *value_array) |
314 | 327 | ||
315 | The array can be an arbitrary set of GPIOs. The functions will try to set | 328 | The array can be an arbitrary set of GPIOs. The functions will try to access |
316 | GPIOs belonging to the same bank or chip simultaneously if supported by the | 329 | GPIOs belonging to the same bank or chip simultaneously if supported by the |
317 | corresponding chip driver. In that case a significantly improved performance | 330 | corresponding chip driver. In that case a significantly improved performance |
318 | can be expected. If simultaneous setting is not possible the GPIOs will be set | 331 | can be expected. If simultaneous access is not possible the GPIOs will be |
319 | sequentially. | 332 | accessed sequentially. |
320 | 333 | ||
321 | The gpiod_set_array() functions take three arguments: | 334 | The functions take three arguments: |
322 | * array_size - the number of array elements | 335 | * array_size - the number of array elements |
323 | * desc_array - an array of GPIO descriptors | 336 | * desc_array - an array of GPIO descriptors |
324 | * value_array - an array of values to assign to the GPIOs | 337 | * value_array - an array to store the GPIOs' values (get) or |
338 | an array of values to assign to the GPIOs (set) | ||
325 | 339 | ||
326 | The descriptor array can be obtained using the gpiod_get_array() function | 340 | The descriptor array can be obtained using the gpiod_get_array() function |
327 | or one of its variants. If the group of descriptors returned by that function | 341 | or one of its variants. If the group of descriptors returned by that function |
328 | matches the desired group of GPIOs, those GPIOs can be set by simply using | 342 | matches the desired group of GPIOs, those GPIOs can be accessed by simply using |
329 | the struct gpio_descs returned by gpiod_get_array(): | 343 | the struct gpio_descs returned by gpiod_get_array(): |
330 | 344 | ||
331 | struct gpio_descs *my_gpio_descs = gpiod_get_array(...); | 345 | struct gpio_descs *my_gpio_descs = gpiod_get_array(...); |
332 | gpiod_set_array_value(my_gpio_descs->ndescs, my_gpio_descs->desc, | 346 | gpiod_set_array_value(my_gpio_descs->ndescs, my_gpio_descs->desc, |
333 | my_gpio_values); | 347 | my_gpio_values); |
334 | 348 | ||
335 | It is also possible to set a completely arbitrary array of descriptors. The | 349 | It is also possible to access a completely arbitrary array of descriptors. The |
336 | descriptors may be obtained using any combination of gpiod_get() and | 350 | descriptors may be obtained using any combination of gpiod_get() and |
337 | gpiod_get_array(). Afterwards the array of descriptors has to be setup | 351 | gpiod_get_array(). Afterwards the array of descriptors has to be setup |
338 | manually before it can be used with gpiod_set_array(). | 352 | manually before it can be passed to one of the above functions. |
339 | 353 | ||
340 | Note that for optimal performance GPIOs belonging to the same chip should be | 354 | Note that for optimal performance GPIOs belonging to the same chip should be |
341 | contiguous within the array of descriptors. | 355 | contiguous within the array of descriptors. |
342 | 356 | ||
357 | The return value of gpiod_get_array_value() and its variants is 0 on success | ||
358 | or negative on error. Note the difference to gpiod_get_value(), which returns | ||
359 | 0 or 1 on success to convey the GPIO value. With the array functions, the GPIO | ||
360 | values are stored in value_array rather than passed back as return value. | ||
361 | |||
343 | 362 | ||
344 | GPIOs mapped to IRQs | 363 | GPIOs mapped to IRQs |
345 | -------------------- | 364 | -------------------- |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 8113929eb2bd..ff46a1b6299e 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -365,28 +365,28 @@ static long linehandle_ioctl(struct file *filep, unsigned int cmd, | |||
365 | struct linehandle_state *lh = filep->private_data; | 365 | struct linehandle_state *lh = filep->private_data; |
366 | void __user *ip = (void __user *)arg; | 366 | void __user *ip = (void __user *)arg; |
367 | struct gpiohandle_data ghd; | 367 | struct gpiohandle_data ghd; |
368 | int vals[GPIOHANDLES_MAX]; | ||
368 | int i; | 369 | int i; |
369 | 370 | ||
370 | if (cmd == GPIOHANDLE_GET_LINE_VALUES_IOCTL) { | 371 | if (cmd == GPIOHANDLE_GET_LINE_VALUES_IOCTL) { |
371 | int val; | 372 | /* TODO: check if descriptors are really input */ |
373 | int ret = gpiod_get_array_value_complex(false, | ||
374 | true, | ||
375 | lh->numdescs, | ||
376 | lh->descs, | ||
377 | vals); | ||
378 | if (ret) | ||
379 | return ret; | ||
372 | 380 | ||
373 | memset(&ghd, 0, sizeof(ghd)); | 381 | memset(&ghd, 0, sizeof(ghd)); |
374 | 382 | for (i = 0; i < lh->numdescs; i++) | |
375 | /* TODO: check if descriptors are really input */ | 383 | ghd.values[i] = vals[i]; |
376 | for (i = 0; i < lh->numdescs; i++) { | ||
377 | val = gpiod_get_value_cansleep(lh->descs[i]); | ||
378 | if (val < 0) | ||
379 | return val; | ||
380 | ghd.values[i] = val; | ||
381 | } | ||
382 | 384 | ||
383 | if (copy_to_user(ip, &ghd, sizeof(ghd))) | 385 | if (copy_to_user(ip, &ghd, sizeof(ghd))) |
384 | return -EFAULT; | 386 | return -EFAULT; |
385 | 387 | ||
386 | return 0; | 388 | return 0; |
387 | } else if (cmd == GPIOHANDLE_SET_LINE_VALUES_IOCTL) { | 389 | } else if (cmd == GPIOHANDLE_SET_LINE_VALUES_IOCTL) { |
388 | int vals[GPIOHANDLES_MAX]; | ||
389 | |||
390 | /* TODO: check if descriptors are really output */ | 390 | /* TODO: check if descriptors are really output */ |
391 | if (copy_from_user(&ghd, ip, sizeof(ghd))) | 391 | if (copy_from_user(&ghd, ip, sizeof(ghd))) |
392 | return -EFAULT; | 392 | return -EFAULT; |
@@ -2466,6 +2466,71 @@ static int gpiod_get_raw_value_commit(const struct gpio_desc *desc) | |||
2466 | return value; | 2466 | return value; |
2467 | } | 2467 | } |
2468 | 2468 | ||
2469 | static int gpio_chip_get_multiple(struct gpio_chip *chip, | ||
2470 | unsigned long *mask, unsigned long *bits) | ||
2471 | { | ||
2472 | if (chip->get_multiple) { | ||
2473 | return chip->get_multiple(chip, mask, bits); | ||
2474 | } else if (chip->get) { | ||
2475 | int i, value; | ||
2476 | |||
2477 | for_each_set_bit(i, mask, chip->ngpio) { | ||
2478 | value = chip->get(chip, i); | ||
2479 | if (value < 0) | ||
2480 | return value; | ||
2481 | __assign_bit(i, bits, value); | ||
2482 | } | ||
2483 | return 0; | ||
2484 | } | ||
2485 | return -EIO; | ||
2486 | } | ||
2487 | |||
2488 | int gpiod_get_array_value_complex(bool raw, bool can_sleep, | ||
2489 | unsigned int array_size, | ||
2490 | struct gpio_desc **desc_array, | ||
2491 | int *value_array) | ||
2492 | { | ||
2493 | int i = 0; | ||
2494 | |||
2495 | while (i < array_size) { | ||
2496 | struct gpio_chip *chip = desc_array[i]->gdev->chip; | ||
2497 | unsigned long mask[BITS_TO_LONGS(chip->ngpio)]; | ||
2498 | unsigned long bits[BITS_TO_LONGS(chip->ngpio)]; | ||
2499 | int first, j, ret; | ||
2500 | |||
2501 | if (!can_sleep) | ||
2502 | WARN_ON(chip->can_sleep); | ||
2503 | |||
2504 | /* collect all inputs belonging to the same chip */ | ||
2505 | first = i; | ||
2506 | memset(mask, 0, sizeof(mask)); | ||
2507 | do { | ||
2508 | const struct gpio_desc *desc = desc_array[i]; | ||
2509 | int hwgpio = gpio_chip_hwgpio(desc); | ||
2510 | |||
2511 | __set_bit(hwgpio, mask); | ||
2512 | i++; | ||
2513 | } while ((i < array_size) && | ||
2514 | (desc_array[i]->gdev->chip == chip)); | ||
2515 | |||
2516 | ret = gpio_chip_get_multiple(chip, mask, bits); | ||
2517 | if (ret) | ||
2518 | return ret; | ||
2519 | |||
2520 | for (j = first; j < i; j++) { | ||
2521 | const struct gpio_desc *desc = desc_array[j]; | ||
2522 | int hwgpio = gpio_chip_hwgpio(desc); | ||
2523 | int value = test_bit(hwgpio, bits); | ||
2524 | |||
2525 | if (!raw && test_bit(FLAG_ACTIVE_LOW, &desc->flags)) | ||
2526 | value = !value; | ||
2527 | value_array[j] = value; | ||
2528 | trace_gpio_value(desc_to_gpio(desc), 1, value); | ||
2529 | } | ||
2530 | } | ||
2531 | return 0; | ||
2532 | } | ||
2533 | |||
2469 | /** | 2534 | /** |
2470 | * gpiod_get_raw_value() - return a gpio's raw value | 2535 | * gpiod_get_raw_value() - return a gpio's raw value |
2471 | * @desc: gpio whose value will be returned | 2536 | * @desc: gpio whose value will be returned |
@@ -2514,6 +2579,51 @@ int gpiod_get_value(const struct gpio_desc *desc) | |||
2514 | } | 2579 | } |
2515 | EXPORT_SYMBOL_GPL(gpiod_get_value); | 2580 | EXPORT_SYMBOL_GPL(gpiod_get_value); |
2516 | 2581 | ||
2582 | /** | ||
2583 | * gpiod_get_raw_array_value() - read raw values from an array of GPIOs | ||
2584 | * @array_size: number of elements in the descriptor / value arrays | ||
2585 | * @desc_array: array of GPIO descriptors whose values will be read | ||
2586 | * @value_array: array to store the read values | ||
2587 | * | ||
2588 | * Read the raw values of the GPIOs, i.e. the values of the physical lines | ||
2589 | * without regard for their ACTIVE_LOW status. Return 0 in case of success, | ||
2590 | * else an error code. | ||
2591 | * | ||
2592 | * This function should be called from contexts where we cannot sleep, | ||
2593 | * and it will complain if the GPIO chip functions potentially sleep. | ||
2594 | */ | ||
2595 | int gpiod_get_raw_array_value(unsigned int array_size, | ||
2596 | struct gpio_desc **desc_array, int *value_array) | ||
2597 | { | ||
2598 | if (!desc_array) | ||
2599 | return -EINVAL; | ||
2600 | return gpiod_get_array_value_complex(true, false, array_size, | ||
2601 | desc_array, value_array); | ||
2602 | } | ||
2603 | EXPORT_SYMBOL_GPL(gpiod_get_raw_array_value); | ||
2604 | |||
2605 | /** | ||
2606 | * gpiod_get_array_value() - read values from an array of GPIOs | ||
2607 | * @array_size: number of elements in the descriptor / value arrays | ||
2608 | * @desc_array: array of GPIO descriptors whose values will be read | ||
2609 | * @value_array: array to store the read values | ||
2610 | * | ||
2611 | * Read the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status | ||
2612 | * into account. Return 0 in case of success, else an error code. | ||
2613 | * | ||
2614 | * This function should be called from contexts where we cannot sleep, | ||
2615 | * and it will complain if the GPIO chip functions potentially sleep. | ||
2616 | */ | ||
2617 | int gpiod_get_array_value(unsigned int array_size, | ||
2618 | struct gpio_desc **desc_array, int *value_array) | ||
2619 | { | ||
2620 | if (!desc_array) | ||
2621 | return -EINVAL; | ||
2622 | return gpiod_get_array_value_complex(false, false, array_size, | ||
2623 | desc_array, value_array); | ||
2624 | } | ||
2625 | EXPORT_SYMBOL_GPL(gpiod_get_array_value); | ||
2626 | |||
2517 | /* | 2627 | /* |
2518 | * gpio_set_open_drain_value_commit() - Set the open drain gpio's value. | 2628 | * gpio_set_open_drain_value_commit() - Set the open drain gpio's value. |
2519 | * @desc: gpio descriptor whose state need to be set. | 2629 | * @desc: gpio descriptor whose state need to be set. |
@@ -2943,6 +3053,53 @@ int gpiod_get_value_cansleep(const struct gpio_desc *desc) | |||
2943 | EXPORT_SYMBOL_GPL(gpiod_get_value_cansleep); | 3053 | EXPORT_SYMBOL_GPL(gpiod_get_value_cansleep); |
2944 | 3054 | ||
2945 | /** | 3055 | /** |
3056 | * gpiod_get_raw_array_value_cansleep() - read raw values from an array of GPIOs | ||
3057 | * @array_size: number of elements in the descriptor / value arrays | ||
3058 | * @desc_array: array of GPIO descriptors whose values will be read | ||
3059 | * @value_array: array to store the read values | ||
3060 | * | ||
3061 | * Read the raw values of the GPIOs, i.e. the values of the physical lines | ||
3062 | * without regard for their ACTIVE_LOW status. Return 0 in case of success, | ||
3063 | * else an error code. | ||
3064 | * | ||
3065 | * This function is to be called from contexts that can sleep. | ||
3066 | */ | ||
3067 | int gpiod_get_raw_array_value_cansleep(unsigned int array_size, | ||
3068 | struct gpio_desc **desc_array, | ||
3069 | int *value_array) | ||
3070 | { | ||
3071 | might_sleep_if(extra_checks); | ||
3072 | if (!desc_array) | ||
3073 | return -EINVAL; | ||
3074 | return gpiod_get_array_value_complex(true, true, array_size, | ||
3075 | desc_array, value_array); | ||
3076 | } | ||
3077 | EXPORT_SYMBOL_GPL(gpiod_get_raw_array_value_cansleep); | ||
3078 | |||
3079 | /** | ||
3080 | * gpiod_get_array_value_cansleep() - read values from an array of GPIOs | ||
3081 | * @array_size: number of elements in the descriptor / value arrays | ||
3082 | * @desc_array: array of GPIO descriptors whose values will be read | ||
3083 | * @value_array: array to store the read values | ||
3084 | * | ||
3085 | * Read the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status | ||
3086 | * into account. Return 0 in case of success, else an error code. | ||
3087 | * | ||
3088 | * This function is to be called from contexts that can sleep. | ||
3089 | */ | ||
3090 | int gpiod_get_array_value_cansleep(unsigned int array_size, | ||
3091 | struct gpio_desc **desc_array, | ||
3092 | int *value_array) | ||
3093 | { | ||
3094 | might_sleep_if(extra_checks); | ||
3095 | if (!desc_array) | ||
3096 | return -EINVAL; | ||
3097 | return gpiod_get_array_value_complex(false, true, array_size, | ||
3098 | desc_array, value_array); | ||
3099 | } | ||
3100 | EXPORT_SYMBOL_GPL(gpiod_get_array_value_cansleep); | ||
3101 | |||
3102 | /** | ||
2946 | * gpiod_set_raw_value_cansleep() - assign a gpio's raw value | 3103 | * gpiod_set_raw_value_cansleep() - assign a gpio's raw value |
2947 | * @desc: gpio whose value will be assigned | 3104 | * @desc: gpio whose value will be assigned |
2948 | * @value: value to assign | 3105 | * @value: value to assign |
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index d003ccb12781..10a48caf8477 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h | |||
@@ -180,6 +180,10 @@ static inline bool acpi_can_fallback_to_crs(struct acpi_device *adev, | |||
180 | #endif | 180 | #endif |
181 | 181 | ||
182 | struct gpio_desc *gpiochip_get_desc(struct gpio_chip *chip, u16 hwnum); | 182 | struct gpio_desc *gpiochip_get_desc(struct gpio_chip *chip, u16 hwnum); |
183 | int gpiod_get_array_value_complex(bool raw, bool can_sleep, | ||
184 | unsigned int array_size, | ||
185 | struct gpio_desc **desc_array, | ||
186 | int *value_array); | ||
183 | void gpiod_set_array_value_complex(bool raw, bool can_sleep, | 187 | void gpiod_set_array_value_complex(bool raw, bool can_sleep, |
184 | unsigned int array_size, | 188 | unsigned int array_size, |
185 | struct gpio_desc **desc_array, | 189 | struct gpio_desc **desc_array, |
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 8f702fcbe485..d4920ec1f1da 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h | |||
@@ -99,10 +99,15 @@ int gpiod_direction_output_raw(struct gpio_desc *desc, int value); | |||
99 | 99 | ||
100 | /* Value get/set from non-sleeping context */ | 100 | /* Value get/set from non-sleeping context */ |
101 | int gpiod_get_value(const struct gpio_desc *desc); | 101 | int gpiod_get_value(const struct gpio_desc *desc); |
102 | int gpiod_get_array_value(unsigned int array_size, | ||
103 | struct gpio_desc **desc_array, int *value_array); | ||
102 | void gpiod_set_value(struct gpio_desc *desc, int value); | 104 | void gpiod_set_value(struct gpio_desc *desc, int value); |
103 | void gpiod_set_array_value(unsigned int array_size, | 105 | void gpiod_set_array_value(unsigned int array_size, |
104 | struct gpio_desc **desc_array, int *value_array); | 106 | struct gpio_desc **desc_array, int *value_array); |
105 | int gpiod_get_raw_value(const struct gpio_desc *desc); | 107 | int gpiod_get_raw_value(const struct gpio_desc *desc); |
108 | int gpiod_get_raw_array_value(unsigned int array_size, | ||
109 | struct gpio_desc **desc_array, | ||
110 | int *value_array); | ||
106 | void gpiod_set_raw_value(struct gpio_desc *desc, int value); | 111 | void gpiod_set_raw_value(struct gpio_desc *desc, int value); |
107 | void gpiod_set_raw_array_value(unsigned int array_size, | 112 | void gpiod_set_raw_array_value(unsigned int array_size, |
108 | struct gpio_desc **desc_array, | 113 | struct gpio_desc **desc_array, |
@@ -110,11 +115,17 @@ void gpiod_set_raw_array_value(unsigned int array_size, | |||
110 | 115 | ||
111 | /* Value get/set from sleeping context */ | 116 | /* Value get/set from sleeping context */ |
112 | int gpiod_get_value_cansleep(const struct gpio_desc *desc); | 117 | int gpiod_get_value_cansleep(const struct gpio_desc *desc); |
118 | int gpiod_get_array_value_cansleep(unsigned int array_size, | ||
119 | struct gpio_desc **desc_array, | ||
120 | int *value_array); | ||
113 | void gpiod_set_value_cansleep(struct gpio_desc *desc, int value); | 121 | void gpiod_set_value_cansleep(struct gpio_desc *desc, int value); |
114 | void gpiod_set_array_value_cansleep(unsigned int array_size, | 122 | void gpiod_set_array_value_cansleep(unsigned int array_size, |
115 | struct gpio_desc **desc_array, | 123 | struct gpio_desc **desc_array, |
116 | int *value_array); | 124 | int *value_array); |
117 | int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc); | 125 | int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc); |
126 | int gpiod_get_raw_array_value_cansleep(unsigned int array_size, | ||
127 | struct gpio_desc **desc_array, | ||
128 | int *value_array); | ||
118 | void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value); | 129 | void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value); |
119 | void gpiod_set_raw_array_value_cansleep(unsigned int array_size, | 130 | void gpiod_set_raw_array_value_cansleep(unsigned int array_size, |
120 | struct gpio_desc **desc_array, | 131 | struct gpio_desc **desc_array, |
@@ -305,6 +316,14 @@ static inline int gpiod_get_value(const struct gpio_desc *desc) | |||
305 | WARN_ON(1); | 316 | WARN_ON(1); |
306 | return 0; | 317 | return 0; |
307 | } | 318 | } |
319 | static inline int gpiod_get_array_value(unsigned int array_size, | ||
320 | struct gpio_desc **desc_array, | ||
321 | int *value_array) | ||
322 | { | ||
323 | /* GPIO can never have been requested */ | ||
324 | WARN_ON(1); | ||
325 | return 0; | ||
326 | } | ||
308 | static inline void gpiod_set_value(struct gpio_desc *desc, int value) | 327 | static inline void gpiod_set_value(struct gpio_desc *desc, int value) |
309 | { | 328 | { |
310 | /* GPIO can never have been requested */ | 329 | /* GPIO can never have been requested */ |
@@ -323,6 +342,14 @@ static inline int gpiod_get_raw_value(const struct gpio_desc *desc) | |||
323 | WARN_ON(1); | 342 | WARN_ON(1); |
324 | return 0; | 343 | return 0; |
325 | } | 344 | } |
345 | static inline int gpiod_get_raw_array_value(unsigned int array_size, | ||
346 | struct gpio_desc **desc_array, | ||
347 | int *value_array) | ||
348 | { | ||
349 | /* GPIO can never have been requested */ | ||
350 | WARN_ON(1); | ||
351 | return 0; | ||
352 | } | ||
326 | static inline void gpiod_set_raw_value(struct gpio_desc *desc, int value) | 353 | static inline void gpiod_set_raw_value(struct gpio_desc *desc, int value) |
327 | { | 354 | { |
328 | /* GPIO can never have been requested */ | 355 | /* GPIO can never have been requested */ |
@@ -342,6 +369,14 @@ static inline int gpiod_get_value_cansleep(const struct gpio_desc *desc) | |||
342 | WARN_ON(1); | 369 | WARN_ON(1); |
343 | return 0; | 370 | return 0; |
344 | } | 371 | } |
372 | static inline int gpiod_get_array_value_cansleep(unsigned int array_size, | ||
373 | struct gpio_desc **desc_array, | ||
374 | int *value_array) | ||
375 | { | ||
376 | /* GPIO can never have been requested */ | ||
377 | WARN_ON(1); | ||
378 | return 0; | ||
379 | } | ||
345 | static inline void gpiod_set_value_cansleep(struct gpio_desc *desc, int value) | 380 | static inline void gpiod_set_value_cansleep(struct gpio_desc *desc, int value) |
346 | { | 381 | { |
347 | /* GPIO can never have been requested */ | 382 | /* GPIO can never have been requested */ |
@@ -360,6 +395,14 @@ static inline int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc) | |||
360 | WARN_ON(1); | 395 | WARN_ON(1); |
361 | return 0; | 396 | return 0; |
362 | } | 397 | } |
398 | static inline int gpiod_get_raw_array_value_cansleep(unsigned int array_size, | ||
399 | struct gpio_desc **desc_array, | ||
400 | int *value_array) | ||
401 | { | ||
402 | /* GPIO can never have been requested */ | ||
403 | WARN_ON(1); | ||
404 | return 0; | ||
405 | } | ||
363 | static inline void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, | 406 | static inline void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, |
364 | int value) | 407 | int value) |
365 | { | 408 | { |
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, |