gpiolib: Introduce a helper to get first GPIO controller node
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 14 Apr 2022 18:42:48 +0000 (21:42 +0300)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 14 Apr 2022 18:47:29 +0000 (21:47 +0300)
Introduce a helper to get first GPIO controller node which drivers
may want to use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
include/linux/gpio/driver.h

index 12de0b2..83e2d72 100644 (file)
@@ -766,4 +766,14 @@ static inline unsigned int gpiochip_node_count(struct device *dev)
        return count;
 }
 
+static inline struct fwnode_handle *gpiochip_node_get_first(struct device *dev)
+{
+       struct fwnode_handle *fwnode;
+
+       for_each_gpiochip_node(dev, fwnode)
+               return fwnode;
+
+       return NULL;
+}
+
 #endif /* __LINUX_GPIO_DRIVER_H */