[PATCH v1 1/4] gpio: Split fwnode_is_gpiochip() helper

From: Andy Shevchenko

Date: Mon Aug 24 2026 - 03:52:01 EST


Many drivers repeat the same over and over. For clarity and robustness
split fwnode_is_gpiochip() helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
include/linux/gpio/driver.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 2ea21341adea..06d40fb77a73 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -879,9 +879,14 @@ static inline void gpiochip_unlock_as_irq(struct gpio_chip *gc,
}
#endif /* CONFIG_GPIOLIB */

+static inline bool fwnode_is_gpiochip(struct fwnode_handle *fwnode)
+{
+ return fwnode_property_present(child, "gpio-controller");
+}
+
#define for_each_gpiochip_node(dev, child) \
device_for_each_child_node(dev, child) \
- for_each_if(fwnode_property_present(child, "gpio-controller"))
+ for_each_if(fwnode_is_gpiochip(child))

static inline unsigned int gpiochip_node_count(struct device *dev)
{
--
2.50.1