summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2020-06-20 23:15:07 +0200
committerLinus Walleij <linus.walleij@linaro.org>2020-06-20 23:15:07 +0200
commit435fda26d70379ccb272b880d2e43bff79fcba27 (patch)
treeea5d480d9cdeb4982868ae692bc350377b1f0dc4 /include
parentb1a05ba9ae8cf6592e1d1f3e7b03bf8e5863f75f (diff)
parent5bae1f08e2853d17ce2ceeca71fe5a3ee03a0a69 (diff)
downloadcachepc-linux-435fda26d70379ccb272b880d2e43bff79fcba27.tar.gz
cachepc-linux-435fda26d70379ccb272b880d2e43bff79fcba27.zip
Merge branch 'ib-for-each-requested' of /home/linus/linux-gpio into devel
Diffstat (limited to 'include')
-rw-r--r--include/linux/gpio/driver.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index c4f272af7af5..11cdcb195635 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -474,6 +474,22 @@ struct gpio_chip {
extern const char *gpiochip_is_requested(struct gpio_chip *gc,
unsigned int offset);
+/**
+ * for_each_requested_gpio_in_range - iterates over requested GPIOs in a given range
+ * @chip: the chip to query
+ * @i: loop variable
+ * @base: first GPIO in the range
+ * @size: amount of GPIOs to check starting from @base
+ * @label: label of current GPIO
+ */
+#define for_each_requested_gpio_in_range(chip, i, base, size, label) \
+ for (i = 0; i < size; i++) \
+ if ((label = gpiochip_is_requested(chip, base + i)) == NULL) {} else
+
+/* Iterates over all requested GPIO of the given @chip */
+#define for_each_requested_gpio(chip, i, label) \
+ for_each_requested_gpio_in_range(chip, i, 0, chip->ngpio, label)
+
/* add/remove chips */
extern int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
struct lock_class_key *lock_key,