public inbox for linux-gpio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: introduce a header for symbols shared by suppliers and consumers
@ 2026-02-23 17:20 Bartosz Golaszewski
  2026-02-23 17:59 ` Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23 17:20 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

GPIO_LINE_DIRECTION_IN/OUT definitions are used both in supplier (GPIO
controller drivers) as well as consumer code. In order to not force the
consumers to include gpio/driver.h or - even worse - to redefine these
values, create a new header file - gpio/defs.h - and move them over
there. Include this header from both gpio/consumer.h and gpio/driver.h.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Andy, Linus: I'm no longer sure who proposed it but I've had it on my
TODO list. Please feel free to take credit below.

 include/linux/gpio/consumer.h | 2 ++
 include/linux/gpio/defs.h     | 9 +++++++++
 include/linux/gpio/driver.h   | 5 ++---
 3 files changed, 13 insertions(+), 3 deletions(-)
 create mode 100644 include/linux/gpio/defs.h

diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 0d84085829186..3efb5cb1e1d16 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -6,6 +6,8 @@
 #include <linux/err.h>
 #include <linux/types.h>
 
+#include "defs.h"
+
 struct acpi_device;
 struct device;
 struct fwnode_handle;
diff --git a/include/linux/gpio/defs.h b/include/linux/gpio/defs.h
new file mode 100644
index 0000000000000..b69fd7c041b28
--- /dev/null
+++ b/include/linux/gpio/defs.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __LINUX_GPIO_DEFS_H
+#define __LINUX_GPIO_DEFS_H
+
+#define GPIO_LINE_DIRECTION_IN		1
+#define GPIO_LINE_DIRECTION_OUT		0
+
+#endif /* __LINUX_GPIO_DEFS_H */
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index fabe2baf7b509..5f5ddcbfa4459 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -20,6 +20,8 @@
 #include <asm/msi.h>
 #endif
 
+#include "defs.h"
+
 struct device;
 struct irq_chip;
 struct irq_data;
@@ -42,9 +44,6 @@ union gpio_irq_fwspec {
 #endif
 };
 
-#define GPIO_LINE_DIRECTION_IN	1
-#define GPIO_LINE_DIRECTION_OUT	0
-
 /**
  * struct gpio_irq_chip - GPIO interrupt controller
  */
-- 
2.47.3


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

* Re: [PATCH] gpio: introduce a header for symbols shared by suppliers and consumers
  2026-02-23 17:20 [PATCH] gpio: introduce a header for symbols shared by suppliers and consumers Bartosz Golaszewski
@ 2026-02-23 17:59 ` Andy Shevchenko
  2026-02-24  9:49 ` Linus Walleij
  2026-02-27  8:58 ` Bartosz Golaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-02-23 17:59 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel

On Mon, Feb 23, 2026 at 06:20:06PM +0100, Bartosz Golaszewski wrote:
> GPIO_LINE_DIRECTION_IN/OUT definitions are used both in supplier (GPIO
> controller drivers) as well as consumer code. In order to not force the
> consumers to include gpio/driver.h or - even worse - to redefine these
> values, create a new header file - gpio/defs.h - and move them over
> there. Include this header from both gpio/consumer.h and gpio/driver.h.

It was discussed before off the list, but I agree with the direction it goes.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
> Andy, Linus: I'm no longer sure who proposed it but I've had it on my
> TODO list. Please feel free to take credit below.

I believe both, I added mine above.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] gpio: introduce a header for symbols shared by suppliers and consumers
  2026-02-23 17:20 [PATCH] gpio: introduce a header for symbols shared by suppliers and consumers Bartosz Golaszewski
  2026-02-23 17:59 ` Andy Shevchenko
@ 2026-02-24  9:49 ` Linus Walleij
  2026-02-27  8:58 ` Bartosz Golaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2026-02-24  9:49 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Andy Shevchenko, Bartosz Golaszewski, linux-gpio, linux-kernel

On Mon, Feb 23, 2026 at 6:20 PM Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:

> GPIO_LINE_DIRECTION_IN/OUT definitions are used both in supplier (GPIO
> controller drivers) as well as consumer code. In order to not force the
> consumers to include gpio/driver.h or - even worse - to redefine these
> values, create a new header file - gpio/defs.h - and move them over
> there. Include this header from both gpio/consumer.h and gpio/driver.h.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
> Andy, Linus: I'm no longer sure who proposed it but I've had it on my
> TODO list. Please feel free to take credit below.

I'm just happy it happens, I ran into the problem.
Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij

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

* Re: [PATCH] gpio: introduce a header for symbols shared by suppliers and consumers
  2026-02-23 17:20 [PATCH] gpio: introduce a header for symbols shared by suppliers and consumers Bartosz Golaszewski
  2026-02-23 17:59 ` Andy Shevchenko
  2026-02-24  9:49 ` Linus Walleij
@ 2026-02-27  8:58 ` Bartosz Golaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2026-02-27  8:58 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, Bartosz Golaszewski,
	Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel


On Mon, 23 Feb 2026 18:20:06 +0100, Bartosz Golaszewski wrote:
> GPIO_LINE_DIRECTION_IN/OUT definitions are used both in supplier (GPIO
> controller drivers) as well as consumer code. In order to not force the
> consumers to include gpio/driver.h or - even worse - to redefine these
> values, create a new header file - gpio/defs.h - and move them over
> there. Include this header from both gpio/consumer.h and gpio/driver.h.
> 
> 
> [...]

Applied, thanks!

[1/1] gpio: introduce a header for symbols shared by suppliers and consumers
      https://git.kernel.org/brgl/c/fa4a3a95139e7293c1333a33bd7b19e7261e3bd0

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

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

end of thread, other threads:[~2026-02-27  8:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23 17:20 [PATCH] gpio: introduce a header for symbols shared by suppliers and consumers Bartosz Golaszewski
2026-02-23 17:59 ` Andy Shevchenko
2026-02-24  9:49 ` Linus Walleij
2026-02-27  8:58 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox