linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] gpiolib: Add for_each_gpio_suffix() helper
@ 2019-08-08 13:25 Stefan Roese
  2019-08-08 13:25 ` [PATCH 2/2] serial: mctrl_gpio: Support all GPIO suffixes (gpios vs gpio) Stefan Roese
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Stefan Roese @ 2019-08-08 13:25 UTC (permalink / raw)
  To: linux-serial, linux-gpio
  Cc: Andy Shevchenko, Geert Uytterhoeven, Pavel Machek, Linus Walleij,
	Greg Kroah-Hartman

Add a helper macro to enable the interation over all supported GPIO
suffixes (currently "gpios" & "gpio"). This will be used by the serial
mctrl code to check, if a GPIO property exists before requesting it.

Signed-off-by: Stefan Roese <sr@denx.de>
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Pavel Machek <pavel@denx.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpio/gpiolib.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
index 7c52c2442173..a3add73f99d6 100644
--- a/drivers/gpio/gpiolib.h
+++ b/drivers/gpio/gpiolib.h
@@ -92,6 +92,12 @@ struct acpi_gpio_info {
 /* gpio suffixes used for ACPI and device tree lookup */
 static __maybe_unused const char * const gpio_suffixes[] = { "gpios", "gpio" };
 
+#define for_each_gpio_suffix(idx, suffix)				\
+	for (idx = 0;							\
+	     idx < ARRAY_SIZE(gpio_suffixes) &&				\
+		     (suffix = gpio_suffixes[idx]) != NULL;		\
+	     idx++)
+
 #ifdef CONFIG_OF_GPIO
 struct gpio_desc *of_find_gpio(struct device *dev,
 			       const char *con_id,
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-08-14 13:38 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-08 13:25 [PATCH 1/2] gpiolib: Add for_each_gpio_suffix() helper Stefan Roese
2019-08-08 13:25 ` [PATCH 2/2] serial: mctrl_gpio: Support all GPIO suffixes (gpios vs gpio) Stefan Roese
2019-08-08 13:48   ` Andy Shevchenko
2019-08-08 13:59     ` Stefan Roese
2019-08-12 10:53       ` Andy Shevchenko
2019-08-13 11:42         ` Pavel Machek
2019-08-13 12:15           ` Andy Shevchenko
2019-08-12 11:17   ` Geert Uytterhoeven
2019-08-12 11:53     ` Stefan Roese
2019-08-12 12:11       ` Geert Uytterhoeven
2019-08-12 12:31         ` Andy Shevchenko
2019-08-08 13:44 ` [PATCH 1/2] gpiolib: Add for_each_gpio_suffix() helper Andy Shevchenko
2019-08-08 14:13   ` Stefan Roese
2019-08-10  8:27 ` Linus Walleij
2019-08-10  8:48   ` Greg Kroah-Hartman
2019-08-12 11:18   ` Geert Uytterhoeven
2019-08-14  8:48     ` Linus Walleij
2019-08-14 13:17       ` Stefan Roese
2019-08-14 13:32         ` Geert Uytterhoeven
2019-08-14 13:38         ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).