]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gpio: Add fwnode_gpiod_get() helper
authorKrishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
Mon, 11 May 2026 07:25:37 +0000 (12:55 +0530)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Mon, 11 May 2026 10:57:48 +0000 (12:57 +0200)
Add fwnode_gpiod_get() as a convenience wrapper around
fwnode_gpiod_get_index() for the common case where only the
first GPIO is required.

This mirrors existing gpiod_get() and devm_gpiod_get() helpers
and avoids open-coding index 0 at call sites.

Suggested-by: Manivannan Sadhasivam <mani@kernel.org>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
Link: https://patch.msgid.link/20260511-wakeirq_support-v10-1-c10af9c9eb8c@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
include/linux/gpio/consumer.h

index 3efb5cb1e1d16eafaff78a4e9879a431b9d0b55f..e2601217a71d6b27df02720861626b80e22a82be 100644 (file)
@@ -598,6 +598,15 @@ static inline int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc,
 }
 #endif /* CONFIG_GPIOLIB && CONFIG_HTE */
 
+static inline
+struct gpio_desc *fwnode_gpiod_get(struct fwnode_handle *fwnode,
+                                  const char *con_id,
+                                  enum gpiod_flags flags,
+                                  const char *label)
+{
+       return fwnode_gpiod_get_index(fwnode, con_id, 0, flags, label);
+}
+
 static inline
 struct gpio_desc *devm_fwnode_gpiod_get(struct device *dev,
                                        struct fwnode_handle *fwnode,