summaryrefslogtreecommitdiff
path: root/include/linux/gpio/driver.h
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>2023-09-27 16:29:22 +0200
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>2023-10-04 13:29:16 +0200
commit9e4555d1e54a18946d7ca363b9fc8ed1fe7dfde4 (patch)
tree798bd9cd20a12752d6682bf37432c00e75855154 /include/linux/gpio/driver.h
parent36aa129f221c9070afd8dff03154ab49702a5b1b (diff)
gpiolib: add support for scope-based management to gpio_device
As the few users that need to get the reference to the GPIO device often release it right after inspecting its properties, let's add support for the automatic reference release to struct gpio_device. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'include/linux/gpio/driver.h')
-rw-r--r--include/linux/gpio/driver.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index a2060dc3344b..1cedbc3d3200 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -3,6 +3,8 @@
#define __LINUX_GPIO_DRIVER_H
#include <linux/bits.h>
+#include <linux/cleanup.h>
+#include <linux/err.h>
#include <linux/irqchip/chained_irq.h>
#include <linux/irqdomain.h>
#include <linux/irqhandler.h>
@@ -609,6 +611,9 @@ struct gpio_chip *gpiochip_find(void *data,
struct gpio_device *gpio_device_get(struct gpio_device *gdev);
void gpio_device_put(struct gpio_device *gdev);
+DEFINE_FREE(gpio_device_put, struct gpio_device *,
+ if (IS_ERR_OR_NULL(_T)) gpio_device_put(_T));
+
bool gpiochip_line_is_irq(struct gpio_chip *gc, unsigned int offset);
int gpiochip_reqres_irq(struct gpio_chip *gc, unsigned int offset);
void gpiochip_relres_irq(struct gpio_chip *gc, unsigned int offset);