All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/12] gpiolib cleanups
@ 2023-02-07 14:29 ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Bartosz Golaszewski, Jonathan Corbet, Alex Shi, Yanteng Si,
	Hu Haowen, Russell King, Aaro Koskinen, Janusz Krzysztofik,
	Andrew Lunn, Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand

These are some older patches Arnd did last year, rebased to
linux-next-20230207. On top there are Andy's patches regarding
similar topic.

The main goal is to remove some of the legacy bits of the gpiolib
interfaces, where the corner cases are easily avoided or replaced
with gpio descriptor based interfaces.

Changes in v3:
- reworked touchscreen patch in accordance with Dmitry's comments
- rebased on the latest Linux Next
- added on top Andy's series

Changes in v2:
- dropped patch 8 after Andy's identical patch was merged
- rebase on latest gpio tree
- leave unused gpio_cansleep() in place for now
- address feedback from Andy Shevchenko

Andy Shevchenko (5):
  gpio: aggregator: Add missing header(s)
  gpiolib: Drop unused forward declaration from driver.h
  gpiolib: Deduplicate forward declarations in consumer.h
  gpiolib: Group forward declarations in consumer.h
  gpiolib: Clean up headers

Arnd Bergmann (7):
  gpiolib: remove empty asm/gpio.h files
  gpiolib: coldfire: remove custom asm/gpio.h
  gpiolib: remove asm-generic/gpio.h
  gpiolib: remove gpio_set_debounce
  gpiolib: remove legacy gpio_export
  gpiolib: split linux/gpio/driver.h out of linux/gpio.h
  gpiolib: split of_mm_gpio_chip out of linux/of_gpio.h

 Documentation/admin-guide/gpio/sysfs.rst      |   2 +-
 Documentation/driver-api/gpio/legacy.rst      |  23 ---
 .../zh_CN/driver-api/gpio/legacy.rst          |  20 ---
 Documentation/translations/zh_TW/gpio.txt     |  19 ---
 MAINTAINERS                                   |   1 -
 arch/arm/Kconfig                              |   1 -
 arch/arm/include/asm/gpio.h                   |  21 ---
 arch/arm/mach-omap1/irq.c                     |   1 +
 arch/arm/mach-omap2/pdata-quirks.c            |   9 +-
 arch/arm/mach-orion5x/board-rd88f5182.c       |   1 +
 arch/arm/mach-s3c/s3c64xx.c                   |   1 +
 arch/arm/mach-sa1100/assabet.c                |   1 +
 arch/arm/plat-orion/gpio.c                    |   1 +
 arch/m68k/Kconfig.cpu                         |   1 -
 arch/m68k/include/asm/gpio.h                  |  95 -----------
 arch/m68k/include/asm/mcfgpio.h               |   2 +-
 arch/powerpc/platforms/44x/Kconfig            |   1 +
 arch/powerpc/platforms/4xx/gpio.c             |   2 +-
 arch/powerpc/platforms/8xx/Kconfig            |   1 +
 arch/powerpc/platforms/8xx/cpm1.c             |   2 +-
 arch/powerpc/platforms/Kconfig                |   2 +
 arch/powerpc/sysdev/cpm_common.c              |   2 +-
 arch/sh/Kconfig                               |   1 -
 arch/sh/boards/board-magicpanelr2.c           |   1 +
 arch/sh/boards/mach-ap325rxa/setup.c          |   7 +-
 arch/sh/include/asm/gpio.h                    |  45 ------
 drivers/gpio/Kconfig                          |  19 ++-
 drivers/gpio/TODO                             |  15 +-
 drivers/gpio/gpio-aggregator.c                |   9 +-
 drivers/gpio/gpio-altera.c                    |   2 +-
 drivers/gpio/gpio-davinci.c                   |   2 -
 drivers/gpio/gpio-mm-lantiq.c                 |   2 +-
 drivers/gpio/gpio-mpc5200.c                   |   2 +-
 drivers/gpio/gpiolib-acpi.c                   |  10 +-
 drivers/gpio/gpiolib-acpi.h                   |   1 -
 drivers/gpio/gpiolib-of.c                     |   9 +-
 drivers/gpio/gpiolib-of.h                     |   1 -
 drivers/gpio/gpiolib-swnode.c                 |   5 +-
 drivers/gpio/gpiolib-sysfs.c                  |  25 ++-
 drivers/gpio/gpiolib.c                        |   9 +-
 drivers/input/touchscreen/ads7846.c           |  24 +--
 drivers/media/pci/sta2x11/sta2x11_vip.c       |  10 +-
 drivers/net/ieee802154/ca8210.c               |   3 +-
 .../broadcom/brcm80211/brcmsmac/led.c         |   1 +
 drivers/pinctrl/core.c                        |   1 -
 drivers/soc/fsl/qe/gpio.c                     |   2 +-
 include/asm-generic/gpio.h                    | 147 ------------------
 include/linux/gpio.h                          | 100 +++++++-----
 include/linux/gpio/consumer.h                 |  24 +--
 include/linux/gpio/driver.h                   |  31 +++-
 .../legacy-of-mm-gpiochip.h}                  |  33 +---
 include/linux/mfd/ucb1x00.h                   |   1 +
 include/linux/of_gpio.h                       |  21 ---
 53 files changed, 223 insertions(+), 549 deletions(-)
 delete mode 100644 arch/arm/include/asm/gpio.h
 delete mode 100644 arch/m68k/include/asm/gpio.h
 delete mode 100644 arch/sh/include/asm/gpio.h
 delete mode 100644 include/asm-generic/gpio.h
 copy include/linux/{of_gpio.h => gpio/legacy-of-mm-gpiochip.h} (50%)

-- 
2.39.1


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

* [PATCH v3 00/12] gpiolib cleanups
@ 2023-02-07 14:29 ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Eric Dumazet,
	Alim Akhtar, Frank Rowand, Alex Shi, Qiang Zhao, Yanteng Si,
	Yoshinori Sato, Jonathan Corbet, Bartosz Golaszewski, Lee Jones,
	Janusz Krzysztofik, Russell King, Jakub Kicinski, Paolo Abeni,
	Sebastian Hesselbarth, Gregory Clement, Kalle Valo,
	Hante Meuleman, Nicholas Piggin, Rob Herring,
	Mauro Carvalho Chehab, Mika Westerberg, Franky Lin,
	Arend van Spriel, Mun Yew Tham, Hu Haowen, Keerthy,
	Aaro Koskinen, Li Yang, David S. Miller

These are some older patches Arnd did last year, rebased to
linux-next-20230207. On top there are Andy's patches regarding
similar topic.

The main goal is to remove some of the legacy bits of the gpiolib
interfaces, where the corner cases are easily avoided or replaced
with gpio descriptor based interfaces.

Changes in v3:
- reworked touchscreen patch in accordance with Dmitry's comments
- rebased on the latest Linux Next
- added on top Andy's series

Changes in v2:
- dropped patch 8 after Andy's identical patch was merged
- rebase on latest gpio tree
- leave unused gpio_cansleep() in place for now
- address feedback from Andy Shevchenko

Andy Shevchenko (5):
  gpio: aggregator: Add missing header(s)
  gpiolib: Drop unused forward declaration from driver.h
  gpiolib: Deduplicate forward declarations in consumer.h
  gpiolib: Group forward declarations in consumer.h
  gpiolib: Clean up headers

Arnd Bergmann (7):
  gpiolib: remove empty asm/gpio.h files
  gpiolib: coldfire: remove custom asm/gpio.h
  gpiolib: remove asm-generic/gpio.h
  gpiolib: remove gpio_set_debounce
  gpiolib: remove legacy gpio_export
  gpiolib: split linux/gpio/driver.h out of linux/gpio.h
  gpiolib: split of_mm_gpio_chip out of linux/of_gpio.h

 Documentation/admin-guide/gpio/sysfs.rst      |   2 +-
 Documentation/driver-api/gpio/legacy.rst      |  23 ---
 .../zh_CN/driver-api/gpio/legacy.rst          |  20 ---
 Documentation/translations/zh_TW/gpio.txt     |  19 ---
 MAINTAINERS                                   |   1 -
 arch/arm/Kconfig                              |   1 -
 arch/arm/include/asm/gpio.h                   |  21 ---
 arch/arm/mach-omap1/irq.c                     |   1 +
 arch/arm/mach-omap2/pdata-quirks.c            |   9 +-
 arch/arm/mach-orion5x/board-rd88f5182.c       |   1 +
 arch/arm/mach-s3c/s3c64xx.c                   |   1 +
 arch/arm/mach-sa1100/assabet.c                |   1 +
 arch/arm/plat-orion/gpio.c                    |   1 +
 arch/m68k/Kconfig.cpu                         |   1 -
 arch/m68k/include/asm/gpio.h                  |  95 -----------
 arch/m68k/include/asm/mcfgpio.h               |   2 +-
 arch/powerpc/platforms/44x/Kconfig            |   1 +
 arch/powerpc/platforms/4xx/gpio.c             |   2 +-
 arch/powerpc/platforms/8xx/Kconfig            |   1 +
 arch/powerpc/platforms/8xx/cpm1.c             |   2 +-
 arch/powerpc/platforms/Kconfig                |   2 +
 arch/powerpc/sysdev/cpm_common.c              |   2 +-
 arch/sh/Kconfig                               |   1 -
 arch/sh/boards/board-magicpanelr2.c           |   1 +
 arch/sh/boards/mach-ap325rxa/setup.c          |   7 +-
 arch/sh/include/asm/gpio.h                    |  45 ------
 drivers/gpio/Kconfig                          |  19 ++-
 drivers/gpio/TODO                             |  15 +-
 drivers/gpio/gpio-aggregator.c                |   9 +-
 drivers/gpio/gpio-altera.c                    |   2 +-
 drivers/gpio/gpio-davinci.c                   |   2 -
 drivers/gpio/gpio-mm-lantiq.c                 |   2 +-
 drivers/gpio/gpio-mpc5200.c                   |   2 +-
 drivers/gpio/gpiolib-acpi.c                   |  10 +-
 drivers/gpio/gpiolib-acpi.h                   |   1 -
 drivers/gpio/gpiolib-of.c                     |   9 +-
 drivers/gpio/gpiolib-of.h                     |   1 -
 drivers/gpio/gpiolib-swnode.c                 |   5 +-
 drivers/gpio/gpiolib-sysfs.c                  |  25 ++-
 drivers/gpio/gpiolib.c                        |   9 +-
 drivers/input/touchscreen/ads7846.c           |  24 +--
 drivers/media/pci/sta2x11/sta2x11_vip.c       |  10 +-
 drivers/net/ieee802154/ca8210.c               |   3 +-
 .../broadcom/brcm80211/brcmsmac/led.c         |   1 +
 drivers/pinctrl/core.c                        |   1 -
 drivers/soc/fsl/qe/gpio.c                     |   2 +-
 include/asm-generic/gpio.h                    | 147 ------------------
 include/linux/gpio.h                          | 100 +++++++-----
 include/linux/gpio/consumer.h                 |  24 +--
 include/linux/gpio/driver.h                   |  31 +++-
 .../legacy-of-mm-gpiochip.h}                  |  33 +---
 include/linux/mfd/ucb1x00.h                   |   1 +
 include/linux/of_gpio.h                       |  21 ---
 53 files changed, 223 insertions(+), 549 deletions(-)
 delete mode 100644 arch/arm/include/asm/gpio.h
 delete mode 100644 arch/m68k/include/asm/gpio.h
 delete mode 100644 arch/sh/include/asm/gpio.h
 delete mode 100644 include/asm-generic/gpio.h
 copy include/linux/{of_gpio.h => gpio/legacy-of-mm-gpiochip.h} (50%)

-- 
2.39.1


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

* [PATCH v3 01/12] gpiolib: remove empty asm/gpio.h files
  2023-02-07 14:29 ` Andy Shevchenko
@ 2023-02-07 14:29   ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Bartosz Golaszewski, Jonathan Corbet, Alex Shi, Yanteng Si,
	Hu Haowen, Russell King, Aaro Koskinen, Janusz Krzysztofik,
	Andrew Lunn, Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand,
	Geert Uytterhoeven

From: Arnd Bergmann <arnd@arndb.de>

The arm and sh versions of this file are identical to the generic
versions and can just be removed.

The drivers that actually use the sh3 specific version also include
cpu/gpio.h directly, with the exception of magicpanelr2, which is
easily fixed. This leaves coldfire as the only gpio driver
that needs something custom for gpiolib.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/arm/Kconfig                    |  1 -
 arch/arm/include/asm/gpio.h         | 21 --------------
 arch/sh/Kconfig                     |  1 -
 arch/sh/boards/board-magicpanelr2.c |  1 +
 arch/sh/include/asm/gpio.h          | 45 -----------------------------
 5 files changed, 1 insertion(+), 68 deletions(-)
 delete mode 100644 arch/arm/include/asm/gpio.h
 delete mode 100644 arch/sh/include/asm/gpio.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e24a9820e12f..1d1a603d964d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -24,7 +24,6 @@ config ARM
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
 	select ARCH_HAS_TEARDOWN_DMA_OPS if MMU
 	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
-	select ARCH_HAVE_CUSTOM_GPIO_H
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG if CPU_V7 || CPU_V7M || CPU_V6K
 	select ARCH_HAS_GCOV_PROFILE_ALL
 	select ARCH_KEEP_MEMBLOCK
diff --git a/arch/arm/include/asm/gpio.h b/arch/arm/include/asm/gpio.h
deleted file mode 100644
index 4ebbb58f06ea..000000000000
--- a/arch/arm/include/asm/gpio.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ARCH_ARM_GPIO_H
-#define _ARCH_ARM_GPIO_H
-
-#include <asm-generic/gpio.h>
-
-/* The trivial gpiolib dispatchers */
-#define gpio_get_value  __gpio_get_value
-#define gpio_set_value  __gpio_set_value
-#define gpio_cansleep   __gpio_cansleep
-
-/*
- * Provide a default gpio_to_irq() which should satisfy every case.
- * However, some platforms want to do this differently, so allow them
- * to override it.
- */
-#ifndef gpio_to_irq
-#define gpio_to_irq	__gpio_to_irq
-#endif
-
-#endif /* _ARCH_ARM_GPIO_H */
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 0665ac0add0b..ccb866750a88 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -4,7 +4,6 @@ config SUPERH
 	select ARCH_32BIT_OFF_T
 	select ARCH_ENABLE_MEMORY_HOTPLUG if SPARSEMEM && MMU
 	select ARCH_ENABLE_MEMORY_HOTREMOVE if SPARSEMEM && MMU
-	select ARCH_HAVE_CUSTOM_GPIO_H
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A)
 	select ARCH_HAS_BINFMT_FLAT if !MMU
 	select ARCH_HAS_CURRENT_STACK_POINTER
diff --git a/arch/sh/boards/board-magicpanelr2.c b/arch/sh/boards/board-magicpanelr2.c
index 56bd386ff3b0..75de893152af 100644
--- a/arch/sh/boards/board-magicpanelr2.c
+++ b/arch/sh/boards/board-magicpanelr2.c
@@ -21,6 +21,7 @@
 #include <linux/sh_intc.h>
 #include <mach/magicpanelr2.h>
 #include <asm/heartbeat.h>
+#include <cpu/gpio.h>
 #include <cpu/sh7720.h>
 
 /* Dummy supplies, where voltage doesn't matter */
diff --git a/arch/sh/include/asm/gpio.h b/arch/sh/include/asm/gpio.h
deleted file mode 100644
index 588c1380e4cb..000000000000
--- a/arch/sh/include/asm/gpio.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0
- *
- *  include/asm-sh/gpio.h
- *
- * Generic GPIO API and pinmux table support for SuperH.
- *
- * Copyright (c) 2008 Magnus Damm
- */
-#ifndef __ASM_SH_GPIO_H
-#define __ASM_SH_GPIO_H
-
-#include <linux/kernel.h>
-#include <linux/errno.h>
-
-#if defined(CONFIG_CPU_SH3)
-#include <cpu/gpio.h>
-#endif
-
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-static inline int gpio_get_value(unsigned gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* __ASM_SH_GPIO_H */
-- 
2.39.1


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

* [PATCH v3 01/12] gpiolib: remove empty asm/gpio.h files
@ 2023-02-07 14:29   ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Geert Uytterhoeven,
	Eric Dumazet, Alim Akhtar, Frank Rowand, Alex Shi, Qiang Zhao,
	Yanteng Si, Yoshinori Sato, Jonathan Corbet, Bartosz Golaszewski,
	Lee Jones, Janusz Krzysztofik, Russell King, Jakub Kicinski,
	Paolo Abeni, Sebastian Hesselbarth, Gregory Clement, Kalle Valo,
	Hante Meuleman, Nicholas Piggin, Rob Herring,
	Mauro Carvalho Chehab, Mika Westerberg, Franky Lin,
	Arend van Spriel, Mun Yew Tham, Hu Haowen, Keerthy,
	Aaro Koskinen, Li Yang, David S. Miller

From: Arnd Bergmann <arnd@arndb.de>

The arm and sh versions of this file are identical to the generic
versions and can just be removed.

The drivers that actually use the sh3 specific version also include
cpu/gpio.h directly, with the exception of magicpanelr2, which is
easily fixed. This leaves coldfire as the only gpio driver
that needs something custom for gpiolib.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/arm/Kconfig                    |  1 -
 arch/arm/include/asm/gpio.h         | 21 --------------
 arch/sh/Kconfig                     |  1 -
 arch/sh/boards/board-magicpanelr2.c |  1 +
 arch/sh/include/asm/gpio.h          | 45 -----------------------------
 5 files changed, 1 insertion(+), 68 deletions(-)
 delete mode 100644 arch/arm/include/asm/gpio.h
 delete mode 100644 arch/sh/include/asm/gpio.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e24a9820e12f..1d1a603d964d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -24,7 +24,6 @@ config ARM
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
 	select ARCH_HAS_TEARDOWN_DMA_OPS if MMU
 	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
-	select ARCH_HAVE_CUSTOM_GPIO_H
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG if CPU_V7 || CPU_V7M || CPU_V6K
 	select ARCH_HAS_GCOV_PROFILE_ALL
 	select ARCH_KEEP_MEMBLOCK
diff --git a/arch/arm/include/asm/gpio.h b/arch/arm/include/asm/gpio.h
deleted file mode 100644
index 4ebbb58f06ea..000000000000
--- a/arch/arm/include/asm/gpio.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ARCH_ARM_GPIO_H
-#define _ARCH_ARM_GPIO_H
-
-#include <asm-generic/gpio.h>
-
-/* The trivial gpiolib dispatchers */
-#define gpio_get_value  __gpio_get_value
-#define gpio_set_value  __gpio_set_value
-#define gpio_cansleep   __gpio_cansleep
-
-/*
- * Provide a default gpio_to_irq() which should satisfy every case.
- * However, some platforms want to do this differently, so allow them
- * to override it.
- */
-#ifndef gpio_to_irq
-#define gpio_to_irq	__gpio_to_irq
-#endif
-
-#endif /* _ARCH_ARM_GPIO_H */
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 0665ac0add0b..ccb866750a88 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -4,7 +4,6 @@ config SUPERH
 	select ARCH_32BIT_OFF_T
 	select ARCH_ENABLE_MEMORY_HOTPLUG if SPARSEMEM && MMU
 	select ARCH_ENABLE_MEMORY_HOTREMOVE if SPARSEMEM && MMU
-	select ARCH_HAVE_CUSTOM_GPIO_H
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A)
 	select ARCH_HAS_BINFMT_FLAT if !MMU
 	select ARCH_HAS_CURRENT_STACK_POINTER
diff --git a/arch/sh/boards/board-magicpanelr2.c b/arch/sh/boards/board-magicpanelr2.c
index 56bd386ff3b0..75de893152af 100644
--- a/arch/sh/boards/board-magicpanelr2.c
+++ b/arch/sh/boards/board-magicpanelr2.c
@@ -21,6 +21,7 @@
 #include <linux/sh_intc.h>
 #include <mach/magicpanelr2.h>
 #include <asm/heartbeat.h>
+#include <cpu/gpio.h>
 #include <cpu/sh7720.h>
 
 /* Dummy supplies, where voltage doesn't matter */
diff --git a/arch/sh/include/asm/gpio.h b/arch/sh/include/asm/gpio.h
deleted file mode 100644
index 588c1380e4cb..000000000000
--- a/arch/sh/include/asm/gpio.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0
- *
- *  include/asm-sh/gpio.h
- *
- * Generic GPIO API and pinmux table support for SuperH.
- *
- * Copyright (c) 2008 Magnus Damm
- */
-#ifndef __ASM_SH_GPIO_H
-#define __ASM_SH_GPIO_H
-
-#include <linux/kernel.h>
-#include <linux/errno.h>
-
-#if defined(CONFIG_CPU_SH3)
-#include <cpu/gpio.h>
-#endif
-
-#include <asm-generic/gpio.h>
-
-#ifdef CONFIG_GPIOLIB
-
-static inline int gpio_get_value(unsigned gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
-#endif /* CONFIG_GPIOLIB */
-
-#endif /* __ASM_SH_GPIO_H */
-- 
2.39.1


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

* [PATCH v3 02/12] gpiolib: coldfire: remove custom asm/gpio.h
  2023-02-07 14:29 ` Andy Shevchenko
@ 2023-02-07 14:29   ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Bartosz Golaszewski, Jonathan Corbet, Alex Shi, Yanteng Si,
	Hu Haowen, Russell King, Aaro Koskinen, Janusz Krzysztofik,
	Andrew Lunn, Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand

From: Arnd Bergmann <arnd@arndb.de>

Now that coldfire is the only user of a custom asm/gpio.h, it seems
better to remove this as well, and have the same interface everywhere.

For the gpio_get_value()/gpio_set_value()/gpio_to_irq(), gpio_cansleep()
functions, the custom version is only a micro-optimization to inline the
function for constant GPIO numbers. However, in the coldfire defconfigs,
I was unable to find a single instance where this micro-optimization
was even used, and according to Geert the only user appears to be the
QSPI chip that is disabled everywhere.

The custom gpio_request_one() function is even less useful, as it is
guarded by an #ifdef that is never true.

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/m68k/Kconfig.cpu        |  1 -
 arch/m68k/include/asm/gpio.h | 95 ------------------------------------
 drivers/gpio/Kconfig         |  8 ---
 include/linux/gpio.h         |  7 ---
 4 files changed, 111 deletions(-)
 delete mode 100644 arch/m68k/include/asm/gpio.h

diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
index 9380f6e3bb66..96a0fb4f1af5 100644
--- a/arch/m68k/Kconfig.cpu
+++ b/arch/m68k/Kconfig.cpu
@@ -24,7 +24,6 @@ config M68KCLASSIC
 
 config COLDFIRE
 	bool "Coldfire CPU family support"
-	select ARCH_HAVE_CUSTOM_GPIO_H
 	select CPU_HAS_NO_BITFIELDS
 	select CPU_HAS_NO_CAS
 	select CPU_HAS_NO_MULDIV64
diff --git a/arch/m68k/include/asm/gpio.h b/arch/m68k/include/asm/gpio.h
deleted file mode 100644
index 5cfc0996ba94..000000000000
--- a/arch/m68k/include/asm/gpio.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Coldfire generic GPIO support
- *
- * (C) Copyright 2009, Steven King <sfking@fdwdc.com>
-*/
-
-#ifndef coldfire_gpio_h
-#define coldfire_gpio_h
-
-#include <linux/io.h>
-#include <asm/coldfire.h>
-#include <asm/mcfsim.h>
-#include <asm/mcfgpio.h>
-/*
- * The Generic GPIO functions
- *
- * If the gpio is a compile time constant and is one of the Coldfire gpios,
- * use the inline version, otherwise dispatch thru gpiolib.
- */
-
-static inline int gpio_get_value(unsigned gpio)
-{
-	if (__builtin_constant_p(gpio) && gpio < MCFGPIO_PIN_MAX)
-		return mcfgpio_read(__mcfgpio_ppdr(gpio)) & mcfgpio_bit(gpio);
-	else
-		return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned gpio, int value)
-{
-	if (__builtin_constant_p(gpio) && gpio < MCFGPIO_PIN_MAX) {
-		if (gpio < MCFGPIO_SCR_START) {
-			unsigned long flags;
-			MCFGPIO_PORTTYPE data;
-
-			local_irq_save(flags);
-			data = mcfgpio_read(__mcfgpio_podr(gpio));
-			if (value)
-				data |= mcfgpio_bit(gpio);
-			else
-				data &= ~mcfgpio_bit(gpio);
-			mcfgpio_write(data, __mcfgpio_podr(gpio));
-			local_irq_restore(flags);
-		} else {
-			if (value)
-				mcfgpio_write(mcfgpio_bit(gpio),
-						MCFGPIO_SETR_PORT(gpio));
-			else
-				mcfgpio_write(~mcfgpio_bit(gpio),
-						MCFGPIO_CLRR_PORT(gpio));
-		}
-	} else
-		__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_to_irq(unsigned gpio)
-{
-#if defined(MCFGPIO_IRQ_MIN)
-	if ((gpio >= MCFGPIO_IRQ_MIN) && (gpio < MCFGPIO_IRQ_MAX))
-#else
-	if (gpio < MCFGPIO_IRQ_MAX)
-#endif
-		return gpio + MCFGPIO_IRQ_VECBASE;
-	else
-		return __gpio_to_irq(gpio);
-}
-
-static inline int gpio_cansleep(unsigned gpio)
-{
-	return gpio < MCFGPIO_PIN_MAX ? 0 : __gpio_cansleep(gpio);
-}
-
-#ifndef CONFIG_GPIOLIB
-static inline int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
-{
-	int err;
-
-	err = gpio_request(gpio, label);
-	if (err)
-		return err;
-
-	if (flags & GPIOF_DIR_IN)
-		err = gpio_direction_input(gpio);
-	else
-		err = gpio_direction_output(gpio,
-			(flags & GPIOF_INIT_HIGH) ? 1 : 0);
-
-	if (err)
-		gpio_free(gpio);
-
-	return err;
-}
-#endif /* !CONFIG_GPIOLIB */
-#endif
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 218d7e4c27ff..06a268d56800 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -3,14 +3,6 @@
 # GPIO infrastructure and drivers
 #
 
-config ARCH_HAVE_CUSTOM_GPIO_H
-	bool
-	help
-	  Selecting this config option from the architecture Kconfig allows
-	  the architecture to provide a custom asm/gpio.h implementation
-	  overriding the default implementations.  New uses of this are
-	  strongly discouraged.
-
 menuconfig GPIOLIB
 	bool "GPIO Support"
 	help
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 85beb236c925..2b75017b3aad 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -54,11 +54,6 @@ struct gpio {
 };
 
 #ifdef CONFIG_GPIOLIB
-
-#ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H
-#include <asm/gpio.h>
-#else
-
 #include <asm-generic/gpio.h>
 
 static inline int gpio_get_value(unsigned int gpio)
@@ -81,8 +76,6 @@ static inline int gpio_to_irq(unsigned int gpio)
 	return __gpio_to_irq(gpio);
 }
 
-#endif /* ! CONFIG_ARCH_HAVE_CUSTOM_GPIO_H */
-
 /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */
 
 struct device;
-- 
2.39.1


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

* [PATCH v3 02/12] gpiolib: coldfire: remove custom asm/gpio.h
@ 2023-02-07 14:29   ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Eric Dumazet,
	Alim Akhtar, Frank Rowand, Alex Shi, Qiang Zhao, Yanteng Si,
	Yoshinori Sato, Jonathan Corbet, Bartosz Golaszewski, Lee Jones,
	Janusz Krzysztofik, Russell King, Jakub Kicinski, Paolo Abeni,
	Sebastian Hesselbarth, Gregory Clement, Kalle Valo,
	Hante Meuleman, Nicholas Piggin, Rob Herring,
	Mauro Carvalho Chehab, Mika Westerberg, Franky Lin,
	Arend van Spriel, Mun Yew Tham, Hu Haowen, Keerthy,
	Aaro Koskinen, Li Yang, David S. Miller

From: Arnd Bergmann <arnd@arndb.de>

Now that coldfire is the only user of a custom asm/gpio.h, it seems
better to remove this as well, and have the same interface everywhere.

For the gpio_get_value()/gpio_set_value()/gpio_to_irq(), gpio_cansleep()
functions, the custom version is only a micro-optimization to inline the
function for constant GPIO numbers. However, in the coldfire defconfigs,
I was unable to find a single instance where this micro-optimization
was even used, and according to Geert the only user appears to be the
QSPI chip that is disabled everywhere.

The custom gpio_request_one() function is even less useful, as it is
guarded by an #ifdef that is never true.

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/m68k/Kconfig.cpu        |  1 -
 arch/m68k/include/asm/gpio.h | 95 ------------------------------------
 drivers/gpio/Kconfig         |  8 ---
 include/linux/gpio.h         |  7 ---
 4 files changed, 111 deletions(-)
 delete mode 100644 arch/m68k/include/asm/gpio.h

diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
index 9380f6e3bb66..96a0fb4f1af5 100644
--- a/arch/m68k/Kconfig.cpu
+++ b/arch/m68k/Kconfig.cpu
@@ -24,7 +24,6 @@ config M68KCLASSIC
 
 config COLDFIRE
 	bool "Coldfire CPU family support"
-	select ARCH_HAVE_CUSTOM_GPIO_H
 	select CPU_HAS_NO_BITFIELDS
 	select CPU_HAS_NO_CAS
 	select CPU_HAS_NO_MULDIV64
diff --git a/arch/m68k/include/asm/gpio.h b/arch/m68k/include/asm/gpio.h
deleted file mode 100644
index 5cfc0996ba94..000000000000
--- a/arch/m68k/include/asm/gpio.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Coldfire generic GPIO support
- *
- * (C) Copyright 2009, Steven King <sfking@fdwdc.com>
-*/
-
-#ifndef coldfire_gpio_h
-#define coldfire_gpio_h
-
-#include <linux/io.h>
-#include <asm/coldfire.h>
-#include <asm/mcfsim.h>
-#include <asm/mcfgpio.h>
-/*
- * The Generic GPIO functions
- *
- * If the gpio is a compile time constant and is one of the Coldfire gpios,
- * use the inline version, otherwise dispatch thru gpiolib.
- */
-
-static inline int gpio_get_value(unsigned gpio)
-{
-	if (__builtin_constant_p(gpio) && gpio < MCFGPIO_PIN_MAX)
-		return mcfgpio_read(__mcfgpio_ppdr(gpio)) & mcfgpio_bit(gpio);
-	else
-		return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned gpio, int value)
-{
-	if (__builtin_constant_p(gpio) && gpio < MCFGPIO_PIN_MAX) {
-		if (gpio < MCFGPIO_SCR_START) {
-			unsigned long flags;
-			MCFGPIO_PORTTYPE data;
-
-			local_irq_save(flags);
-			data = mcfgpio_read(__mcfgpio_podr(gpio));
-			if (value)
-				data |= mcfgpio_bit(gpio);
-			else
-				data &= ~mcfgpio_bit(gpio);
-			mcfgpio_write(data, __mcfgpio_podr(gpio));
-			local_irq_restore(flags);
-		} else {
-			if (value)
-				mcfgpio_write(mcfgpio_bit(gpio),
-						MCFGPIO_SETR_PORT(gpio));
-			else
-				mcfgpio_write(~mcfgpio_bit(gpio),
-						MCFGPIO_CLRR_PORT(gpio));
-		}
-	} else
-		__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_to_irq(unsigned gpio)
-{
-#if defined(MCFGPIO_IRQ_MIN)
-	if ((gpio >= MCFGPIO_IRQ_MIN) && (gpio < MCFGPIO_IRQ_MAX))
-#else
-	if (gpio < MCFGPIO_IRQ_MAX)
-#endif
-		return gpio + MCFGPIO_IRQ_VECBASE;
-	else
-		return __gpio_to_irq(gpio);
-}
-
-static inline int gpio_cansleep(unsigned gpio)
-{
-	return gpio < MCFGPIO_PIN_MAX ? 0 : __gpio_cansleep(gpio);
-}
-
-#ifndef CONFIG_GPIOLIB
-static inline int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
-{
-	int err;
-
-	err = gpio_request(gpio, label);
-	if (err)
-		return err;
-
-	if (flags & GPIOF_DIR_IN)
-		err = gpio_direction_input(gpio);
-	else
-		err = gpio_direction_output(gpio,
-			(flags & GPIOF_INIT_HIGH) ? 1 : 0);
-
-	if (err)
-		gpio_free(gpio);
-
-	return err;
-}
-#endif /* !CONFIG_GPIOLIB */
-#endif
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 218d7e4c27ff..06a268d56800 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -3,14 +3,6 @@
 # GPIO infrastructure and drivers
 #
 
-config ARCH_HAVE_CUSTOM_GPIO_H
-	bool
-	help
-	  Selecting this config option from the architecture Kconfig allows
-	  the architecture to provide a custom asm/gpio.h implementation
-	  overriding the default implementations.  New uses of this are
-	  strongly discouraged.
-
 menuconfig GPIOLIB
 	bool "GPIO Support"
 	help
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 85beb236c925..2b75017b3aad 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -54,11 +54,6 @@ struct gpio {
 };
 
 #ifdef CONFIG_GPIOLIB
-
-#ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H
-#include <asm/gpio.h>
-#else
-
 #include <asm-generic/gpio.h>
 
 static inline int gpio_get_value(unsigned int gpio)
@@ -81,8 +76,6 @@ static inline int gpio_to_irq(unsigned int gpio)
 	return __gpio_to_irq(gpio);
 }
 
-#endif /* ! CONFIG_ARCH_HAVE_CUSTOM_GPIO_H */
-
 /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */
 
 struct device;
-- 
2.39.1


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

* [PATCH v3 03/12] gpiolib: remove asm-generic/gpio.h
  2023-02-07 14:29 ` Andy Shevchenko
@ 2023-02-07 14:29   ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Bartosz Golaszewski, Jonathan Corbet, Alex Shi, Yanteng Si,
	Hu Haowen, Russell King, Aaro Koskinen, Janusz Krzysztofik,
	Andrew Lunn, Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand

From: Arnd Bergmann <arnd@arndb.de>

The asm-generic/gpio.h file is now always included when
using gpiolib, so just move its contents into linux/gpio.h
with a few minor simplifications.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 MAINTAINERS                     |   1 -
 arch/m68k/include/asm/mcfgpio.h |   2 +-
 drivers/gpio/gpio-davinci.c     |   2 -
 drivers/pinctrl/core.c          |   1 -
 include/asm-generic/gpio.h      | 147 --------------------------------
 include/linux/gpio.h            |  93 ++++++++++++++++++--
 6 files changed, 85 insertions(+), 161 deletions(-)
 delete mode 100644 include/asm-generic/gpio.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 4d6aa8076868..0469de4e5000 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8730,7 +8730,6 @@ F:	Documentation/admin-guide/gpio/
 F:	Documentation/devicetree/bindings/gpio/
 F:	Documentation/driver-api/gpio/
 F:	drivers/gpio/
-F:	include/asm-generic/gpio.h
 F:	include/dt-bindings/gpio/
 F:	include/linux/gpio.h
 F:	include/linux/gpio/
diff --git a/arch/m68k/include/asm/mcfgpio.h b/arch/m68k/include/asm/mcfgpio.h
index 27f32cc81da6..2cefe8445980 100644
--- a/arch/m68k/include/asm/mcfgpio.h
+++ b/arch/m68k/include/asm/mcfgpio.h
@@ -9,7 +9,7 @@
 #define mcfgpio_h
 
 #ifdef CONFIG_GPIOLIB
-#include <asm-generic/gpio.h>
+#include <linux/gpio.h>
 #else
 
 int __mcfgpio_get_value(unsigned gpio);
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 26b1f7465e09..7fc83057990a 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -24,8 +24,6 @@
 #include <linux/spinlock.h>
 #include <linux/pm_runtime.h>
 
-#include <asm-generic/gpio.h>
-
 #define MAX_REGS_BANKS 5
 #define MAX_INT_PER_BANK 32
 
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index d6e6c751255f..401886c81344 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -30,7 +30,6 @@
 
 #ifdef CONFIG_GPIOLIB
 #include "../gpio/gpiolib.h"
-#include <asm-generic/gpio.h>
 #endif
 
 #include "core.h"
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
deleted file mode 100644
index 22cb8c9efc1d..000000000000
--- a/include/asm-generic/gpio.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_GENERIC_GPIO_H
-#define _ASM_GENERIC_GPIO_H
-
-#include <linux/types.h>
-#include <linux/errno.h>
-
-#ifdef CONFIG_GPIOLIB
-
-#include <linux/compiler.h>
-#include <linux/gpio/driver.h>
-#include <linux/gpio/consumer.h>
-
-/*
- * Platforms may implement their GPIO interface with library code,
- * at a small performance cost for non-inlined operations and some
- * extra memory (for code and for per-GPIO table entries).
- */
-
-/*
- * At the end we want all GPIOs to be dynamically allocated from 0.
- * However, some legacy drivers still perform fixed allocation.
- * Until they are all fixed, leave 0-512 space for them.
- */
-#define GPIO_DYNAMIC_BASE	512
-
-struct device;
-struct gpio;
-struct seq_file;
-struct module;
-struct device_node;
-struct gpio_desc;
-
-/* Always use the library code for GPIO management calls,
- * or when sleeping may be involved.
- */
-extern int gpio_request(unsigned gpio, const char *label);
-extern void gpio_free(unsigned gpio);
-
-static inline int gpio_direction_input(unsigned gpio)
-{
-	return gpiod_direction_input(gpio_to_desc(gpio));
-}
-static inline int gpio_direction_output(unsigned gpio, int value)
-{
-	return gpiod_direction_output_raw(gpio_to_desc(gpio), value);
-}
-
-static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
-{
-	return gpiod_set_debounce(gpio_to_desc(gpio), debounce);
-}
-
-static inline int gpio_get_value_cansleep(unsigned gpio)
-{
-	return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio));
-}
-static inline void gpio_set_value_cansleep(unsigned gpio, int value)
-{
-	return gpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value);
-}
-
-
-/* A platform's <asm/gpio.h> code may want to inline the I/O calls when
- * the GPIO is constant and refers to some always-present controller,
- * giving direct access to chip registers and tight bitbanging loops.
- */
-static inline int __gpio_get_value(unsigned gpio)
-{
-	return gpiod_get_raw_value(gpio_to_desc(gpio));
-}
-static inline void __gpio_set_value(unsigned gpio, int value)
-{
-	return gpiod_set_raw_value(gpio_to_desc(gpio), value);
-}
-
-static inline int __gpio_cansleep(unsigned gpio)
-{
-	return gpiod_cansleep(gpio_to_desc(gpio));
-}
-
-static inline int __gpio_to_irq(unsigned gpio)
-{
-	return gpiod_to_irq(gpio_to_desc(gpio));
-}
-
-extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
-extern int gpio_request_array(const struct gpio *array, size_t num);
-extern void gpio_free_array(const struct gpio *array, size_t num);
-
-/*
- * A sysfs interface can be exported by individual drivers if they want,
- * but more typically is configured entirely from userspace.
- */
-static inline int gpio_export(unsigned gpio, bool direction_may_change)
-{
-	return gpiod_export(gpio_to_desc(gpio), direction_may_change);
-}
-
-static inline void gpio_unexport(unsigned gpio)
-{
-	gpiod_unexport(gpio_to_desc(gpio));
-}
-
-#else	/* !CONFIG_GPIOLIB */
-
-#include <linux/kernel.h>
-
-/* platforms that don't directly support access to GPIOs through I2C, SPI,
- * or other blocking infrastructure can use these wrappers.
- */
-
-static inline int gpio_cansleep(unsigned gpio)
-{
-	return 0;
-}
-
-static inline int gpio_get_value_cansleep(unsigned gpio)
-{
-	might_sleep();
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value_cansleep(unsigned gpio, int value)
-{
-	might_sleep();
-	__gpio_set_value(gpio, value);
-}
-
-#endif /* !CONFIG_GPIOLIB */
-
-/*
- * "valid" GPIO numbers are nonnegative and may be passed to
- * setup routines like gpio_request().  only some valid numbers
- * can successfully be requested and used.
- *
- * Invalid GPIO numbers are useful for indicating no-such-GPIO in
- * platform data and other tables.
- */
-
-static inline bool gpio_is_valid(int number)
-{
-	/* only non-negative numbers are valid */
-	return number >= 0;
-}
-
-#endif /* _ASM_GENERIC_GPIO_H */
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 2b75017b3aad..6719a82eeec5 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -54,26 +54,101 @@ struct gpio {
 };
 
 #ifdef CONFIG_GPIOLIB
-#include <asm-generic/gpio.h>
+#include <linux/compiler.h>
+#include <linux/gpio/consumer.h>
+#include <linux/gpio/driver.h>
 
-static inline int gpio_get_value(unsigned int gpio)
+/*
+ * "valid" GPIO numbers are nonnegative and may be passed to
+ * setup routines like gpio_request().  Only some valid numbers
+ * can successfully be requested and used.
+ *
+ * Invalid GPIO numbers are useful for indicating no-such-GPIO in
+ * platform data and other tables.
+ */
+static inline bool gpio_is_valid(int number)
+{
+	/* only non-negative numbers are valid */
+	return number >= 0;
+}
+
+/*
+ * Platforms may implement their GPIO interface with library code,
+ * at a small performance cost for non-inlined operations and some
+ * extra memory (for code and for per-GPIO table entries).
+ */
+
+/*
+ * At the end we want all GPIOs to be dynamically allocated from 0.
+ * However, some legacy drivers still perform fixed allocation.
+ * Until they are all fixed, leave 0-512 space for them.
+ */
+#define GPIO_DYNAMIC_BASE	512
+
+/* Always use the library code for GPIO management calls,
+ * or when sleeping may be involved.
+ */
+int gpio_request(unsigned gpio, const char *label);
+void gpio_free(unsigned gpio);
+
+static inline int gpio_direction_input(unsigned gpio)
+{
+	return gpiod_direction_input(gpio_to_desc(gpio));
+}
+static inline int gpio_direction_output(unsigned gpio, int value)
 {
-	return __gpio_get_value(gpio);
+	return gpiod_direction_output_raw(gpio_to_desc(gpio), value);
 }
 
-static inline void gpio_set_value(unsigned int gpio, int value)
+static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
 {
-	__gpio_set_value(gpio, value);
+	return gpiod_set_debounce(gpio_to_desc(gpio), debounce);
 }
 
-static inline int gpio_cansleep(unsigned int gpio)
+static inline int gpio_get_value_cansleep(unsigned gpio)
+{
+	return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio));
+}
+static inline void gpio_set_value_cansleep(unsigned gpio, int value)
 {
-	return __gpio_cansleep(gpio);
+	return gpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value);
 }
 
-static inline int gpio_to_irq(unsigned int gpio)
+static inline int gpio_get_value(unsigned gpio)
+{
+	return gpiod_get_raw_value(gpio_to_desc(gpio));
+}
+static inline void gpio_set_value(unsigned gpio, int value)
+{
+	return gpiod_set_raw_value(gpio_to_desc(gpio), value);
+}
+
+static inline int gpio_cansleep(unsigned gpio)
+{
+	return gpiod_cansleep(gpio_to_desc(gpio));
+}
+
+static inline int gpio_to_irq(unsigned gpio)
+{
+	return gpiod_to_irq(gpio_to_desc(gpio));
+}
+
+int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
+int gpio_request_array(const struct gpio *array, size_t num);
+void gpio_free_array(const struct gpio *array, size_t num);
+
+/*
+ * A sysfs interface can be exported by individual drivers if they want,
+ * but more typically is configured entirely from userspace.
+ */
+static inline int gpio_export(unsigned gpio, bool direction_may_change)
+{
+	return gpiod_export(gpio_to_desc(gpio), direction_may_change);
+}
+
+static inline void gpio_unexport(unsigned gpio)
 {
-	return __gpio_to_irq(gpio);
+	gpiod_unexport(gpio_to_desc(gpio));
 }
 
 /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */
-- 
2.39.1


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

* [PATCH v3 03/12] gpiolib: remove asm-generic/gpio.h
@ 2023-02-07 14:29   ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Eric Dumazet,
	Alim Akhtar, Frank Rowand, Alex Shi, Qiang Zhao, Yanteng Si,
	Yoshinori Sato, Jonathan Corbet, Bartosz Golaszewski, Lee Jones,
	Janusz Krzysztofik, Russell King, Jakub Kicinski, Paolo Abeni,
	Sebastian Hesselbarth, Gregory Clement, Kalle Valo,
	Hante Meuleman, Nicholas Piggin, Rob Herring,
	Mauro Carvalho Chehab, Mika Westerberg, Franky Lin,
	Arend van Spriel, Mun Yew Tham, Hu Haowen, Keerthy,
	Aaro Koskinen, Li Yang, David S. Miller

From: Arnd Bergmann <arnd@arndb.de>

The asm-generic/gpio.h file is now always included when
using gpiolib, so just move its contents into linux/gpio.h
with a few minor simplifications.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 MAINTAINERS                     |   1 -
 arch/m68k/include/asm/mcfgpio.h |   2 +-
 drivers/gpio/gpio-davinci.c     |   2 -
 drivers/pinctrl/core.c          |   1 -
 include/asm-generic/gpio.h      | 147 --------------------------------
 include/linux/gpio.h            |  93 ++++++++++++++++++--
 6 files changed, 85 insertions(+), 161 deletions(-)
 delete mode 100644 include/asm-generic/gpio.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 4d6aa8076868..0469de4e5000 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8730,7 +8730,6 @@ F:	Documentation/admin-guide/gpio/
 F:	Documentation/devicetree/bindings/gpio/
 F:	Documentation/driver-api/gpio/
 F:	drivers/gpio/
-F:	include/asm-generic/gpio.h
 F:	include/dt-bindings/gpio/
 F:	include/linux/gpio.h
 F:	include/linux/gpio/
diff --git a/arch/m68k/include/asm/mcfgpio.h b/arch/m68k/include/asm/mcfgpio.h
index 27f32cc81da6..2cefe8445980 100644
--- a/arch/m68k/include/asm/mcfgpio.h
+++ b/arch/m68k/include/asm/mcfgpio.h
@@ -9,7 +9,7 @@
 #define mcfgpio_h
 
 #ifdef CONFIG_GPIOLIB
-#include <asm-generic/gpio.h>
+#include <linux/gpio.h>
 #else
 
 int __mcfgpio_get_value(unsigned gpio);
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 26b1f7465e09..7fc83057990a 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -24,8 +24,6 @@
 #include <linux/spinlock.h>
 #include <linux/pm_runtime.h>
 
-#include <asm-generic/gpio.h>
-
 #define MAX_REGS_BANKS 5
 #define MAX_INT_PER_BANK 32
 
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index d6e6c751255f..401886c81344 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -30,7 +30,6 @@
 
 #ifdef CONFIG_GPIOLIB
 #include "../gpio/gpiolib.h"
-#include <asm-generic/gpio.h>
 #endif
 
 #include "core.h"
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
deleted file mode 100644
index 22cb8c9efc1d..000000000000
--- a/include/asm-generic/gpio.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_GENERIC_GPIO_H
-#define _ASM_GENERIC_GPIO_H
-
-#include <linux/types.h>
-#include <linux/errno.h>
-
-#ifdef CONFIG_GPIOLIB
-
-#include <linux/compiler.h>
-#include <linux/gpio/driver.h>
-#include <linux/gpio/consumer.h>
-
-/*
- * Platforms may implement their GPIO interface with library code,
- * at a small performance cost for non-inlined operations and some
- * extra memory (for code and for per-GPIO table entries).
- */
-
-/*
- * At the end we want all GPIOs to be dynamically allocated from 0.
- * However, some legacy drivers still perform fixed allocation.
- * Until they are all fixed, leave 0-512 space for them.
- */
-#define GPIO_DYNAMIC_BASE	512
-
-struct device;
-struct gpio;
-struct seq_file;
-struct module;
-struct device_node;
-struct gpio_desc;
-
-/* Always use the library code for GPIO management calls,
- * or when sleeping may be involved.
- */
-extern int gpio_request(unsigned gpio, const char *label);
-extern void gpio_free(unsigned gpio);
-
-static inline int gpio_direction_input(unsigned gpio)
-{
-	return gpiod_direction_input(gpio_to_desc(gpio));
-}
-static inline int gpio_direction_output(unsigned gpio, int value)
-{
-	return gpiod_direction_output_raw(gpio_to_desc(gpio), value);
-}
-
-static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
-{
-	return gpiod_set_debounce(gpio_to_desc(gpio), debounce);
-}
-
-static inline int gpio_get_value_cansleep(unsigned gpio)
-{
-	return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio));
-}
-static inline void gpio_set_value_cansleep(unsigned gpio, int value)
-{
-	return gpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value);
-}
-
-
-/* A platform's <asm/gpio.h> code may want to inline the I/O calls when
- * the GPIO is constant and refers to some always-present controller,
- * giving direct access to chip registers and tight bitbanging loops.
- */
-static inline int __gpio_get_value(unsigned gpio)
-{
-	return gpiod_get_raw_value(gpio_to_desc(gpio));
-}
-static inline void __gpio_set_value(unsigned gpio, int value)
-{
-	return gpiod_set_raw_value(gpio_to_desc(gpio), value);
-}
-
-static inline int __gpio_cansleep(unsigned gpio)
-{
-	return gpiod_cansleep(gpio_to_desc(gpio));
-}
-
-static inline int __gpio_to_irq(unsigned gpio)
-{
-	return gpiod_to_irq(gpio_to_desc(gpio));
-}
-
-extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
-extern int gpio_request_array(const struct gpio *array, size_t num);
-extern void gpio_free_array(const struct gpio *array, size_t num);
-
-/*
- * A sysfs interface can be exported by individual drivers if they want,
- * but more typically is configured entirely from userspace.
- */
-static inline int gpio_export(unsigned gpio, bool direction_may_change)
-{
-	return gpiod_export(gpio_to_desc(gpio), direction_may_change);
-}
-
-static inline void gpio_unexport(unsigned gpio)
-{
-	gpiod_unexport(gpio_to_desc(gpio));
-}
-
-#else	/* !CONFIG_GPIOLIB */
-
-#include <linux/kernel.h>
-
-/* platforms that don't directly support access to GPIOs through I2C, SPI,
- * or other blocking infrastructure can use these wrappers.
- */
-
-static inline int gpio_cansleep(unsigned gpio)
-{
-	return 0;
-}
-
-static inline int gpio_get_value_cansleep(unsigned gpio)
-{
-	might_sleep();
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value_cansleep(unsigned gpio, int value)
-{
-	might_sleep();
-	__gpio_set_value(gpio, value);
-}
-
-#endif /* !CONFIG_GPIOLIB */
-
-/*
- * "valid" GPIO numbers are nonnegative and may be passed to
- * setup routines like gpio_request().  only some valid numbers
- * can successfully be requested and used.
- *
- * Invalid GPIO numbers are useful for indicating no-such-GPIO in
- * platform data and other tables.
- */
-
-static inline bool gpio_is_valid(int number)
-{
-	/* only non-negative numbers are valid */
-	return number >= 0;
-}
-
-#endif /* _ASM_GENERIC_GPIO_H */
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 2b75017b3aad..6719a82eeec5 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -54,26 +54,101 @@ struct gpio {
 };
 
 #ifdef CONFIG_GPIOLIB
-#include <asm-generic/gpio.h>
+#include <linux/compiler.h>
+#include <linux/gpio/consumer.h>
+#include <linux/gpio/driver.h>
 
-static inline int gpio_get_value(unsigned int gpio)
+/*
+ * "valid" GPIO numbers are nonnegative and may be passed to
+ * setup routines like gpio_request().  Only some valid numbers
+ * can successfully be requested and used.
+ *
+ * Invalid GPIO numbers are useful for indicating no-such-GPIO in
+ * platform data and other tables.
+ */
+static inline bool gpio_is_valid(int number)
+{
+	/* only non-negative numbers are valid */
+	return number >= 0;
+}
+
+/*
+ * Platforms may implement their GPIO interface with library code,
+ * at a small performance cost for non-inlined operations and some
+ * extra memory (for code and for per-GPIO table entries).
+ */
+
+/*
+ * At the end we want all GPIOs to be dynamically allocated from 0.
+ * However, some legacy drivers still perform fixed allocation.
+ * Until they are all fixed, leave 0-512 space for them.
+ */
+#define GPIO_DYNAMIC_BASE	512
+
+/* Always use the library code for GPIO management calls,
+ * or when sleeping may be involved.
+ */
+int gpio_request(unsigned gpio, const char *label);
+void gpio_free(unsigned gpio);
+
+static inline int gpio_direction_input(unsigned gpio)
+{
+	return gpiod_direction_input(gpio_to_desc(gpio));
+}
+static inline int gpio_direction_output(unsigned gpio, int value)
 {
-	return __gpio_get_value(gpio);
+	return gpiod_direction_output_raw(gpio_to_desc(gpio), value);
 }
 
-static inline void gpio_set_value(unsigned int gpio, int value)
+static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
 {
-	__gpio_set_value(gpio, value);
+	return gpiod_set_debounce(gpio_to_desc(gpio), debounce);
 }
 
-static inline int gpio_cansleep(unsigned int gpio)
+static inline int gpio_get_value_cansleep(unsigned gpio)
+{
+	return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio));
+}
+static inline void gpio_set_value_cansleep(unsigned gpio, int value)
 {
-	return __gpio_cansleep(gpio);
+	return gpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value);
 }
 
-static inline int gpio_to_irq(unsigned int gpio)
+static inline int gpio_get_value(unsigned gpio)
+{
+	return gpiod_get_raw_value(gpio_to_desc(gpio));
+}
+static inline void gpio_set_value(unsigned gpio, int value)
+{
+	return gpiod_set_raw_value(gpio_to_desc(gpio), value);
+}
+
+static inline int gpio_cansleep(unsigned gpio)
+{
+	return gpiod_cansleep(gpio_to_desc(gpio));
+}
+
+static inline int gpio_to_irq(unsigned gpio)
+{
+	return gpiod_to_irq(gpio_to_desc(gpio));
+}
+
+int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
+int gpio_request_array(const struct gpio *array, size_t num);
+void gpio_free_array(const struct gpio *array, size_t num);
+
+/*
+ * A sysfs interface can be exported by individual drivers if they want,
+ * but more typically is configured entirely from userspace.
+ */
+static inline int gpio_export(unsigned gpio, bool direction_may_change)
+{
+	return gpiod_export(gpio_to_desc(gpio), direction_may_change);
+}
+
+static inline void gpio_unexport(unsigned gpio)
 {
-	return __gpio_to_irq(gpio);
+	gpiod_unexport(gpio_to_desc(gpio));
 }
 
 /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */
-- 
2.39.1


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

* [PATCH v3 04/12] gpiolib: remove gpio_set_debounce
  2023-02-07 14:29 ` Andy Shevchenko
@ 2023-02-07 14:29   ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Bartosz Golaszewski, Jonathan Corbet, Alex Shi, Yanteng Si,
	Hu Haowen, Russell King, Aaro Koskinen, Janusz Krzysztofik,
	Andrew Lunn, Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand

From: Arnd Bergmann <arnd@arndb.de>

gpio_set_debounce() only has a single user, which is trivially
converted to gpiod_set_debounce().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 Documentation/driver-api/gpio/legacy.rst      |  2 --
 .../zh_CN/driver-api/gpio/legacy.rst          |  1 -
 Documentation/translations/zh_TW/gpio.txt     |  1 -
 drivers/input/touchscreen/ads7846.c           | 24 ++++++++++++-------
 include/linux/gpio.h                          | 10 --------
 5 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/Documentation/driver-api/gpio/legacy.rst b/Documentation/driver-api/gpio/legacy.rst
index a0559d93efd1..e0306e78e34b 100644
--- a/Documentation/driver-api/gpio/legacy.rst
+++ b/Documentation/driver-api/gpio/legacy.rst
@@ -238,8 +238,6 @@ setup or driver probe/teardown code, so this is an easy constraint.)::
         ## 	gpio_free_array()
 
                 gpio_free()
-                gpio_set_debounce()
-
 
 
 Claiming and Releasing GPIOs
diff --git a/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst b/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
index 74fa473bb504..dee2a0517c1c 100644
--- a/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
+++ b/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
@@ -219,7 +219,6 @@ GPIO 值的命令需要等待其信息排到队首才发送命令,再获得其
         ## 	gpio_free_array()
 
                 gpio_free()
-                gpio_set_debounce()
 
 
 
diff --git a/Documentation/translations/zh_TW/gpio.txt b/Documentation/translations/zh_TW/gpio.txt
index 1b986bbb0909..dc608358d90a 100644
--- a/Documentation/translations/zh_TW/gpio.txt
+++ b/Documentation/translations/zh_TW/gpio.txt
@@ -226,7 +226,6 @@ GPIO 值的命令需要等待其信息排到隊首才發送命令,再獲得其
 ## 	gpio_free_array()
 
 	gpio_free()
-	gpio_set_debounce()
 
 
 
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 17f11bce8113..a9a4a7f7d315 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -25,8 +25,8 @@
 #include <linux/slab.h>
 #include <linux/pm.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
 #include <linux/of_device.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
@@ -999,7 +999,6 @@ static int ads7846_setup_pendown(struct spi_device *spi,
 	if (pdata->get_pendown_state) {
 		ts->get_pendown_state = pdata->get_pendown_state;
 	} else if (gpio_is_valid(pdata->gpio_pendown)) {
-
 		err = devm_gpio_request_one(&spi->dev, pdata->gpio_pendown,
 					    GPIOF_IN, "ads7846_pendown");
 		if (err) {
@@ -1010,14 +1009,21 @@ static int ads7846_setup_pendown(struct spi_device *spi,
 		}
 
 		ts->gpio_pendown = pdata->gpio_pendown;
-
-		if (pdata->gpio_pendown_debounce)
-			gpio_set_debounce(pdata->gpio_pendown,
-					  pdata->gpio_pendown_debounce);
 	} else {
-		dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
-		return -EINVAL;
+		struct gpio_desc *desc;
+
+		desc = devm_gpiod_get(&spi->dev, "pendown", GPIOD_IN);
+		if (IS_ERR(desc)) {
+			dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
+			return PTR_ERR(desc);
+		}
+		gpiod_set_consumer_name(desc, "ads7846_pendown");
+
+		ts->gpio_pendown = desc_to_gpio(desc);
 	}
+	if (pdata->gpio_pendown_debounce)
+		gpiod_set_debounce(gpio_to_desc(ts->gpio_pendown),
+				   pdata->gpio_pendown_debounce);
 
 	return 0;
 }
@@ -1194,7 +1200,7 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
 	pdata->wakeup = of_property_read_bool(node, "wakeup-source") ||
 			of_property_read_bool(node, "linux,wakeup");
 
-	pdata->gpio_pendown = of_get_named_gpio(dev->of_node, "pendown-gpio", 0);
+	pdata->gpio_pendown = -ENOENT;
 
 	return pdata;
 }
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 6719a82eeec5..220e8656f2ab 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -100,11 +100,6 @@ static inline int gpio_direction_output(unsigned gpio, int value)
 	return gpiod_direction_output_raw(gpio_to_desc(gpio), value);
 }
 
-static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
-{
-	return gpiod_set_debounce(gpio_to_desc(gpio), debounce);
-}
-
 static inline int gpio_get_value_cansleep(unsigned gpio)
 {
 	return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio));
@@ -215,11 +210,6 @@ static inline int gpio_direction_output(unsigned gpio, int value)
 	return -ENOSYS;
 }
 
-static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
-{
-	return -ENOSYS;
-}
-
 static inline int gpio_get_value(unsigned gpio)
 {
 	/* GPIO can never have been requested or set as {in,out}put */
-- 
2.39.1


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

* [PATCH v3 04/12] gpiolib: remove gpio_set_debounce
@ 2023-02-07 14:29   ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Eric Dumazet,
	Alim Akhtar, Frank Rowand, Alex Shi, Qiang Zhao, Yanteng Si,
	Yoshinori Sato, Jonathan Corbet, Bartosz Golaszewski, Lee Jones,
	Janusz Krzysztofik, Russell King, Jakub Kicinski, Paolo Abeni,
	Sebastian Hesselbarth, Gregory Clement, Kalle Valo,
	Hante Meuleman, Nicholas Piggin, Rob Herring,
	Mauro Carvalho Chehab, Mika Westerberg, Franky Lin,
	Arend van Spriel, Mun Yew Tham, Hu Haowen, Keerthy,
	Aaro Koskinen, Li Yang, David S. Miller

From: Arnd Bergmann <arnd@arndb.de>

gpio_set_debounce() only has a single user, which is trivially
converted to gpiod_set_debounce().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 Documentation/driver-api/gpio/legacy.rst      |  2 --
 .../zh_CN/driver-api/gpio/legacy.rst          |  1 -
 Documentation/translations/zh_TW/gpio.txt     |  1 -
 drivers/input/touchscreen/ads7846.c           | 24 ++++++++++++-------
 include/linux/gpio.h                          | 10 --------
 5 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/Documentation/driver-api/gpio/legacy.rst b/Documentation/driver-api/gpio/legacy.rst
index a0559d93efd1..e0306e78e34b 100644
--- a/Documentation/driver-api/gpio/legacy.rst
+++ b/Documentation/driver-api/gpio/legacy.rst
@@ -238,8 +238,6 @@ setup or driver probe/teardown code, so this is an easy constraint.)::
         ## 	gpio_free_array()
 
                 gpio_free()
-                gpio_set_debounce()
-
 
 
 Claiming and Releasing GPIOs
diff --git a/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst b/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
index 74fa473bb504..dee2a0517c1c 100644
--- a/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
+++ b/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
@@ -219,7 +219,6 @@ GPIO 值的命令需要等待其信息排到队首才发送命令,再获得其
         ## 	gpio_free_array()
 
                 gpio_free()
-                gpio_set_debounce()
 
 
 
diff --git a/Documentation/translations/zh_TW/gpio.txt b/Documentation/translations/zh_TW/gpio.txt
index 1b986bbb0909..dc608358d90a 100644
--- a/Documentation/translations/zh_TW/gpio.txt
+++ b/Documentation/translations/zh_TW/gpio.txt
@@ -226,7 +226,6 @@ GPIO 值的命令需要等待其信息排到隊首才發送命令,再獲得其
 ## 	gpio_free_array()
 
 	gpio_free()
-	gpio_set_debounce()
 
 
 
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 17f11bce8113..a9a4a7f7d315 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -25,8 +25,8 @@
 #include <linux/slab.h>
 #include <linux/pm.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
 #include <linux/of_device.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
@@ -999,7 +999,6 @@ static int ads7846_setup_pendown(struct spi_device *spi,
 	if (pdata->get_pendown_state) {
 		ts->get_pendown_state = pdata->get_pendown_state;
 	} else if (gpio_is_valid(pdata->gpio_pendown)) {
-
 		err = devm_gpio_request_one(&spi->dev, pdata->gpio_pendown,
 					    GPIOF_IN, "ads7846_pendown");
 		if (err) {
@@ -1010,14 +1009,21 @@ static int ads7846_setup_pendown(struct spi_device *spi,
 		}
 
 		ts->gpio_pendown = pdata->gpio_pendown;
-
-		if (pdata->gpio_pendown_debounce)
-			gpio_set_debounce(pdata->gpio_pendown,
-					  pdata->gpio_pendown_debounce);
 	} else {
-		dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
-		return -EINVAL;
+		struct gpio_desc *desc;
+
+		desc = devm_gpiod_get(&spi->dev, "pendown", GPIOD_IN);
+		if (IS_ERR(desc)) {
+			dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
+			return PTR_ERR(desc);
+		}
+		gpiod_set_consumer_name(desc, "ads7846_pendown");
+
+		ts->gpio_pendown = desc_to_gpio(desc);
 	}
+	if (pdata->gpio_pendown_debounce)
+		gpiod_set_debounce(gpio_to_desc(ts->gpio_pendown),
+				   pdata->gpio_pendown_debounce);
 
 	return 0;
 }
@@ -1194,7 +1200,7 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
 	pdata->wakeup = of_property_read_bool(node, "wakeup-source") ||
 			of_property_read_bool(node, "linux,wakeup");
 
-	pdata->gpio_pendown = of_get_named_gpio(dev->of_node, "pendown-gpio", 0);
+	pdata->gpio_pendown = -ENOENT;
 
 	return pdata;
 }
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 6719a82eeec5..220e8656f2ab 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -100,11 +100,6 @@ static inline int gpio_direction_output(unsigned gpio, int value)
 	return gpiod_direction_output_raw(gpio_to_desc(gpio), value);
 }
 
-static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
-{
-	return gpiod_set_debounce(gpio_to_desc(gpio), debounce);
-}
-
 static inline int gpio_get_value_cansleep(unsigned gpio)
 {
 	return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio));
@@ -215,11 +210,6 @@ static inline int gpio_direction_output(unsigned gpio, int value)
 	return -ENOSYS;
 }
 
-static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
-{
-	return -ENOSYS;
-}
-
 static inline int gpio_get_value(unsigned gpio)
 {
 	/* GPIO can never have been requested or set as {in,out}put */
-- 
2.39.1


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

* [PATCH v3 05/12] gpiolib: remove legacy gpio_export
  2023-02-07 14:29 ` Andy Shevchenko
@ 2023-02-07 14:29   ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Bartosz Golaszewski, Jonathan Corbet, Alex Shi, Yanteng Si,
	Hu Haowen, Russell King, Aaro Koskinen, Janusz Krzysztofik,
	Andrew Lunn, Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand

From: Arnd Bergmann <arnd@arndb.de>

There are only a handful of users of gpio_export() and
related functions.

As these are just wrappers around the modern gpiod_export()
helper, remove the wrappers and open-code the gpio_to_desc
in all callers to shrink the legacy API.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 Documentation/admin-guide/gpio/sysfs.rst      |  2 +-
 Documentation/driver-api/gpio/legacy.rst      | 21 ---------------
 .../zh_CN/driver-api/gpio/legacy.rst          | 19 -------------
 Documentation/translations/zh_TW/gpio.txt     | 18 -------------
 arch/arm/mach-omap2/pdata-quirks.c            |  9 ++++---
 arch/sh/boards/mach-ap325rxa/setup.c          |  7 ++---
 drivers/gpio/gpiolib-sysfs.c                  |  4 +--
 drivers/media/pci/sta2x11/sta2x11_vip.c       | 10 ++++---
 drivers/net/ieee802154/ca8210.c               |  3 ++-
 include/linux/gpio.h                          | 27 -------------------
 10 files changed, 21 insertions(+), 99 deletions(-)

diff --git a/Documentation/admin-guide/gpio/sysfs.rst b/Documentation/admin-guide/gpio/sysfs.rst
index ec09ffd983e7..35171d15f78d 100644
--- a/Documentation/admin-guide/gpio/sysfs.rst
+++ b/Documentation/admin-guide/gpio/sysfs.rst
@@ -145,7 +145,7 @@ requested using gpio_request()::
 	/* export the GPIO to userspace */
 	int gpiod_export(struct gpio_desc *desc, bool direction_may_change);
 
-	/* reverse gpio_export() */
+	/* reverse gpiod_export() */
 	void gpiod_unexport(struct gpio_desc *desc);
 
 	/* create a sysfs link to an exported GPIO node */
diff --git a/Documentation/driver-api/gpio/legacy.rst b/Documentation/driver-api/gpio/legacy.rst
index e0306e78e34b..78372853c6d4 100644
--- a/Documentation/driver-api/gpio/legacy.rst
+++ b/Documentation/driver-api/gpio/legacy.rst
@@ -714,27 +714,6 @@ gpiochip nodes (possibly in conjunction with schematics) to determine
 the correct GPIO number to use for a given signal.
 
 
-Exporting from Kernel code
---------------------------
-Kernel code can explicitly manage exports of GPIOs which have already been
-requested using gpio_request()::
-
-	/* export the GPIO to userspace */
-	int gpio_export(unsigned gpio, bool direction_may_change);
-
-	/* reverse gpio_export() */
-	void gpio_unexport();
-
-After a kernel driver requests a GPIO, it may only be made available in
-the sysfs interface by gpio_export().  The driver can control whether the
-signal direction may change.  This helps drivers prevent userspace code
-from accidentally clobbering important system state.
-
-This explicit exporting can help with debugging (by making some kinds
-of experiments easier), or can provide an always-there interface that's
-suitable for documenting as part of a board support package.
-
-
 API Reference
 =============
 
diff --git a/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst b/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
index dee2a0517c1c..84ce2322fdba 100644
--- a/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
+++ b/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
@@ -653,25 +653,6 @@ GPIO 控制器的路径类似 /sys/class/gpio/gpiochip42/ (对于从#42 GPIO
 确定给定信号所用的 GPIO 编号。
 
 
-从内核代码中导出
-----------------
-
-内核代码可以明确地管理那些已通过 gpio_request()申请的 GPIO 的导出::
-
-	/* 导出 GPIO 到用户空间 */
-	int gpio_export(unsigned gpio, bool direction_may_change);
-
-	/* gpio_export()的逆操作 */
-	void gpio_unexport();
-
-在一个内核驱动申请一个 GPIO 之后,它可以通过 gpio_export()使其在 sysfs
-接口中可见。该驱动可以控制信号方向是否可修改。这有助于防止用户空间代码无意间
-破坏重要的系统状态。
-
-这个明确的导出有助于(通过使某些实验更容易来)调试,也可以提供一个始终存在的接口,
-与文档配合作为板级支持包的一部分。
-
-
 API参考
 =======
 
diff --git a/Documentation/translations/zh_TW/gpio.txt b/Documentation/translations/zh_TW/gpio.txt
index dc608358d90a..62e560ffe628 100644
--- a/Documentation/translations/zh_TW/gpio.txt
+++ b/Documentation/translations/zh_TW/gpio.txt
@@ -614,21 +614,3 @@ GPIO 控制器的路徑類似 /sys/class/gpio/gpiochip42/ (對於從#42 GPIO
 固定的,例如在擴展卡上的 GPIO會根據所使用的主板或所在堆疊架構中其他的板子而
 有所不同。在這種情況下,你可能需要使用 gpiochip 節點(儘可能地結合電路圖)來
 確定給定信號所用的 GPIO 編號。
-
-
-從內核代碼中導出
--------------
-內核代碼可以明確地管理那些已通過 gpio_request()申請的 GPIO 的導出:
-
-	/* 導出 GPIO 到用戶空間 */
-	int gpio_export(unsigned gpio, bool direction_may_change);
-
-	/* gpio_export()的逆操作 */
-	void gpio_unexport();
-
-在一個內核驅動申請一個 GPIO 之後,它可以通過 gpio_export()使其在 sysfs
-接口中可見。該驅動可以控制信號方向是否可修改。這有助於防止用戶空間代碼無意間
-破壞重要的系統狀態。
-
-這個明確的導出有助於(通過使某些實驗更容易來)調試,也可以提供一個始終存在的接口,
-與文檔配合作爲板級支持包的一部分。
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index baba73fd6f11..04208cc52784 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -6,6 +6,7 @@
  */
 #include <linux/clk.h>
 #include <linux/davinci_emac.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -108,7 +109,7 @@ static int omap3_sbc_t3730_twl_callback(struct device *dev,
 	if (res)
 		return res;
 
-	gpio_export(gpio, 0);
+	gpiod_export(gpio_to_desc(gpio), 0);
 
 	return 0;
 }
@@ -123,7 +124,7 @@ static void __init omap3_sbc_t3x_usb_hub_init(int gpio, char *hub_name)
 		return;
 	}
 
-	gpio_export(gpio, 0);
+	gpiod_export(gpio_to_desc(gpio), 0);
 
 	udelay(10);
 	gpio_set_value(gpio, 1);
@@ -200,8 +201,8 @@ static void __init omap3_sbc_t3517_wifi_init(void)
 		return;
 	}
 
-	gpio_export(cm_t3517_wlan_gpios[0].gpio, 0);
-	gpio_export(cm_t3517_wlan_gpios[1].gpio, 0);
+	gpiod_export(gpio_to_desc(cm_t3517_wlan_gpios[0].gpio), 0);
+	gpiod_export(gpio_to_desc(cm_t3517_wlan_gpios[1].gpio), 0);
 
 	msleep(100);
 	gpio_set_value(cm_t3517_wlan_gpios[1].gpio, 0);
diff --git a/arch/sh/boards/mach-ap325rxa/setup.c b/arch/sh/boards/mach-ap325rxa/setup.c
index c77b5f00a66a..151792162152 100644
--- a/arch/sh/boards/mach-ap325rxa/setup.c
+++ b/arch/sh/boards/mach-ap325rxa/setup.c
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio/machine.h>
 #include <linux/i2c.h>
 #include <linux/init.h>
@@ -411,16 +412,16 @@ static int __init ap325rxa_devices_setup(void)
 	/* LD3 and LD4 LEDs */
 	gpio_request(GPIO_PTX5, NULL); /* RUN */
 	gpio_direction_output(GPIO_PTX5, 1);
-	gpio_export(GPIO_PTX5, 0);
+	gpiod_export(gpio_to_desc(GPIO_PTX5), 0);
 
 	gpio_request(GPIO_PTX4, NULL); /* INDICATOR */
 	gpio_direction_output(GPIO_PTX4, 0);
-	gpio_export(GPIO_PTX4, 0);
+	gpiod_export(gpio_to_desc(GPIO_PTX4), 0);
 
 	/* SW1 input */
 	gpio_request(GPIO_PTF7, NULL); /* MODE */
 	gpio_direction_input(GPIO_PTF7);
-	gpio_export(GPIO_PTF7, 0);
+	gpiod_export(gpio_to_desc(GPIO_PTF7), 0);
 
 	/* LCDC */
 	gpio_request(GPIO_FN_LCDD15, NULL);
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index cd27bf173dec..6e4267944f80 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -491,7 +491,7 @@ static ssize_t unexport_store(struct class *class,
 		goto done;
 
 	desc = gpio_to_desc(gpio);
-	/* reject bogus commands (gpio_unexport ignores them) */
+	/* reject bogus commands (gpiod_unexport() ignores them) */
 	if (!desc) {
 		pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);
 		return -EINVAL;
@@ -790,7 +790,7 @@ static int __init gpiolib_sysfs_init(void)
 	 * early (e.g. before the class_register above was called).
 	 *
 	 * We run before arch_initcall() so chip->dev nodes can have
-	 * registered, and so arch_initcall() can always gpio_export().
+	 * registered, and so arch_initcall() can always gpiod_export().
 	 */
 	spin_lock_irqsave(&gpio_lock, flags);
 	list_for_each_entry(gdev, &gpio_devices, list) {
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c
index 8535e49a4c4f..e4cf9d63e926 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -18,6 +18,7 @@
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio.h>
 #include <linux/i2c.h>
 #include <linux/delay.h>
@@ -889,6 +890,7 @@ static int sta2x11_vip_init_controls(struct sta2x11_vip *vip)
 static int vip_gpio_reserve(struct device *dev, int pin, int dir,
 			    const char *name)
 {
+	struct gpio_desc *desc = gpio_to_desc(pin);
 	int ret = -ENODEV;
 
 	if (!gpio_is_valid(pin))
@@ -900,7 +902,7 @@ static int vip_gpio_reserve(struct device *dev, int pin, int dir,
 		return ret;
 	}
 
-	ret = gpio_direction_output(pin, dir);
+	ret = gpiod_direction_output(desc, dir);
 	if (ret) {
 		dev_err(dev, "Failed to set direction for pin %d (%s)\n",
 			pin, name);
@@ -908,7 +910,7 @@ static int vip_gpio_reserve(struct device *dev, int pin, int dir,
 		return ret;
 	}
 
-	ret = gpio_export(pin, false);
+	ret = gpiod_export(desc, false);
 	if (ret) {
 		dev_err(dev, "Failed to export pin %d (%s)\n", pin, name);
 		gpio_free(pin);
@@ -928,8 +930,10 @@ static int vip_gpio_reserve(struct device *dev, int pin, int dir,
 static void vip_gpio_release(struct device *dev, int pin, const char *name)
 {
 	if (gpio_is_valid(pin)) {
+		struct gpio_desc *desc = gpio_to_desc(pin);
+
 		dev_dbg(dev, "releasing pin %d (%s)\n",	pin, name);
-		gpio_unexport(pin);
+		gpiod_unexport(desc);
 		gpio_free(pin);
 	}
 }
diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
index e1a569b99e4a..5c0be6a3ec5e 100644
--- a/drivers/net/ieee802154/ca8210.c
+++ b/drivers/net/ieee802154/ca8210.c
@@ -51,6 +51,7 @@
 #include <linux/clk-provider.h>
 #include <linux/debugfs.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio.h>
 #include <linux/ieee802154.h>
 #include <linux/io.h>
@@ -2853,7 +2854,7 @@ static int ca8210_interrupt_init(struct spi_device *spi)
 	);
 	if (ret) {
 		dev_crit(&spi->dev, "request_irq %d failed\n", pdata->irq_id);
-		gpio_unexport(pdata->gpio_irq);
+		gpiod_unexport(gpio_to_desc(pdata->gpio_irq));
 		gpio_free(pdata->gpio_irq);
 	}
 
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 220e8656f2ab..a1271526e489 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -132,20 +132,6 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
 int gpio_request_array(const struct gpio *array, size_t num);
 void gpio_free_array(const struct gpio *array, size_t num);
 
-/*
- * A sysfs interface can be exported by individual drivers if they want,
- * but more typically is configured entirely from userspace.
- */
-static inline int gpio_export(unsigned gpio, bool direction_may_change)
-{
-	return gpiod_export(gpio_to_desc(gpio), direction_may_change);
-}
-
-static inline void gpio_unexport(unsigned gpio)
-{
-	gpiod_unexport(gpio_to_desc(gpio));
-}
-
 /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */
 
 struct device;
@@ -243,19 +229,6 @@ static inline void gpio_set_value_cansleep(unsigned gpio, int value)
 	WARN_ON(1);
 }
 
-static inline int gpio_export(unsigned gpio, bool direction_may_change)
-{
-	/* GPIO can never have been requested or set as {in,out}put */
-	WARN_ON(1);
-	return -EINVAL;
-}
-
-static inline void gpio_unexport(unsigned gpio)
-{
-	/* GPIO can never have been exported */
-	WARN_ON(1);
-}
-
 static inline int gpio_to_irq(unsigned gpio)
 {
 	/* GPIO can never have been requested or set as input */
-- 
2.39.1


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

* [PATCH v3 05/12] gpiolib: remove legacy gpio_export
@ 2023-02-07 14:29   ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Eric Dumazet,
	Alim Akhtar, Frank Rowand, Alex Shi, Qiang Zhao, Yanteng Si,
	Yoshinori Sato, Jonathan Corbet, Bartosz Golaszewski, Lee Jones,
	Janusz Krzysztofik, Russell King, Jakub Kicinski, Paolo Abeni,
	Sebastian Hesselbarth, Gregory Clement, Kalle Valo,
	Hante Meuleman, Nicholas Piggin, Rob Herring,
	Mauro Carvalho Chehab, Mika Westerberg, Franky Lin,
	Arend van Spriel, Mun Yew Tham, Hu Haowen, Keerthy,
	Aaro Koskinen, Li Yang, David S. Miller

From: Arnd Bergmann <arnd@arndb.de>

There are only a handful of users of gpio_export() and
related functions.

As these are just wrappers around the modern gpiod_export()
helper, remove the wrappers and open-code the gpio_to_desc
in all callers to shrink the legacy API.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 Documentation/admin-guide/gpio/sysfs.rst      |  2 +-
 Documentation/driver-api/gpio/legacy.rst      | 21 ---------------
 .../zh_CN/driver-api/gpio/legacy.rst          | 19 -------------
 Documentation/translations/zh_TW/gpio.txt     | 18 -------------
 arch/arm/mach-omap2/pdata-quirks.c            |  9 ++++---
 arch/sh/boards/mach-ap325rxa/setup.c          |  7 ++---
 drivers/gpio/gpiolib-sysfs.c                  |  4 +--
 drivers/media/pci/sta2x11/sta2x11_vip.c       | 10 ++++---
 drivers/net/ieee802154/ca8210.c               |  3 ++-
 include/linux/gpio.h                          | 27 -------------------
 10 files changed, 21 insertions(+), 99 deletions(-)

diff --git a/Documentation/admin-guide/gpio/sysfs.rst b/Documentation/admin-guide/gpio/sysfs.rst
index ec09ffd983e7..35171d15f78d 100644
--- a/Documentation/admin-guide/gpio/sysfs.rst
+++ b/Documentation/admin-guide/gpio/sysfs.rst
@@ -145,7 +145,7 @@ requested using gpio_request()::
 	/* export the GPIO to userspace */
 	int gpiod_export(struct gpio_desc *desc, bool direction_may_change);
 
-	/* reverse gpio_export() */
+	/* reverse gpiod_export() */
 	void gpiod_unexport(struct gpio_desc *desc);
 
 	/* create a sysfs link to an exported GPIO node */
diff --git a/Documentation/driver-api/gpio/legacy.rst b/Documentation/driver-api/gpio/legacy.rst
index e0306e78e34b..78372853c6d4 100644
--- a/Documentation/driver-api/gpio/legacy.rst
+++ b/Documentation/driver-api/gpio/legacy.rst
@@ -714,27 +714,6 @@ gpiochip nodes (possibly in conjunction with schematics) to determine
 the correct GPIO number to use for a given signal.
 
 
-Exporting from Kernel code
---------------------------
-Kernel code can explicitly manage exports of GPIOs which have already been
-requested using gpio_request()::
-
-	/* export the GPIO to userspace */
-	int gpio_export(unsigned gpio, bool direction_may_change);
-
-	/* reverse gpio_export() */
-	void gpio_unexport();
-
-After a kernel driver requests a GPIO, it may only be made available in
-the sysfs interface by gpio_export().  The driver can control whether the
-signal direction may change.  This helps drivers prevent userspace code
-from accidentally clobbering important system state.
-
-This explicit exporting can help with debugging (by making some kinds
-of experiments easier), or can provide an always-there interface that's
-suitable for documenting as part of a board support package.
-
-
 API Reference
 =============
 
diff --git a/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst b/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
index dee2a0517c1c..84ce2322fdba 100644
--- a/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
+++ b/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
@@ -653,25 +653,6 @@ GPIO 控制器的路径类似 /sys/class/gpio/gpiochip42/ (对于从#42 GPIO
 确定给定信号所用的 GPIO 编号。
 
 
-从内核代码中导出
-----------------
-
-内核代码可以明确地管理那些已通过 gpio_request()申请的 GPIO 的导出::
-
-	/* 导出 GPIO 到用户空间 */
-	int gpio_export(unsigned gpio, bool direction_may_change);
-
-	/* gpio_export()的逆操作 */
-	void gpio_unexport();
-
-在一个内核驱动申请一个 GPIO 之后,它可以通过 gpio_export()使其在 sysfs
-接口中可见。该驱动可以控制信号方向是否可修改。这有助于防止用户空间代码无意间
-破坏重要的系统状态。
-
-这个明确的导出有助于(通过使某些实验更容易来)调试,也可以提供一个始终存在的接口,
-与文档配合作为板级支持包的一部分。
-
-
 API参考
 =======
 
diff --git a/Documentation/translations/zh_TW/gpio.txt b/Documentation/translations/zh_TW/gpio.txt
index dc608358d90a..62e560ffe628 100644
--- a/Documentation/translations/zh_TW/gpio.txt
+++ b/Documentation/translations/zh_TW/gpio.txt
@@ -614,21 +614,3 @@ GPIO 控制器的路徑類似 /sys/class/gpio/gpiochip42/ (對於從#42 GPIO
 固定的,例如在擴展卡上的 GPIO會根據所使用的主板或所在堆疊架構中其他的板子而
 有所不同。在這種情況下,你可能需要使用 gpiochip 節點(儘可能地結合電路圖)來
 確定給定信號所用的 GPIO 編號。
-
-
-從內核代碼中導出
--------------
-內核代碼可以明確地管理那些已通過 gpio_request()申請的 GPIO 的導出:
-
-	/* 導出 GPIO 到用戶空間 */
-	int gpio_export(unsigned gpio, bool direction_may_change);
-
-	/* gpio_export()的逆操作 */
-	void gpio_unexport();
-
-在一個內核驅動申請一個 GPIO 之後,它可以通過 gpio_export()使其在 sysfs
-接口中可見。該驅動可以控制信號方向是否可修改。這有助於防止用戶空間代碼無意間
-破壞重要的系統狀態。
-
-這個明確的導出有助於(通過使某些實驗更容易來)調試,也可以提供一個始終存在的接口,
-與文檔配合作爲板級支持包的一部分。
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index baba73fd6f11..04208cc52784 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -6,6 +6,7 @@
  */
 #include <linux/clk.h>
 #include <linux/davinci_emac.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -108,7 +109,7 @@ static int omap3_sbc_t3730_twl_callback(struct device *dev,
 	if (res)
 		return res;
 
-	gpio_export(gpio, 0);
+	gpiod_export(gpio_to_desc(gpio), 0);
 
 	return 0;
 }
@@ -123,7 +124,7 @@ static void __init omap3_sbc_t3x_usb_hub_init(int gpio, char *hub_name)
 		return;
 	}
 
-	gpio_export(gpio, 0);
+	gpiod_export(gpio_to_desc(gpio), 0);
 
 	udelay(10);
 	gpio_set_value(gpio, 1);
@@ -200,8 +201,8 @@ static void __init omap3_sbc_t3517_wifi_init(void)
 		return;
 	}
 
-	gpio_export(cm_t3517_wlan_gpios[0].gpio, 0);
-	gpio_export(cm_t3517_wlan_gpios[1].gpio, 0);
+	gpiod_export(gpio_to_desc(cm_t3517_wlan_gpios[0].gpio), 0);
+	gpiod_export(gpio_to_desc(cm_t3517_wlan_gpios[1].gpio), 0);
 
 	msleep(100);
 	gpio_set_value(cm_t3517_wlan_gpios[1].gpio, 0);
diff --git a/arch/sh/boards/mach-ap325rxa/setup.c b/arch/sh/boards/mach-ap325rxa/setup.c
index c77b5f00a66a..151792162152 100644
--- a/arch/sh/boards/mach-ap325rxa/setup.c
+++ b/arch/sh/boards/mach-ap325rxa/setup.c
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio/machine.h>
 #include <linux/i2c.h>
 #include <linux/init.h>
@@ -411,16 +412,16 @@ static int __init ap325rxa_devices_setup(void)
 	/* LD3 and LD4 LEDs */
 	gpio_request(GPIO_PTX5, NULL); /* RUN */
 	gpio_direction_output(GPIO_PTX5, 1);
-	gpio_export(GPIO_PTX5, 0);
+	gpiod_export(gpio_to_desc(GPIO_PTX5), 0);
 
 	gpio_request(GPIO_PTX4, NULL); /* INDICATOR */
 	gpio_direction_output(GPIO_PTX4, 0);
-	gpio_export(GPIO_PTX4, 0);
+	gpiod_export(gpio_to_desc(GPIO_PTX4), 0);
 
 	/* SW1 input */
 	gpio_request(GPIO_PTF7, NULL); /* MODE */
 	gpio_direction_input(GPIO_PTF7);
-	gpio_export(GPIO_PTF7, 0);
+	gpiod_export(gpio_to_desc(GPIO_PTF7), 0);
 
 	/* LCDC */
 	gpio_request(GPIO_FN_LCDD15, NULL);
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index cd27bf173dec..6e4267944f80 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -491,7 +491,7 @@ static ssize_t unexport_store(struct class *class,
 		goto done;
 
 	desc = gpio_to_desc(gpio);
-	/* reject bogus commands (gpio_unexport ignores them) */
+	/* reject bogus commands (gpiod_unexport() ignores them) */
 	if (!desc) {
 		pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);
 		return -EINVAL;
@@ -790,7 +790,7 @@ static int __init gpiolib_sysfs_init(void)
 	 * early (e.g. before the class_register above was called).
 	 *
 	 * We run before arch_initcall() so chip->dev nodes can have
-	 * registered, and so arch_initcall() can always gpio_export().
+	 * registered, and so arch_initcall() can always gpiod_export().
 	 */
 	spin_lock_irqsave(&gpio_lock, flags);
 	list_for_each_entry(gdev, &gpio_devices, list) {
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c
index 8535e49a4c4f..e4cf9d63e926 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -18,6 +18,7 @@
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio.h>
 #include <linux/i2c.h>
 #include <linux/delay.h>
@@ -889,6 +890,7 @@ static int sta2x11_vip_init_controls(struct sta2x11_vip *vip)
 static int vip_gpio_reserve(struct device *dev, int pin, int dir,
 			    const char *name)
 {
+	struct gpio_desc *desc = gpio_to_desc(pin);
 	int ret = -ENODEV;
 
 	if (!gpio_is_valid(pin))
@@ -900,7 +902,7 @@ static int vip_gpio_reserve(struct device *dev, int pin, int dir,
 		return ret;
 	}
 
-	ret = gpio_direction_output(pin, dir);
+	ret = gpiod_direction_output(desc, dir);
 	if (ret) {
 		dev_err(dev, "Failed to set direction for pin %d (%s)\n",
 			pin, name);
@@ -908,7 +910,7 @@ static int vip_gpio_reserve(struct device *dev, int pin, int dir,
 		return ret;
 	}
 
-	ret = gpio_export(pin, false);
+	ret = gpiod_export(desc, false);
 	if (ret) {
 		dev_err(dev, "Failed to export pin %d (%s)\n", pin, name);
 		gpio_free(pin);
@@ -928,8 +930,10 @@ static int vip_gpio_reserve(struct device *dev, int pin, int dir,
 static void vip_gpio_release(struct device *dev, int pin, const char *name)
 {
 	if (gpio_is_valid(pin)) {
+		struct gpio_desc *desc = gpio_to_desc(pin);
+
 		dev_dbg(dev, "releasing pin %d (%s)\n",	pin, name);
-		gpio_unexport(pin);
+		gpiod_unexport(desc);
 		gpio_free(pin);
 	}
 }
diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
index e1a569b99e4a..5c0be6a3ec5e 100644
--- a/drivers/net/ieee802154/ca8210.c
+++ b/drivers/net/ieee802154/ca8210.c
@@ -51,6 +51,7 @@
 #include <linux/clk-provider.h>
 #include <linux/debugfs.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio.h>
 #include <linux/ieee802154.h>
 #include <linux/io.h>
@@ -2853,7 +2854,7 @@ static int ca8210_interrupt_init(struct spi_device *spi)
 	);
 	if (ret) {
 		dev_crit(&spi->dev, "request_irq %d failed\n", pdata->irq_id);
-		gpio_unexport(pdata->gpio_irq);
+		gpiod_unexport(gpio_to_desc(pdata->gpio_irq));
 		gpio_free(pdata->gpio_irq);
 	}
 
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 220e8656f2ab..a1271526e489 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -132,20 +132,6 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
 int gpio_request_array(const struct gpio *array, size_t num);
 void gpio_free_array(const struct gpio *array, size_t num);
 
-/*
- * A sysfs interface can be exported by individual drivers if they want,
- * but more typically is configured entirely from userspace.
- */
-static inline int gpio_export(unsigned gpio, bool direction_may_change)
-{
-	return gpiod_export(gpio_to_desc(gpio), direction_may_change);
-}
-
-static inline void gpio_unexport(unsigned gpio)
-{
-	gpiod_unexport(gpio_to_desc(gpio));
-}
-
 /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */
 
 struct device;
@@ -243,19 +229,6 @@ static inline void gpio_set_value_cansleep(unsigned gpio, int value)
 	WARN_ON(1);
 }
 
-static inline int gpio_export(unsigned gpio, bool direction_may_change)
-{
-	/* GPIO can never have been requested or set as {in,out}put */
-	WARN_ON(1);
-	return -EINVAL;
-}
-
-static inline void gpio_unexport(unsigned gpio)
-{
-	/* GPIO can never have been exported */
-	WARN_ON(1);
-}
-
 static inline int gpio_to_irq(unsigned gpio)
 {
 	/* GPIO can never have been requested or set as input */
-- 
2.39.1


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

* [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
  2023-02-07 14:29 ` Andy Shevchenko
@ 2023-02-07 14:29   ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Bartosz Golaszewski, Jonathan Corbet, Alex Shi, Yanteng Si,
	Hu Haowen, Russell King, Aaro Koskinen, Janusz Krzysztofik,
	Andrew Lunn, Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand

From: Arnd Bergmann <arnd@arndb.de>

Almost all gpio drivers include linux/gpio/driver.h, and other
files should not rely on includes from this header.

Remove the indirect include from here and include the correct
headers directly from where they are used.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/arm/mach-omap1/irq.c                              | 1 +
 arch/arm/mach-orion5x/board-rd88f5182.c                | 1 +
 arch/arm/mach-s3c/s3c64xx.c                            | 1 +
 arch/arm/mach-sa1100/assabet.c                         | 1 +
 arch/arm/plat-orion/gpio.c                             | 1 +
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c | 1 +
 include/linux/gpio.h                                   | 2 --
 include/linux/mfd/ucb1x00.h                            | 1 +
 8 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap1/irq.c b/arch/arm/mach-omap1/irq.c
index 9ccc784fd614..bfc7ab010ae2 100644
--- a/arch/arm/mach-omap1/irq.c
+++ b/arch/arm/mach-omap1/irq.c
@@ -41,6 +41,7 @@
 #include <linux/sched.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/irqdomain.h>
 
 #include <asm/irq.h>
 #include <asm/exception.h>
diff --git a/arch/arm/mach-orion5x/board-rd88f5182.c b/arch/arm/mach-orion5x/board-rd88f5182.c
index 596601367989..1c14e49a90a6 100644
--- a/arch/arm/mach-orion5x/board-rd88f5182.c
+++ b/arch/arm/mach-orion5x/board-rd88f5182.c
@@ -9,6 +9,7 @@
 #include <linux/gpio.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pci.h>
 #include <linux/irq.h>
diff --git a/arch/arm/mach-s3c/s3c64xx.c b/arch/arm/mach-s3c/s3c64xx.c
index e97bd59083a8..48fd5b0a3927 100644
--- a/arch/arm/mach-s3c/s3c64xx.c
+++ b/arch/arm/mach-s3c/s3c64xx.c
@@ -21,6 +21,7 @@
 #include <linux/ioport.h>
 #include <linux/serial_core.h>
 #include <linux/serial_s3c.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/reboot.h>
 #include <linux/io.h>
diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
index 2eba112f2ad8..d000c678b439 100644
--- a/arch/arm/mach-sa1100/assabet.c
+++ b/arch/arm/mach-sa1100/assabet.c
@@ -10,6 +10,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/errno.h>
+#include <linux/gpio/driver.h>
 #include <linux/gpio/gpio-reg.h>
 #include <linux/gpio/machine.h>
 #include <linux/gpio_keys.h>
diff --git a/arch/arm/plat-orion/gpio.c b/arch/arm/plat-orion/gpio.c
index 3ef9ecdd6343..4946d8066f6a 100644
--- a/arch/arm/plat-orion/gpio.c
+++ b/arch/arm/plat-orion/gpio.c
@@ -19,6 +19,7 @@
 #include <linux/bitops.h>
 #include <linux/io.h>
 #include <linux/gpio.h>
+#include <linux/gpio/driver.h>
 #include <linux/leds.h>
 #include <linux/of.h>
 #include <linux/of_irq.h>
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c
index 9540a05247c2..89c8829528c2 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <net/mac80211.h>
 #include <linux/bcma/bcma_driver_chipcommon.h>
+#include <linux/gpio.h>
 #include <linux/gpio/driver.h>
 #include <linux/gpio/machine.h>
 #include <linux/gpio/consumer.h>
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index a1271526e489..84bb49939d6e 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -54,9 +54,7 @@ struct gpio {
 };
 
 #ifdef CONFIG_GPIOLIB
-#include <linux/compiler.h>
 #include <linux/gpio/consumer.h>
-#include <linux/gpio/driver.h>
 
 /*
  * "valid" GPIO numbers are nonnegative and may be passed to
diff --git a/include/linux/mfd/ucb1x00.h b/include/linux/mfd/ucb1x00.h
index 43bcf35afe27..ede237384723 100644
--- a/include/linux/mfd/ucb1x00.h
+++ b/include/linux/mfd/ucb1x00.h
@@ -10,6 +10,7 @@
 #include <linux/device.h>
 #include <linux/mfd/mcp.h>
 #include <linux/gpio.h>
+#include <linux/gpio/driver.h>
 #include <linux/mutex.h>
 
 #define UCB_IO_DATA	0x00
-- 
2.39.1


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

* [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
@ 2023-02-07 14:29   ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Eric Dumazet,
	Alim Akhtar, Frank Rowand, Alex Shi, Qiang Zhao, Yanteng Si,
	Yoshinori Sato, Jonathan Corbet, Bartosz Golaszewski, Lee Jones,
	Janusz Krzysztofik, Russell King, Jakub Kicinski, Paolo Abeni,
	Sebastian Hesselbarth, Gregory Clement, Kalle Valo,
	Hante Meuleman, Nicholas Piggin, Rob Herring,
	Mauro Carvalho Chehab, Mika Westerberg, Franky Lin,
	Arend van Spriel, Mun Yew Tham, Hu Haowen, Keerthy,
	Aaro Koskinen, Li Yang, David S. Miller

From: Arnd Bergmann <arnd@arndb.de>

Almost all gpio drivers include linux/gpio/driver.h, and other
files should not rely on includes from this header.

Remove the indirect include from here and include the correct
headers directly from where they are used.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/arm/mach-omap1/irq.c                              | 1 +
 arch/arm/mach-orion5x/board-rd88f5182.c                | 1 +
 arch/arm/mach-s3c/s3c64xx.c                            | 1 +
 arch/arm/mach-sa1100/assabet.c                         | 1 +
 arch/arm/plat-orion/gpio.c                             | 1 +
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c | 1 +
 include/linux/gpio.h                                   | 2 --
 include/linux/mfd/ucb1x00.h                            | 1 +
 8 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap1/irq.c b/arch/arm/mach-omap1/irq.c
index 9ccc784fd614..bfc7ab010ae2 100644
--- a/arch/arm/mach-omap1/irq.c
+++ b/arch/arm/mach-omap1/irq.c
@@ -41,6 +41,7 @@
 #include <linux/sched.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/irqdomain.h>
 
 #include <asm/irq.h>
 #include <asm/exception.h>
diff --git a/arch/arm/mach-orion5x/board-rd88f5182.c b/arch/arm/mach-orion5x/board-rd88f5182.c
index 596601367989..1c14e49a90a6 100644
--- a/arch/arm/mach-orion5x/board-rd88f5182.c
+++ b/arch/arm/mach-orion5x/board-rd88f5182.c
@@ -9,6 +9,7 @@
 #include <linux/gpio.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pci.h>
 #include <linux/irq.h>
diff --git a/arch/arm/mach-s3c/s3c64xx.c b/arch/arm/mach-s3c/s3c64xx.c
index e97bd59083a8..48fd5b0a3927 100644
--- a/arch/arm/mach-s3c/s3c64xx.c
+++ b/arch/arm/mach-s3c/s3c64xx.c
@@ -21,6 +21,7 @@
 #include <linux/ioport.h>
 #include <linux/serial_core.h>
 #include <linux/serial_s3c.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/reboot.h>
 #include <linux/io.h>
diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
index 2eba112f2ad8..d000c678b439 100644
--- a/arch/arm/mach-sa1100/assabet.c
+++ b/arch/arm/mach-sa1100/assabet.c
@@ -10,6 +10,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/errno.h>
+#include <linux/gpio/driver.h>
 #include <linux/gpio/gpio-reg.h>
 #include <linux/gpio/machine.h>
 #include <linux/gpio_keys.h>
diff --git a/arch/arm/plat-orion/gpio.c b/arch/arm/plat-orion/gpio.c
index 3ef9ecdd6343..4946d8066f6a 100644
--- a/arch/arm/plat-orion/gpio.c
+++ b/arch/arm/plat-orion/gpio.c
@@ -19,6 +19,7 @@
 #include <linux/bitops.h>
 #include <linux/io.h>
 #include <linux/gpio.h>
+#include <linux/gpio/driver.h>
 #include <linux/leds.h>
 #include <linux/of.h>
 #include <linux/of_irq.h>
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c
index 9540a05247c2..89c8829528c2 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <net/mac80211.h>
 #include <linux/bcma/bcma_driver_chipcommon.h>
+#include <linux/gpio.h>
 #include <linux/gpio/driver.h>
 #include <linux/gpio/machine.h>
 #include <linux/gpio/consumer.h>
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index a1271526e489..84bb49939d6e 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -54,9 +54,7 @@ struct gpio {
 };
 
 #ifdef CONFIG_GPIOLIB
-#include <linux/compiler.h>
 #include <linux/gpio/consumer.h>
-#include <linux/gpio/driver.h>
 
 /*
  * "valid" GPIO numbers are nonnegative and may be passed to
diff --git a/include/linux/mfd/ucb1x00.h b/include/linux/mfd/ucb1x00.h
index 43bcf35afe27..ede237384723 100644
--- a/include/linux/mfd/ucb1x00.h
+++ b/include/linux/mfd/ucb1x00.h
@@ -10,6 +10,7 @@
 #include <linux/device.h>
 #include <linux/mfd/mcp.h>
 #include <linux/gpio.h>
+#include <linux/gpio/driver.h>
 #include <linux/mutex.h>
 
 #define UCB_IO_DATA	0x00
-- 
2.39.1


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

* [PATCH v3 07/12] gpiolib: split of_mm_gpio_chip out of linux/of_gpio.h
  2023-02-07 14:29 ` Andy Shevchenko
@ 2023-02-07 14:29   ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Bartosz Golaszewski, Jonathan Corbet, Alex Shi, Yanteng Si,
	Hu Haowen, Russell King, Aaro Koskinen, Janusz Krzysztofik,
	Andrew Lunn, Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand

From: Arnd Bergmann <arnd@arndb.de>

This is a rarely used feature that has nothing to do with the
client-side of_gpio.h.

Split it out with a separate header file and Kconfig option
so it can be removed on its own timeline aside from removing
the of_gpio consumer interfaces.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/powerpc/platforms/44x/Kconfig            |  1 +
 arch/powerpc/platforms/4xx/gpio.c             |  2 +-
 arch/powerpc/platforms/8xx/Kconfig            |  1 +
 arch/powerpc/platforms/8xx/cpm1.c             |  2 +-
 arch/powerpc/platforms/Kconfig                |  2 ++
 arch/powerpc/sysdev/cpm_common.c              |  2 +-
 drivers/gpio/Kconfig                          | 11 +++++++
 drivers/gpio/TODO                             | 15 ++++++---
 drivers/gpio/gpio-altera.c                    |  2 +-
 drivers/gpio/gpio-mm-lantiq.c                 |  2 +-
 drivers/gpio/gpio-mpc5200.c                   |  2 +-
 drivers/gpio/gpiolib-of.c                     |  3 ++
 drivers/soc/fsl/qe/gpio.c                     |  2 +-
 .../legacy-of-mm-gpiochip.h}                  | 33 +++----------------
 include/linux/of_gpio.h                       | 21 ------------
 15 files changed, 40 insertions(+), 61 deletions(-)
 copy include/linux/{of_gpio.h => gpio/legacy-of-mm-gpiochip.h} (50%)

diff --git a/arch/powerpc/platforms/44x/Kconfig b/arch/powerpc/platforms/44x/Kconfig
index 25b80cd558f8..1624ebf95497 100644
--- a/arch/powerpc/platforms/44x/Kconfig
+++ b/arch/powerpc/platforms/44x/Kconfig
@@ -230,6 +230,7 @@ config PPC4xx_GPIO
 	bool "PPC4xx GPIO support"
 	depends on 44x
 	select GPIOLIB
+	select OF_GPIO_MM_GPIOCHIP
 	help
 	  Enable gpiolib support for ppc440 based boards
 
diff --git a/arch/powerpc/platforms/4xx/gpio.c b/arch/powerpc/platforms/4xx/gpio.c
index 49ee8d365852..e5f2319e5cbe 100644
--- a/arch/powerpc/platforms/4xx/gpio.c
+++ b/arch/powerpc/platforms/4xx/gpio.c
@@ -14,7 +14,7 @@
 #include <linux/spinlock.h>
 #include <linux/io.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #include <linux/gpio/driver.h>
 #include <linux/types.h>
 #include <linux/slab.h>
diff --git a/arch/powerpc/platforms/8xx/Kconfig b/arch/powerpc/platforms/8xx/Kconfig
index 60cc5b537a98..a14d9d8997a4 100644
--- a/arch/powerpc/platforms/8xx/Kconfig
+++ b/arch/powerpc/platforms/8xx/Kconfig
@@ -101,6 +101,7 @@ comment "Generic MPC8xx Options"
 config 8xx_GPIO
 	bool "GPIO API Support"
 	select GPIOLIB
+	select OF_GPIO_MM_GPIOCHIP
 	help
 	  Saying Y here will cause the ports on an MPC8xx processor to be used
 	  with the GPIO API.  If you say N here, the kernel needs less memory.
diff --git a/arch/powerpc/platforms/8xx/cpm1.c b/arch/powerpc/platforms/8xx/cpm1.c
index bb38c8d8f8de..56ca14f77543 100644
--- a/arch/powerpc/platforms/8xx/cpm1.c
+++ b/arch/powerpc/platforms/8xx/cpm1.c
@@ -44,7 +44,7 @@
 #include <asm/fs_pd.h>
 
 #ifdef CONFIG_8xx_GPIO
-#include <linux/of_gpio.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #endif
 
 #define CPM_MAP_SIZE    (0x4000)
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index d41dad227de8..8e4bbd19dec5 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -244,6 +244,7 @@ config QE_GPIO
 	bool "QE GPIO support"
 	depends on QUICC_ENGINE
 	select GPIOLIB
+	select OF_GPIO_MM_GPIOCHIP
 	help
 	  Say Y here if you're going to use hardware that connects to the
 	  QE GPIOs.
@@ -254,6 +255,7 @@ config CPM2
 	select CPM
 	select HAVE_PCI
 	select GPIOLIB
+	select OF_GPIO_MM_GPIOCHIP
 	help
 	  The CPM2 (Communications Processor Module) is a coprocessor on
 	  embedded CPUs made by Freescale.  Selecting this option means that
diff --git a/arch/powerpc/sysdev/cpm_common.c b/arch/powerpc/sysdev/cpm_common.c
index 7dc1960f8bdb..8234013a8772 100644
--- a/arch/powerpc/sysdev/cpm_common.c
+++ b/arch/powerpc/sysdev/cpm_common.c
@@ -31,7 +31,7 @@
 #include <mm/mmu_decl.h>
 
 #if defined(CONFIG_CPM2) || defined(CONFIG_8xx_GPIO)
-#include <linux/of_gpio.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #endif
 
 static int __init cpm_init(void)
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 06a268d56800..178025ca3b34 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -39,6 +39,14 @@ config GPIOLIB_IRQCHIP
 	select IRQ_DOMAIN
 	bool
 
+config OF_GPIO_MM_GPIOCHIP
+	bool
+	help
+	  This adds support for the legacy 'struct of_mm_gpio_chip' interface
+	  from PowerPC. Existing drivers using this interface need to select
+	  this symbol, but new drivers should use the generic gpio-regmap
+	  infrastructure instead.
+
 config DEBUG_GPIO
 	bool "Debug GPIO calls"
 	depends on DEBUG_KERNEL
@@ -131,6 +139,7 @@ config GPIO_ALTERA
 	tristate "Altera GPIO"
 	depends on OF_GPIO
 	select GPIOLIB_IRQCHIP
+	select OF_GPIO_MM_GPIOCHIP
 	help
 	  Say Y or M here to build support for the Altera PIO device.
 
@@ -403,6 +412,7 @@ config GPIO_MENZ127
 config GPIO_MM_LANTIQ
 	bool "Lantiq Memory mapped GPIOs"
 	depends on LANTIQ && SOC_XWAY
+	select OF_GPIO_MM_GPIOCHIP
 	help
 	  This enables support for memory mapped GPIOs on the External Bus Unit
 	  (EBU) found on Lantiq SoCs. The GPIOs are output only as they are
@@ -411,6 +421,7 @@ config GPIO_MM_LANTIQ
 config GPIO_MPC5200
 	def_bool y
 	depends on PPC_MPC52xx
+	select OF_GPIO_MM_GPIOCHIP
 
 config GPIO_MPC8XXX
 	bool "MPC512x/MPC8xxx/QorIQ GPIO support"
diff --git a/drivers/gpio/TODO b/drivers/gpio/TODO
index 68ada1066941..189c3abe7e79 100644
--- a/drivers/gpio/TODO
+++ b/drivers/gpio/TODO
@@ -59,11 +59,6 @@ the device tree back-end. It is legacy and should not be used in new code.
 
 Work items:
 
-- Get rid of struct of_mm_gpio_chip altogether: use the generic  MMIO
-  GPIO for all current users (see below). Delete struct of_mm_gpio_chip,
-  to_of_mm_gpio_chip(), of_mm_gpiochip_add_data(), of_mm_gpiochip_remove()
-  from the kernel.
-
 - Change all consumer drivers that #include <linux/of_gpio.h> to
   #include <linux/gpio/consumer.h> and stop doing custom parsing of the
   GPIO lines from the device tree. This can be tricky and often ivolves
@@ -81,6 +76,16 @@ Work items:
   uses <linux/gpio/consumer.h> or <linux/gpio/driver.h> instead.
 
 
+Get rid of <linux/gpio/legacy-of-mm-gpiochip.h>
+
+Work items:
+
+- Get rid of struct of_mm_gpio_chip altogether: use the generic  MMIO
+  GPIO for all current users (see below). Delete struct of_mm_gpio_chip,
+  to_of_mm_gpio_chip(), of_mm_gpiochip_add_data(), of_mm_gpiochip_remove(),
+  CONFIG_OF_GPIO_MM_GPIOCHIP from the kernel.
+
+
 Get rid of <linux/gpio.h>
 
 This legacy header is a one stop shop for anything GPIO is closely tied
diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c
index b59fae993626..99e137f8097e 100644
--- a/drivers/gpio/gpio-altera.c
+++ b/drivers/gpio/gpio-altera.c
@@ -7,7 +7,7 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/gpio/driver.h>
-#include <linux/of_gpio.h> /* For of_mm_gpio_chip */
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #include <linux/platform_device.h>
 
 #define ALTERA_GPIO_MAX_NGPIO		32
diff --git a/drivers/gpio/gpio-mm-lantiq.c b/drivers/gpio/gpio-mm-lantiq.c
index 538e31fe8903..27ff84c5d162 100644
--- a/drivers/gpio/gpio-mm-lantiq.c
+++ b/drivers/gpio/gpio-mm-lantiq.c
@@ -10,8 +10,8 @@
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
 #include <linux/gpio/driver.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
 #include <linux/io.h>
 #include <linux/slab.h>
 
diff --git a/drivers/gpio/gpio-mpc5200.c b/drivers/gpio/gpio-mpc5200.c
index 000494e0c533..3b0bfff8c778 100644
--- a/drivers/gpio/gpio-mpc5200.c
+++ b/drivers/gpio/gpio-mpc5200.c
@@ -8,7 +8,7 @@
 #include <linux/of.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #include <linux/io.h>
 #include <linux/of_platform.h>
 #include <linux/module.h>
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 266352b1a966..0f699af438b0 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -892,6 +892,8 @@ static int of_gpio_simple_xlate(struct gpio_chip *gc,
 	return gpiospec->args[0];
 }
 
+#if IS_ENABLED(CONFIG_OF_GPIO_MM_GPIOCHIP)
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 /**
  * of_mm_gpiochip_add_data - Add memory mapped GPIO chip (bank)
  * @np:		device node of the GPIO chip
@@ -964,6 +966,7 @@ void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc)
 	kfree(gc->label);
 }
 EXPORT_SYMBOL_GPL(of_mm_gpiochip_remove);
+#endif
 
 #ifdef CONFIG_PINCTRL
 static int of_gpiochip_add_pin_range(struct gpio_chip *chip)
diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
index 1c41eb49d5a7..3ef24ba0245b 100644
--- a/drivers/soc/fsl/qe/gpio.c
+++ b/drivers/soc/fsl/qe/gpio.c
@@ -13,7 +13,7 @@
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>	/* for of_mm_gpio_chip */
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/slab.h>
diff --git a/include/linux/of_gpio.h b/include/linux/gpio/legacy-of-mm-gpiochip.h
similarity index 50%
copy from include/linux/of_gpio.h
copy to include/linux/gpio/legacy-of-mm-gpiochip.h
index 5d58b3b0a97e..2e2bd3b19cc3 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/gpio/legacy-of-mm-gpiochip.h
@@ -1,26 +1,19 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * OF helpers for the GPIO API
+ * OF helpers for the old of_mm_gpio_chip, used on ppc32 and nios2,
+ * do not use in new code.
  *
  * Copyright (c) 2007-2008  MontaVista Software, Inc.
  *
  * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
  */
 
-#ifndef __LINUX_OF_GPIO_H
-#define __LINUX_OF_GPIO_H
+#ifndef __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H
+#define __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H
 
-#include <linux/compiler.h>
 #include <linux/gpio/driver.h>
-#include <linux/gpio.h>		/* FIXME: Shouldn't be here */
 #include <linux/of.h>
 
-struct device_node;
-
-#ifdef CONFIG_OF_GPIO
-
-#include <linux/container_of.h>
-
 /*
  * OF GPIO chip for memory mapped banks
  */
@@ -35,25 +28,9 @@ static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
 	return container_of(gc, struct of_mm_gpio_chip, gc);
 }
 
-extern int of_get_named_gpio(const struct device_node *np,
-			     const char *list_name, int index);
-
 extern int of_mm_gpiochip_add_data(struct device_node *np,
 				   struct of_mm_gpio_chip *mm_gc,
 				   void *data);
 extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc);
 
-#else /* CONFIG_OF_GPIO */
-
-#include <linux/errno.h>
-
-/* Drivers may not strictly depend on the GPIO support, so let them link. */
-static inline int of_get_named_gpio(const struct device_node *np,
-                                   const char *propname, int index)
-{
-	return -ENOSYS;
-}
-
-#endif /* CONFIG_OF_GPIO */
-
-#endif /* __LINUX_OF_GPIO_H */
+#endif /* __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H */
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index 5d58b3b0a97e..d0f66a5e1b2a 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -19,30 +19,9 @@ struct device_node;
 
 #ifdef CONFIG_OF_GPIO
 
-#include <linux/container_of.h>
-
-/*
- * OF GPIO chip for memory mapped banks
- */
-struct of_mm_gpio_chip {
-	struct gpio_chip gc;
-	void (*save_regs)(struct of_mm_gpio_chip *mm_gc);
-	void __iomem *regs;
-};
-
-static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
-{
-	return container_of(gc, struct of_mm_gpio_chip, gc);
-}
-
 extern int of_get_named_gpio(const struct device_node *np,
 			     const char *list_name, int index);
 
-extern int of_mm_gpiochip_add_data(struct device_node *np,
-				   struct of_mm_gpio_chip *mm_gc,
-				   void *data);
-extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc);
-
 #else /* CONFIG_OF_GPIO */
 
 #include <linux/errno.h>
-- 
2.39.1


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

* [PATCH v3 07/12] gpiolib: split of_mm_gpio_chip out of linux/of_gpio.h
@ 2023-02-07 14:29   ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Eric Dumazet,
	Alim Akhtar, Frank Rowand, Alex Shi, Qiang Zhao, Yanteng Si,
	Yoshinori Sato, Jonathan Corbet, Bartosz Golaszewski, Lee Jones,
	Janusz Krzysztofik, Russell King, Jakub Kicinski, Paolo Abeni,
	Sebastian Hesselbarth, Gregory Clement, Kalle Valo,
	Hante Meuleman, Nicholas Piggin, Rob Herring,
	Mauro Carvalho Chehab, Mika Westerberg, Franky Lin,
	Arend van Spriel, Mun Yew Tham, Hu Haowen, Keerthy,
	Aaro Koskinen, Li Yang, David S. Miller

From: Arnd Bergmann <arnd@arndb.de>

This is a rarely used feature that has nothing to do with the
client-side of_gpio.h.

Split it out with a separate header file and Kconfig option
so it can be removed on its own timeline aside from removing
the of_gpio consumer interfaces.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/powerpc/platforms/44x/Kconfig            |  1 +
 arch/powerpc/platforms/4xx/gpio.c             |  2 +-
 arch/powerpc/platforms/8xx/Kconfig            |  1 +
 arch/powerpc/platforms/8xx/cpm1.c             |  2 +-
 arch/powerpc/platforms/Kconfig                |  2 ++
 arch/powerpc/sysdev/cpm_common.c              |  2 +-
 drivers/gpio/Kconfig                          | 11 +++++++
 drivers/gpio/TODO                             | 15 ++++++---
 drivers/gpio/gpio-altera.c                    |  2 +-
 drivers/gpio/gpio-mm-lantiq.c                 |  2 +-
 drivers/gpio/gpio-mpc5200.c                   |  2 +-
 drivers/gpio/gpiolib-of.c                     |  3 ++
 drivers/soc/fsl/qe/gpio.c                     |  2 +-
 .../legacy-of-mm-gpiochip.h}                  | 33 +++----------------
 include/linux/of_gpio.h                       | 21 ------------
 15 files changed, 40 insertions(+), 61 deletions(-)
 copy include/linux/{of_gpio.h => gpio/legacy-of-mm-gpiochip.h} (50%)

diff --git a/arch/powerpc/platforms/44x/Kconfig b/arch/powerpc/platforms/44x/Kconfig
index 25b80cd558f8..1624ebf95497 100644
--- a/arch/powerpc/platforms/44x/Kconfig
+++ b/arch/powerpc/platforms/44x/Kconfig
@@ -230,6 +230,7 @@ config PPC4xx_GPIO
 	bool "PPC4xx GPIO support"
 	depends on 44x
 	select GPIOLIB
+	select OF_GPIO_MM_GPIOCHIP
 	help
 	  Enable gpiolib support for ppc440 based boards
 
diff --git a/arch/powerpc/platforms/4xx/gpio.c b/arch/powerpc/platforms/4xx/gpio.c
index 49ee8d365852..e5f2319e5cbe 100644
--- a/arch/powerpc/platforms/4xx/gpio.c
+++ b/arch/powerpc/platforms/4xx/gpio.c
@@ -14,7 +14,7 @@
 #include <linux/spinlock.h>
 #include <linux/io.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #include <linux/gpio/driver.h>
 #include <linux/types.h>
 #include <linux/slab.h>
diff --git a/arch/powerpc/platforms/8xx/Kconfig b/arch/powerpc/platforms/8xx/Kconfig
index 60cc5b537a98..a14d9d8997a4 100644
--- a/arch/powerpc/platforms/8xx/Kconfig
+++ b/arch/powerpc/platforms/8xx/Kconfig
@@ -101,6 +101,7 @@ comment "Generic MPC8xx Options"
 config 8xx_GPIO
 	bool "GPIO API Support"
 	select GPIOLIB
+	select OF_GPIO_MM_GPIOCHIP
 	help
 	  Saying Y here will cause the ports on an MPC8xx processor to be used
 	  with the GPIO API.  If you say N here, the kernel needs less memory.
diff --git a/arch/powerpc/platforms/8xx/cpm1.c b/arch/powerpc/platforms/8xx/cpm1.c
index bb38c8d8f8de..56ca14f77543 100644
--- a/arch/powerpc/platforms/8xx/cpm1.c
+++ b/arch/powerpc/platforms/8xx/cpm1.c
@@ -44,7 +44,7 @@
 #include <asm/fs_pd.h>
 
 #ifdef CONFIG_8xx_GPIO
-#include <linux/of_gpio.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #endif
 
 #define CPM_MAP_SIZE    (0x4000)
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index d41dad227de8..8e4bbd19dec5 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -244,6 +244,7 @@ config QE_GPIO
 	bool "QE GPIO support"
 	depends on QUICC_ENGINE
 	select GPIOLIB
+	select OF_GPIO_MM_GPIOCHIP
 	help
 	  Say Y here if you're going to use hardware that connects to the
 	  QE GPIOs.
@@ -254,6 +255,7 @@ config CPM2
 	select CPM
 	select HAVE_PCI
 	select GPIOLIB
+	select OF_GPIO_MM_GPIOCHIP
 	help
 	  The CPM2 (Communications Processor Module) is a coprocessor on
 	  embedded CPUs made by Freescale.  Selecting this option means that
diff --git a/arch/powerpc/sysdev/cpm_common.c b/arch/powerpc/sysdev/cpm_common.c
index 7dc1960f8bdb..8234013a8772 100644
--- a/arch/powerpc/sysdev/cpm_common.c
+++ b/arch/powerpc/sysdev/cpm_common.c
@@ -31,7 +31,7 @@
 #include <mm/mmu_decl.h>
 
 #if defined(CONFIG_CPM2) || defined(CONFIG_8xx_GPIO)
-#include <linux/of_gpio.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #endif
 
 static int __init cpm_init(void)
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 06a268d56800..178025ca3b34 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -39,6 +39,14 @@ config GPIOLIB_IRQCHIP
 	select IRQ_DOMAIN
 	bool
 
+config OF_GPIO_MM_GPIOCHIP
+	bool
+	help
+	  This adds support for the legacy 'struct of_mm_gpio_chip' interface
+	  from PowerPC. Existing drivers using this interface need to select
+	  this symbol, but new drivers should use the generic gpio-regmap
+	  infrastructure instead.
+
 config DEBUG_GPIO
 	bool "Debug GPIO calls"
 	depends on DEBUG_KERNEL
@@ -131,6 +139,7 @@ config GPIO_ALTERA
 	tristate "Altera GPIO"
 	depends on OF_GPIO
 	select GPIOLIB_IRQCHIP
+	select OF_GPIO_MM_GPIOCHIP
 	help
 	  Say Y or M here to build support for the Altera PIO device.
 
@@ -403,6 +412,7 @@ config GPIO_MENZ127
 config GPIO_MM_LANTIQ
 	bool "Lantiq Memory mapped GPIOs"
 	depends on LANTIQ && SOC_XWAY
+	select OF_GPIO_MM_GPIOCHIP
 	help
 	  This enables support for memory mapped GPIOs on the External Bus Unit
 	  (EBU) found on Lantiq SoCs. The GPIOs are output only as they are
@@ -411,6 +421,7 @@ config GPIO_MM_LANTIQ
 config GPIO_MPC5200
 	def_bool y
 	depends on PPC_MPC52xx
+	select OF_GPIO_MM_GPIOCHIP
 
 config GPIO_MPC8XXX
 	bool "MPC512x/MPC8xxx/QorIQ GPIO support"
diff --git a/drivers/gpio/TODO b/drivers/gpio/TODO
index 68ada1066941..189c3abe7e79 100644
--- a/drivers/gpio/TODO
+++ b/drivers/gpio/TODO
@@ -59,11 +59,6 @@ the device tree back-end. It is legacy and should not be used in new code.
 
 Work items:
 
-- Get rid of struct of_mm_gpio_chip altogether: use the generic  MMIO
-  GPIO for all current users (see below). Delete struct of_mm_gpio_chip,
-  to_of_mm_gpio_chip(), of_mm_gpiochip_add_data(), of_mm_gpiochip_remove()
-  from the kernel.
-
 - Change all consumer drivers that #include <linux/of_gpio.h> to
   #include <linux/gpio/consumer.h> and stop doing custom parsing of the
   GPIO lines from the device tree. This can be tricky and often ivolves
@@ -81,6 +76,16 @@ Work items:
   uses <linux/gpio/consumer.h> or <linux/gpio/driver.h> instead.
 
 
+Get rid of <linux/gpio/legacy-of-mm-gpiochip.h>
+
+Work items:
+
+- Get rid of struct of_mm_gpio_chip altogether: use the generic  MMIO
+  GPIO for all current users (see below). Delete struct of_mm_gpio_chip,
+  to_of_mm_gpio_chip(), of_mm_gpiochip_add_data(), of_mm_gpiochip_remove(),
+  CONFIG_OF_GPIO_MM_GPIOCHIP from the kernel.
+
+
 Get rid of <linux/gpio.h>
 
 This legacy header is a one stop shop for anything GPIO is closely tied
diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c
index b59fae993626..99e137f8097e 100644
--- a/drivers/gpio/gpio-altera.c
+++ b/drivers/gpio/gpio-altera.c
@@ -7,7 +7,7 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/gpio/driver.h>
-#include <linux/of_gpio.h> /* For of_mm_gpio_chip */
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #include <linux/platform_device.h>
 
 #define ALTERA_GPIO_MAX_NGPIO		32
diff --git a/drivers/gpio/gpio-mm-lantiq.c b/drivers/gpio/gpio-mm-lantiq.c
index 538e31fe8903..27ff84c5d162 100644
--- a/drivers/gpio/gpio-mm-lantiq.c
+++ b/drivers/gpio/gpio-mm-lantiq.c
@@ -10,8 +10,8 @@
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
 #include <linux/gpio/driver.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
 #include <linux/io.h>
 #include <linux/slab.h>
 
diff --git a/drivers/gpio/gpio-mpc5200.c b/drivers/gpio/gpio-mpc5200.c
index 000494e0c533..3b0bfff8c778 100644
--- a/drivers/gpio/gpio-mpc5200.c
+++ b/drivers/gpio/gpio-mpc5200.c
@@ -8,7 +8,7 @@
 #include <linux/of.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #include <linux/io.h>
 #include <linux/of_platform.h>
 #include <linux/module.h>
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 266352b1a966..0f699af438b0 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -892,6 +892,8 @@ static int of_gpio_simple_xlate(struct gpio_chip *gc,
 	return gpiospec->args[0];
 }
 
+#if IS_ENABLED(CONFIG_OF_GPIO_MM_GPIOCHIP)
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 /**
  * of_mm_gpiochip_add_data - Add memory mapped GPIO chip (bank)
  * @np:		device node of the GPIO chip
@@ -964,6 +966,7 @@ void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc)
 	kfree(gc->label);
 }
 EXPORT_SYMBOL_GPL(of_mm_gpiochip_remove);
+#endif
 
 #ifdef CONFIG_PINCTRL
 static int of_gpiochip_add_pin_range(struct gpio_chip *chip)
diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
index 1c41eb49d5a7..3ef24ba0245b 100644
--- a/drivers/soc/fsl/qe/gpio.c
+++ b/drivers/soc/fsl/qe/gpio.c
@@ -13,7 +13,7 @@
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>	/* for of_mm_gpio_chip */
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/slab.h>
diff --git a/include/linux/of_gpio.h b/include/linux/gpio/legacy-of-mm-gpiochip.h
similarity index 50%
copy from include/linux/of_gpio.h
copy to include/linux/gpio/legacy-of-mm-gpiochip.h
index 5d58b3b0a97e..2e2bd3b19cc3 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/gpio/legacy-of-mm-gpiochip.h
@@ -1,26 +1,19 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * OF helpers for the GPIO API
+ * OF helpers for the old of_mm_gpio_chip, used on ppc32 and nios2,
+ * do not use in new code.
  *
  * Copyright (c) 2007-2008  MontaVista Software, Inc.
  *
  * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
  */
 
-#ifndef __LINUX_OF_GPIO_H
-#define __LINUX_OF_GPIO_H
+#ifndef __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H
+#define __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H
 
-#include <linux/compiler.h>
 #include <linux/gpio/driver.h>
-#include <linux/gpio.h>		/* FIXME: Shouldn't be here */
 #include <linux/of.h>
 
-struct device_node;
-
-#ifdef CONFIG_OF_GPIO
-
-#include <linux/container_of.h>
-
 /*
  * OF GPIO chip for memory mapped banks
  */
@@ -35,25 +28,9 @@ static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
 	return container_of(gc, struct of_mm_gpio_chip, gc);
 }
 
-extern int of_get_named_gpio(const struct device_node *np,
-			     const char *list_name, int index);
-
 extern int of_mm_gpiochip_add_data(struct device_node *np,
 				   struct of_mm_gpio_chip *mm_gc,
 				   void *data);
 extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc);
 
-#else /* CONFIG_OF_GPIO */
-
-#include <linux/errno.h>
-
-/* Drivers may not strictly depend on the GPIO support, so let them link. */
-static inline int of_get_named_gpio(const struct device_node *np,
-                                   const char *propname, int index)
-{
-	return -ENOSYS;
-}
-
-#endif /* CONFIG_OF_GPIO */
-
-#endif /* __LINUX_OF_GPIO_H */
+#endif /* __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H */
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index 5d58b3b0a97e..d0f66a5e1b2a 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -19,30 +19,9 @@ struct device_node;
 
 #ifdef CONFIG_OF_GPIO
 
-#include <linux/container_of.h>
-
-/*
- * OF GPIO chip for memory mapped banks
- */
-struct of_mm_gpio_chip {
-	struct gpio_chip gc;
-	void (*save_regs)(struct of_mm_gpio_chip *mm_gc);
-	void __iomem *regs;
-};
-
-static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
-{
-	return container_of(gc, struct of_mm_gpio_chip, gc);
-}
-
 extern int of_get_named_gpio(const struct device_node *np,
 			     const char *list_name, int index);
 
-extern int of_mm_gpiochip_add_data(struct device_node *np,
-				   struct of_mm_gpio_chip *mm_gc,
-				   void *data);
-extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc);
-
 #else /* CONFIG_OF_GPIO */
 
 #include <linux/errno.h>
-- 
2.39.1


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

* [PATCH v3 08/12] gpio: aggregator: Add missing header(s)
  2023-02-07 14:29 ` Andy Shevchenko
@ 2023-02-07 14:29   ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Bartosz Golaszewski, Jonathan Corbet, Alex Shi, Yanteng Si,
	Hu Haowen, Russell King, Aaro Koskinen, Janusz Krzysztofik,
	Andrew Lunn, Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand

Do not imply that some of the generic headers may be always included.
Instead, include explicitly what we are direct user of.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-aggregator.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c
index 6d17d262ad91..20a686f12df7 100644
--- a/drivers/gpio/gpio-aggregator.c
+++ b/drivers/gpio/gpio-aggregator.c
@@ -10,19 +10,20 @@
 #include <linux/bitmap.h>
 #include <linux/bitops.h>
 #include <linux/ctype.h>
-#include <linux/gpio.h>
-#include <linux/gpio/consumer.h>
-#include <linux/gpio/driver.h>
-#include <linux/gpio/machine.h>
 #include <linux/idr.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/overflow.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
 
+#include <linux/gpio/consumer.h>
+#include <linux/gpio/driver.h>
+#include <linux/gpio/machine.h>
+
 #define AGGREGATOR_MAX_GPIOS 512
 
 /*
-- 
2.39.1


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

* [PATCH v3 08/12] gpio: aggregator: Add missing header(s)
@ 2023-02-07 14:29   ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Eric Dumazet,
	Alim Akhtar, Frank Rowand, Alex Shi, Qiang Zhao, Yanteng Si,
	Yoshinori Sato, Jonathan Corbet, Bartosz Golaszewski, Lee Jones,
	Janusz Krzysztofik, Russell King, Jakub Kicinski, Paolo Abeni,
	Sebastian Hesselbarth, Gregory Clement, Kalle Valo,
	Hante Meuleman, Nicholas Piggin, Rob Herring,
	Mauro Carvalho Chehab, Mika Westerberg, Franky Lin,
	Arend van Spriel, Mun Yew Tham, Hu Haowen, Keerthy,
	Aaro Koskinen, Li Yang, David S. Miller

Do not imply that some of the generic headers may be always included.
Instead, include explicitly what we are direct user of.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-aggregator.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c
index 6d17d262ad91..20a686f12df7 100644
--- a/drivers/gpio/gpio-aggregator.c
+++ b/drivers/gpio/gpio-aggregator.c
@@ -10,19 +10,20 @@
 #include <linux/bitmap.h>
 #include <linux/bitops.h>
 #include <linux/ctype.h>
-#include <linux/gpio.h>
-#include <linux/gpio/consumer.h>
-#include <linux/gpio/driver.h>
-#include <linux/gpio/machine.h>
 #include <linux/idr.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/overflow.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
 
+#include <linux/gpio/consumer.h>
+#include <linux/gpio/driver.h>
+#include <linux/gpio/machine.h>
+
 #define AGGREGATOR_MAX_GPIOS 512
 
 /*
-- 
2.39.1


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

* [PATCH v3 09/12] gpiolib: Drop unused forward declaration from driver.h
  2023-02-07 14:29 ` Andy Shevchenko
@ 2023-02-07 14:29   ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Bartosz Golaszewski, Jonathan Corbet, Alex Shi, Yanteng Si,
	Hu Haowen, Russell King, Aaro Koskinen, Janusz Krzysztofik,
	Andrew Lunn, Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand

There is no struct device_node pointers anywhere in the header,
drop unused forward declaration.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/gpio/driver.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index ccd8a512d854..262a84ce9bcb 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -16,7 +16,6 @@
 
 struct gpio_desc;
 struct of_phandle_args;
-struct device_node;
 struct seq_file;
 struct gpio_device;
 struct module;
-- 
2.39.1


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

* [PATCH v3 09/12] gpiolib: Drop unused forward declaration from driver.h
@ 2023-02-07 14:29   ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Eric Dumazet,
	Alim Akhtar, Frank Rowand, Alex Shi, Qiang Zhao, Yanteng Si,
	Yoshinori Sato, Jonathan Corbet, Bartosz Golaszewski, Lee Jones,
	Janusz Krzysztofik, Russell King, Jakub Kicinski, Paolo Abeni,
	Sebastian Hesselbarth, Gregory Clement, Kalle Valo,
	Hante Meuleman, Nicholas Piggin, Rob Herring,
	Mauro Carvalho Chehab, Mika Westerberg, Franky Lin,
	Arend van Spriel, Mun Yew Tham, Hu Haowen, Keerthy,
	Aaro Koskinen, Li Yang, David S. Miller

There is no struct device_node pointers anywhere in the header,
drop unused forward declaration.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/gpio/driver.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index ccd8a512d854..262a84ce9bcb 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -16,7 +16,6 @@
 
 struct gpio_desc;
 struct of_phandle_args;
-struct device_node;
 struct seq_file;
 struct gpio_device;
 struct module;
-- 
2.39.1


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

* [PATCH v3 10/12] gpiolib: Deduplicate forward declarations in consumer.h
  2023-02-07 14:29 ` Andy Shevchenko
@ 2023-02-07 14:29   ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Bartosz Golaszewski, Jonathan Corbet, Alex Shi, Yanteng Si,
	Hu Haowen, Russell King, Aaro Koskinen, Janusz Krzysztofik,
	Andrew Lunn, Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand

The struct fwnode_handle pointer is used in both branches of ifdeffery,
no need to have a copy of the same in each of them, just make it global.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/gpio/consumer.h | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 59cb20cfac3d..a7eb8aa1e54c 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -8,6 +8,7 @@
 #include <linux/err.h>
 
 struct device;
+struct fwnode_handle;
 struct gpio_desc;
 struct gpio_array;
 
@@ -171,9 +172,6 @@ int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name);
 struct gpio_desc *gpio_to_desc(unsigned gpio);
 int desc_to_gpio(const struct gpio_desc *desc);
 
-/* Child properties interface */
-struct fwnode_handle;
-
 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
 					 const char *con_id, int index,
 					 enum gpiod_flags flags,
@@ -546,9 +544,6 @@ static inline int desc_to_gpio(const struct gpio_desc *desc)
 	return -EINVAL;
 }
 
-/* Child properties interface */
-struct fwnode_handle;
-
 static inline
 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
 					 const char *con_id, int index,
-- 
2.39.1


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

* [PATCH v3 10/12] gpiolib: Deduplicate forward declarations in consumer.h
@ 2023-02-07 14:29   ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Eric Dumazet,
	Alim Akhtar, Frank Rowand, Alex Shi, Qiang Zhao, Yanteng Si,
	Yoshinori Sato, Jonathan Corbet, Bartosz Golaszewski, Lee Jones,
	Janusz Krzysztofik, Russell King, Jakub Kicinski, Paolo Abeni,
	Sebastian Hesselbarth, Gregory Clement, Kalle Valo,
	Hante Meuleman, Nicholas Piggin, Rob Herring,
	Mauro Carvalho Chehab, Mika Westerberg, Franky Lin,
	Arend van Spriel, Mun Yew Tham, Hu Haowen, Keerthy,
	Aaro Koskinen, Li Yang, David S. Miller

The struct fwnode_handle pointer is used in both branches of ifdeffery,
no need to have a copy of the same in each of them, just make it global.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/gpio/consumer.h | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 59cb20cfac3d..a7eb8aa1e54c 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -8,6 +8,7 @@
 #include <linux/err.h>
 
 struct device;
+struct fwnode_handle;
 struct gpio_desc;
 struct gpio_array;
 
@@ -171,9 +172,6 @@ int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name);
 struct gpio_desc *gpio_to_desc(unsigned gpio);
 int desc_to_gpio(const struct gpio_desc *desc);
 
-/* Child properties interface */
-struct fwnode_handle;
-
 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
 					 const char *con_id, int index,
 					 enum gpiod_flags flags,
@@ -546,9 +544,6 @@ static inline int desc_to_gpio(const struct gpio_desc *desc)
 	return -EINVAL;
 }
 
-/* Child properties interface */
-struct fwnode_handle;
-
 static inline
 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
 					 const char *con_id, int index,
-- 
2.39.1


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

* [PATCH v3 11/12] gpiolib: Group forward declarations in consumer.h
  2023-02-07 14:29 ` Andy Shevchenko
@ 2023-02-07 14:29   ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Bartosz Golaszewski, Jonathan Corbet, Alex Shi, Yanteng Si,
	Hu Haowen, Russell King, Aaro Koskinen, Janusz Krzysztofik,
	Andrew Lunn, Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand

For better maintenance group the forward declarations together.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/gpio/consumer.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index a7eb8aa1e54c..5432e5d5fbfb 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -7,6 +7,7 @@
 #include <linux/compiler_types.h>
 #include <linux/err.h>
 
+struct acpi_device;
 struct device;
 struct fwnode_handle;
 struct gpio_desc;
@@ -602,8 +603,6 @@ struct acpi_gpio_mapping {
 	unsigned int quirks;
 };
 
-struct acpi_device;
-
 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_ACPI)
 
 int acpi_dev_add_driver_gpios(struct acpi_device *adev,
-- 
2.39.1


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

* [PATCH v3 11/12] gpiolib: Group forward declarations in consumer.h
@ 2023-02-07 14:29   ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Eric Dumazet,
	Alim Akhtar, Frank Rowand, Alex Shi, Qiang Zhao, Yanteng Si,
	Yoshinori Sato, Jonathan Corbet, Bartosz Golaszewski, Lee Jones,
	Janusz Krzysztofik, Russell King, Jakub Kicinski, Paolo Abeni,
	Sebastian Hesselbarth, Gregory Clement, Kalle Valo,
	Hante Meuleman, Nicholas Piggin, Rob Herring,
	Mauro Carvalho Chehab, Mika Westerberg, Franky Lin,
	Arend van Spriel, Mun Yew Tham, Hu Haowen, Keerthy,
	Aaro Koskinen, Li Yang, David S. Miller

For better maintenance group the forward declarations together.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/gpio/consumer.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index a7eb8aa1e54c..5432e5d5fbfb 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -7,6 +7,7 @@
 #include <linux/compiler_types.h>
 #include <linux/err.h>
 
+struct acpi_device;
 struct device;
 struct fwnode_handle;
 struct gpio_desc;
@@ -602,8 +603,6 @@ struct acpi_gpio_mapping {
 	unsigned int quirks;
 };
 
-struct acpi_device;
-
 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_ACPI)
 
 int acpi_dev_add_driver_gpios(struct acpi_device *adev,
-- 
2.39.1


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

* [PATCH v3 12/12] gpiolib: Clean up headers
  2023-02-07 14:29 ` Andy Shevchenko
@ 2023-02-07 14:29   ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Bartosz Golaszewski, Jonathan Corbet, Alex Shi, Yanteng Si,
	Hu Haowen, Russell King, Aaro Koskinen, Janusz Krzysztofik,
	Andrew Lunn, Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand

There is a few things done:
- include only the headers we are direct user of
- when pointer is in use, provide a forward declaration
- add missing headers
- group generic headers and subsystem headers
- sort each group alphabetically

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-acpi.c   | 10 ++++++----
 drivers/gpio/gpiolib-acpi.h   |  1 -
 drivers/gpio/gpiolib-of.c     |  6 ++++--
 drivers/gpio/gpiolib-of.h     |  1 -
 drivers/gpio/gpiolib-swnode.c |  5 +++--
 drivers/gpio/gpiolib-sysfs.c  | 21 ++++++++++++++++-----
 drivers/gpio/gpiolib.c        |  9 ++++++---
 include/linux/gpio.h          |  9 +++------
 include/linux/gpio/consumer.h | 14 ++++++++++----
 include/linux/gpio/driver.h   | 30 +++++++++++++++++++++++-------
 10 files changed, 71 insertions(+), 35 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index bb583cea366c..3871dade186a 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -7,17 +7,19 @@
  *          Mika Westerberg <mika.westerberg@linux.intel.com>
  */
 
+#include <linux/acpi.h>
 #include <linux/dmi.h>
 #include <linux/errno.h>
-#include <linux/gpio/consumer.h>
-#include <linux/gpio/driver.h>
-#include <linux/gpio/machine.h>
 #include <linux/export.h>
-#include <linux/acpi.h>
 #include <linux/interrupt.h>
+#include <linux/irq.h>
 #include <linux/mutex.h>
 #include <linux/pinctrl/pinctrl.h>
 
+#include <linux/gpio/consumer.h>
+#include <linux/gpio/driver.h>
+#include <linux/gpio/machine.h>
+
 #include "gpiolib.h"
 #include "gpiolib-acpi.h"
 
diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h
index 5fa315b3c912..a6f3be0bb921 100644
--- a/drivers/gpio/gpiolib-acpi.h
+++ b/drivers/gpio/gpiolib-acpi.h
@@ -9,7 +9,6 @@
 #define GPIOLIB_ACPI_H
 
 #include <linux/err.h>
-#include <linux/errno.h>
 #include <linux/types.h>
 
 #include <linux/gpio/consumer.h>
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 0f699af438b0..1436cdb5fa26 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -10,14 +10,16 @@
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/errno.h>
-#include <linux/module.h>
 #include <linux/io.h>
-#include <linux/gpio/consumer.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_gpio.h>
 #include <linux/pinctrl/pinctrl.h>
 #include <linux/slab.h>
+#include <linux/string.h>
+
+#include <linux/gpio/consumer.h>
 #include <linux/gpio/machine.h>
 
 #include "gpiolib.h"
diff --git a/drivers/gpio/gpiolib-of.h b/drivers/gpio/gpiolib-of.h
index e5bb065d82ef..6b3a5347c5d9 100644
--- a/drivers/gpio/gpiolib-of.h
+++ b/drivers/gpio/gpiolib-of.h
@@ -4,7 +4,6 @@
 #define GPIOLIB_OF_H
 
 #include <linux/err.h>
-#include <linux/errno.h>
 #include <linux/types.h>
 
 #include <linux/notifier.h>
diff --git a/drivers/gpio/gpiolib-swnode.c b/drivers/gpio/gpiolib-swnode.c
index dd9ccac214d1..b5a6eaf3729b 100644
--- a/drivers/gpio/gpiolib-swnode.c
+++ b/drivers/gpio/gpiolib-swnode.c
@@ -6,13 +6,14 @@
  */
 #include <linux/err.h>
 #include <linux/errno.h>
-#include <linux/gpio/consumer.h>
-#include <linux/gpio/driver.h>
 #include <linux/kernel.h>
 #include <linux/printk.h>
 #include <linux/property.h>
 #include <linux/string.h>
 
+#include <linux/gpio/consumer.h>
+#include <linux/gpio/driver.h>
+
 #include "gpiolib.h"
 #include "gpiolib-swnode.h"
 
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index 6e4267944f80..c1cbf71329f0 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -1,18 +1,29 @@
 // SPDX-License-Identifier: GPL-2.0
+
+#include <linux/bitops.h>
+#include <linux/device.h>
 #include <linux/idr.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/kdev_t.h>
+#include <linux/kstrtox.h>
+#include <linux/list.h>
 #include <linux/mutex.h>
-#include <linux/device.h>
+#include <linux/printk.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/string.h>
 #include <linux/sysfs.h>
+#include <linux/types.h>
+
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
-#include <linux/interrupt.h>
-#include <linux/kdev_t.h>
-#include <linux/slab.h>
-#include <linux/ctype.h>
 
 #include "gpiolib.h"
 #include "gpiolib-sysfs.h"
 
+struct kernfs_node;
+
 #define GPIO_IRQF_TRIGGER_NONE		0
 #define GPIO_IRQF_TRIGGER_FALLING	BIT(0)
 #define GPIO_IRQF_TRIGGER_RISING	BIT(1)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 99a2c77c3711..900f6573c070 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -6,22 +6,25 @@
 #include <linux/debugfs.h>
 #include <linux/device.h>
 #include <linux/err.h>
+#include <linux/errno.h>
 #include <linux/file.h>
 #include <linux/fs.h>
-#include <linux/gpio.h>
-#include <linux/gpio/driver.h>
-#include <linux/gpio/machine.h>
 #include <linux/idr.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 
+#include <linux/gpio.h>
+#include <linux/gpio/driver.h>
+#include <linux/gpio/machine.h>
+
 #include <uapi/linux/gpio.h>
 
 #include "gpiolib-acpi.h"
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 84bb49939d6e..574c45be924b 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -12,7 +12,7 @@
 #ifndef __LINUX_GPIO_H
 #define __LINUX_GPIO_H
 
-#include <linux/errno.h>
+struct device;
 
 /* see Documentation/driver-api/gpio/legacy.rst */
 
@@ -132,20 +132,17 @@ void gpio_free_array(const struct gpio *array, size_t num);
 
 /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */
 
-struct device;
-
 int devm_gpio_request(struct device *dev, unsigned gpio, const char *label);
 int devm_gpio_request_one(struct device *dev, unsigned gpio,
 			  unsigned long flags, const char *label);
 
 #else /* ! CONFIG_GPIOLIB */
 
-#include <linux/bug.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 
-struct device;
-struct gpio_chip;
+#include <asm/bug.h>
+#include <asm/errno.h>
 
 static inline bool gpio_is_valid(int number)
 {
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 5432e5d5fbfb..1c4385a00f88 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -3,15 +3,14 @@
 #define __LINUX_GPIO_CONSUMER_H
 
 #include <linux/bits.h>
-#include <linux/bug.h>
-#include <linux/compiler_types.h>
-#include <linux/err.h>
+#include <linux/types.h>
 
 struct acpi_device;
 struct device;
 struct fwnode_handle;
-struct gpio_desc;
+
 struct gpio_array;
+struct gpio_desc;
 
 /**
  * struct gpio_descs - Struct containing an array of descriptors that can be
@@ -185,8 +184,11 @@ struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
 
 #else /* CONFIG_GPIOLIB */
 
+#include <linux/err.h>
 #include <linux/kernel.h>
 
+#include <asm/bug.h>
+
 static inline int gpiod_count(struct device *dev, const char *con_id)
 {
 	return 0;
@@ -616,6 +618,8 @@ struct gpio_desc *acpi_get_and_request_gpiod(char *path, unsigned int pin, char
 
 #else  /* CONFIG_GPIOLIB && CONFIG_ACPI */
 
+#include <linux/err.h>
+
 static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
 			      const struct acpi_gpio_mapping *gpios)
 {
@@ -647,6 +651,8 @@ void gpiod_unexport(struct gpio_desc *desc);
 
 #else  /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */
 
+#include <asm/errno.h>
+
 static inline int gpiod_export(struct gpio_desc *desc,
 			       bool direction_may_change)
 {
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 262a84ce9bcb..5c6db5533be6 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -2,27 +2,35 @@
 #ifndef __LINUX_GPIO_DRIVER_H
 #define __LINUX_GPIO_DRIVER_H
 
-#include <linux/device.h>
-#include <linux/irq.h>
+#include <linux/bits.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/irqdomain.h>
+#include <linux/irqhandler.h>
 #include <linux/lockdep.h>
 #include <linux/pinctrl/pinconf-generic.h>
 #include <linux/pinctrl/pinctrl.h>
 #include <linux/property.h>
+#include <linux/spinlock_types.h>
 #include <linux/types.h>
 
+#ifdef CONFIG_GENERIC_MSI_IRQ
 #include <asm/msi.h>
+#endif
 
-struct gpio_desc;
+struct device;
+struct irq_chip;
+struct irq_data;
+struct module;
 struct of_phandle_args;
+struct pinctrl_dev;
 struct seq_file;
-struct gpio_device;
-struct module;
-enum gpiod_flags;
-enum gpio_lookup_flags;
 
 struct gpio_chip;
+struct gpio_desc;
+struct gpio_device;
+
+enum gpio_lookup_flags;
+enum gpiod_flags;
 
 union gpio_irq_fwspec {
 	struct irq_fwspec	fwspec;
@@ -679,6 +687,10 @@ bool gpiochip_irqchip_irq_valid(const struct gpio_chip *gc,
 int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
 				struct irq_domain *domain);
 #else
+
+#include <asm/bug.h>
+#include <asm/errno.h>
+
 static inline int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
 					      struct irq_domain *domain)
 {
@@ -756,6 +768,10 @@ struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);
 
 #else /* CONFIG_GPIOLIB */
 
+#include <linux/err.h>
+
+#include <asm/bug.h>
+
 static inline struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc)
 {
 	/* GPIO can never have been requested */
-- 
2.39.1


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

* [PATCH v3 12/12] gpiolib: Clean up headers
@ 2023-02-07 14:29   ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 14:29 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Eric Dumazet,
	Alim Akhtar, Frank Rowand, Alex Shi, Qiang Zhao, Yanteng Si,
	Yoshinori Sato, Jonathan Corbet, Bartosz Golaszewski, Lee Jones,
	Janusz Krzysztofik, Russell King, Jakub Kicinski, Paolo Abeni,
	Sebastian Hesselbarth, Gregory Clement, Kalle Valo,
	Hante Meuleman, Nicholas Piggin, Rob Herring,
	Mauro Carvalho Chehab, Mika Westerberg, Franky Lin,
	Arend van Spriel, Mun Yew Tham, Hu Haowen, Keerthy,
	Aaro Koskinen, Li Yang, David S. Miller

There is a few things done:
- include only the headers we are direct user of
- when pointer is in use, provide a forward declaration
- add missing headers
- group generic headers and subsystem headers
- sort each group alphabetically

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-acpi.c   | 10 ++++++----
 drivers/gpio/gpiolib-acpi.h   |  1 -
 drivers/gpio/gpiolib-of.c     |  6 ++++--
 drivers/gpio/gpiolib-of.h     |  1 -
 drivers/gpio/gpiolib-swnode.c |  5 +++--
 drivers/gpio/gpiolib-sysfs.c  | 21 ++++++++++++++++-----
 drivers/gpio/gpiolib.c        |  9 ++++++---
 include/linux/gpio.h          |  9 +++------
 include/linux/gpio/consumer.h | 14 ++++++++++----
 include/linux/gpio/driver.h   | 30 +++++++++++++++++++++++-------
 10 files changed, 71 insertions(+), 35 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index bb583cea366c..3871dade186a 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -7,17 +7,19 @@
  *          Mika Westerberg <mika.westerberg@linux.intel.com>
  */
 
+#include <linux/acpi.h>
 #include <linux/dmi.h>
 #include <linux/errno.h>
-#include <linux/gpio/consumer.h>
-#include <linux/gpio/driver.h>
-#include <linux/gpio/machine.h>
 #include <linux/export.h>
-#include <linux/acpi.h>
 #include <linux/interrupt.h>
+#include <linux/irq.h>
 #include <linux/mutex.h>
 #include <linux/pinctrl/pinctrl.h>
 
+#include <linux/gpio/consumer.h>
+#include <linux/gpio/driver.h>
+#include <linux/gpio/machine.h>
+
 #include "gpiolib.h"
 #include "gpiolib-acpi.h"
 
diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h
index 5fa315b3c912..a6f3be0bb921 100644
--- a/drivers/gpio/gpiolib-acpi.h
+++ b/drivers/gpio/gpiolib-acpi.h
@@ -9,7 +9,6 @@
 #define GPIOLIB_ACPI_H
 
 #include <linux/err.h>
-#include <linux/errno.h>
 #include <linux/types.h>
 
 #include <linux/gpio/consumer.h>
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 0f699af438b0..1436cdb5fa26 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -10,14 +10,16 @@
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/errno.h>
-#include <linux/module.h>
 #include <linux/io.h>
-#include <linux/gpio/consumer.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_gpio.h>
 #include <linux/pinctrl/pinctrl.h>
 #include <linux/slab.h>
+#include <linux/string.h>
+
+#include <linux/gpio/consumer.h>
 #include <linux/gpio/machine.h>
 
 #include "gpiolib.h"
diff --git a/drivers/gpio/gpiolib-of.h b/drivers/gpio/gpiolib-of.h
index e5bb065d82ef..6b3a5347c5d9 100644
--- a/drivers/gpio/gpiolib-of.h
+++ b/drivers/gpio/gpiolib-of.h
@@ -4,7 +4,6 @@
 #define GPIOLIB_OF_H
 
 #include <linux/err.h>
-#include <linux/errno.h>
 #include <linux/types.h>
 
 #include <linux/notifier.h>
diff --git a/drivers/gpio/gpiolib-swnode.c b/drivers/gpio/gpiolib-swnode.c
index dd9ccac214d1..b5a6eaf3729b 100644
--- a/drivers/gpio/gpiolib-swnode.c
+++ b/drivers/gpio/gpiolib-swnode.c
@@ -6,13 +6,14 @@
  */
 #include <linux/err.h>
 #include <linux/errno.h>
-#include <linux/gpio/consumer.h>
-#include <linux/gpio/driver.h>
 #include <linux/kernel.h>
 #include <linux/printk.h>
 #include <linux/property.h>
 #include <linux/string.h>
 
+#include <linux/gpio/consumer.h>
+#include <linux/gpio/driver.h>
+
 #include "gpiolib.h"
 #include "gpiolib-swnode.h"
 
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index 6e4267944f80..c1cbf71329f0 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -1,18 +1,29 @@
 // SPDX-License-Identifier: GPL-2.0
+
+#include <linux/bitops.h>
+#include <linux/device.h>
 #include <linux/idr.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/kdev_t.h>
+#include <linux/kstrtox.h>
+#include <linux/list.h>
 #include <linux/mutex.h>
-#include <linux/device.h>
+#include <linux/printk.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/string.h>
 #include <linux/sysfs.h>
+#include <linux/types.h>
+
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
-#include <linux/interrupt.h>
-#include <linux/kdev_t.h>
-#include <linux/slab.h>
-#include <linux/ctype.h>
 
 #include "gpiolib.h"
 #include "gpiolib-sysfs.h"
 
+struct kernfs_node;
+
 #define GPIO_IRQF_TRIGGER_NONE		0
 #define GPIO_IRQF_TRIGGER_FALLING	BIT(0)
 #define GPIO_IRQF_TRIGGER_RISING	BIT(1)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 99a2c77c3711..900f6573c070 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -6,22 +6,25 @@
 #include <linux/debugfs.h>
 #include <linux/device.h>
 #include <linux/err.h>
+#include <linux/errno.h>
 #include <linux/file.h>
 #include <linux/fs.h>
-#include <linux/gpio.h>
-#include <linux/gpio/driver.h>
-#include <linux/gpio/machine.h>
 #include <linux/idr.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 
+#include <linux/gpio.h>
+#include <linux/gpio/driver.h>
+#include <linux/gpio/machine.h>
+
 #include <uapi/linux/gpio.h>
 
 #include "gpiolib-acpi.h"
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 84bb49939d6e..574c45be924b 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -12,7 +12,7 @@
 #ifndef __LINUX_GPIO_H
 #define __LINUX_GPIO_H
 
-#include <linux/errno.h>
+struct device;
 
 /* see Documentation/driver-api/gpio/legacy.rst */
 
@@ -132,20 +132,17 @@ void gpio_free_array(const struct gpio *array, size_t num);
 
 /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */
 
-struct device;
-
 int devm_gpio_request(struct device *dev, unsigned gpio, const char *label);
 int devm_gpio_request_one(struct device *dev, unsigned gpio,
 			  unsigned long flags, const char *label);
 
 #else /* ! CONFIG_GPIOLIB */
 
-#include <linux/bug.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 
-struct device;
-struct gpio_chip;
+#include <asm/bug.h>
+#include <asm/errno.h>
 
 static inline bool gpio_is_valid(int number)
 {
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 5432e5d5fbfb..1c4385a00f88 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -3,15 +3,14 @@
 #define __LINUX_GPIO_CONSUMER_H
 
 #include <linux/bits.h>
-#include <linux/bug.h>
-#include <linux/compiler_types.h>
-#include <linux/err.h>
+#include <linux/types.h>
 
 struct acpi_device;
 struct device;
 struct fwnode_handle;
-struct gpio_desc;
+
 struct gpio_array;
+struct gpio_desc;
 
 /**
  * struct gpio_descs - Struct containing an array of descriptors that can be
@@ -185,8 +184,11 @@ struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
 
 #else /* CONFIG_GPIOLIB */
 
+#include <linux/err.h>
 #include <linux/kernel.h>
 
+#include <asm/bug.h>
+
 static inline int gpiod_count(struct device *dev, const char *con_id)
 {
 	return 0;
@@ -616,6 +618,8 @@ struct gpio_desc *acpi_get_and_request_gpiod(char *path, unsigned int pin, char
 
 #else  /* CONFIG_GPIOLIB && CONFIG_ACPI */
 
+#include <linux/err.h>
+
 static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
 			      const struct acpi_gpio_mapping *gpios)
 {
@@ -647,6 +651,8 @@ void gpiod_unexport(struct gpio_desc *desc);
 
 #else  /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */
 
+#include <asm/errno.h>
+
 static inline int gpiod_export(struct gpio_desc *desc,
 			       bool direction_may_change)
 {
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 262a84ce9bcb..5c6db5533be6 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -2,27 +2,35 @@
 #ifndef __LINUX_GPIO_DRIVER_H
 #define __LINUX_GPIO_DRIVER_H
 
-#include <linux/device.h>
-#include <linux/irq.h>
+#include <linux/bits.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/irqdomain.h>
+#include <linux/irqhandler.h>
 #include <linux/lockdep.h>
 #include <linux/pinctrl/pinconf-generic.h>
 #include <linux/pinctrl/pinctrl.h>
 #include <linux/property.h>
+#include <linux/spinlock_types.h>
 #include <linux/types.h>
 
+#ifdef CONFIG_GENERIC_MSI_IRQ
 #include <asm/msi.h>
+#endif
 
-struct gpio_desc;
+struct device;
+struct irq_chip;
+struct irq_data;
+struct module;
 struct of_phandle_args;
+struct pinctrl_dev;
 struct seq_file;
-struct gpio_device;
-struct module;
-enum gpiod_flags;
-enum gpio_lookup_flags;
 
 struct gpio_chip;
+struct gpio_desc;
+struct gpio_device;
+
+enum gpio_lookup_flags;
+enum gpiod_flags;
 
 union gpio_irq_fwspec {
 	struct irq_fwspec	fwspec;
@@ -679,6 +687,10 @@ bool gpiochip_irqchip_irq_valid(const struct gpio_chip *gc,
 int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
 				struct irq_domain *domain);
 #else
+
+#include <asm/bug.h>
+#include <asm/errno.h>
+
 static inline int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
 					      struct irq_domain *domain)
 {
@@ -756,6 +768,10 @@ struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);
 
 #else /* CONFIG_GPIOLIB */
 
+#include <linux/err.h>
+
+#include <asm/bug.h>
+
 static inline struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc)
 {
 	/* GPIO can never have been requested */
-- 
2.39.1


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

* Re: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
  2023-02-07 14:29   ` Andy Shevchenko
@ 2023-02-07 14:55     ` Linus Walleij
  -1 siblings, 0 replies; 53+ messages in thread
From: Linus Walleij @ 2023-02-07 14:55 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Arnd Bergmann, Bartosz Golaszewski, Tony Lindgren,
	Thomas Gleixner, Krzysztof Kozlowski, Geert Uytterhoeven,
	Christophe Leroy, Michael Ellerman, Devarsh Thakkar,
	Dmitry Torokhov, Stefan Schmidt, Miquel Raynal, linux-gpio,
	linux-doc, linux-kernel, linux-doc-tw-discuss, linux-arm-kernel,
	linux-omap, linux-samsung-soc, linux-m68k, linuxppc-dev,
	linux-sh, linux-acpi, linux-input, linux-media, linux-wpan,
	netdev, linux-wireless, brcm80211-dev-list.pdl,
	SHA-cyfmac-dev-list, linux-arch, devicetree, Bartosz Golaszewski,
	Jonathan Corbet, Alex Shi, Yanteng Si, Hu Haowen, Russell King,
	Aaro Koskinen, Janusz Krzysztofik, Andrew Lunn,
	Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand

On Tue, Feb 7, 2023 at 3:29 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> From: Arnd Bergmann <arnd@arndb.de>
>
> Almost all gpio drivers include linux/gpio/driver.h, and other
> files should not rely on includes from this header.
>
> Remove the indirect include from here and include the correct
> headers directly from where they are used.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Make sure you push this to the kernel.org build servers (zeroday builds),
I think this patch needs to hit some more files, in my tests with a similar
patch at least these:

diff --git a/drivers/hte/hte-tegra194-test.c b/drivers/hte/hte-tegra194-test.c
index 5d776a185bd6..79eb866558d3 100644
--- a/drivers/hte/hte-tegra194-test.c
+++ b/drivers/hte/hte-tegra194-test.c
@@ -6,10 +6,11 @@
  */

 #include <linux/err.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/interrupt.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/timer.h>
 #include <linux/platform_device.h>
 #include <linux/workqueue.h>


diff --git a/arch/arm/mach-pxa/viper-pcmcia.c b/arch/arm/mach-pxa/viper-pcmcia.c
index 26599dcc49b3..2c7af4ed57d5 100644
--- a/arch/arm/mach-pxa/viper-pcmcia.c
+++ b/arch/arm/mach-pxa/viper-pcmcia.c
@@ -19,6 +19,7 @@
 #include <linux/errno.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/gpio.h>

 #include <pcmcia/ss.h>

Yours,
Linus Walleij

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

* Re: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
@ 2023-02-07 14:55     ` Linus Walleij
  0 siblings, 0 replies; 53+ messages in thread
From: Linus Walleij @ 2023-02-07 14:55 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Devarsh Thakkar,
	linux-doc, Tony Lindgren, Eric Dumazet, Lee Jones, Alim Akhtar,
	Miquel Raynal, Li Yang, Frank Rowand, Stefan Schmidt, Qiang Zhao,
	linux-arch, Jonathan Corbet, linux-samsung-soc, Yoshinori Sato,
	Bartosz Golaszewski, Bartosz Golaszewski, linux-sh,
	Janusz Krzysztofik, Russell King, linux-acpi,
	SHA-cyfmac-dev-list, Geert Uytterhoeven, Alex Shi, linux-input,
	Jak ub Kicinski, Paolo Abeni, Kalle Valo, linux-media,
	devicetree, Arnd Bergmann, Mauro Carvalho Chehab,
	Arend van Spriel, Nicholas Piggin, Hante Meuleman, linux-gpio,
	linux-m68k, Yanteng Si, Thomas Gleixner, linux-omap,
	Mika Westerberg, linux-arm-kernel, Franky Lin,
	brcm80211-dev-list.pdl, Keerthy, Mun Yew Tham, Hu Haowen,
	linux-wpan, linux-doc-tw-discuss, Dmitry Torokhov,
	linux-wireless, linux-kernel, David S. Miller,
	Krzys ztof Kozlowski, Rob Herring, netdev, Aaro Koskinen,
	Sebastian Hesselbarth, linuxppc-dev, Gregory Clement

On Tue, Feb 7, 2023 at 3:29 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> From: Arnd Bergmann <arnd@arndb.de>
>
> Almost all gpio drivers include linux/gpio/driver.h, and other
> files should not rely on includes from this header.
>
> Remove the indirect include from here and include the correct
> headers directly from where they are used.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Make sure you push this to the kernel.org build servers (zeroday builds),
I think this patch needs to hit some more files, in my tests with a similar
patch at least these:

diff --git a/drivers/hte/hte-tegra194-test.c b/drivers/hte/hte-tegra194-test.c
index 5d776a185bd6..79eb866558d3 100644
--- a/drivers/hte/hte-tegra194-test.c
+++ b/drivers/hte/hte-tegra194-test.c
@@ -6,10 +6,11 @@
  */

 #include <linux/err.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/interrupt.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/timer.h>
 #include <linux/platform_device.h>
 #include <linux/workqueue.h>


diff --git a/arch/arm/mach-pxa/viper-pcmcia.c b/arch/arm/mach-pxa/viper-pcmcia.c
index 26599dcc49b3..2c7af4ed57d5 100644
--- a/arch/arm/mach-pxa/viper-pcmcia.c
+++ b/arch/arm/mach-pxa/viper-pcmcia.c
@@ -19,6 +19,7 @@
 #include <linux/errno.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/gpio.h>

 #include <pcmcia/ss.h>

Yours,
Linus Walleij

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

* Re: [PATCH v3 12/12] gpiolib: Clean up headers
  2023-02-07 14:29   ` Andy Shevchenko
  (?)
@ 2023-02-07 17:46   ` kernel test robot
  -1 siblings, 0 replies; 53+ messages in thread
From: kernel test robot @ 2023-02-07 17:46 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: llvm, oe-kbuild-all

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on brgl/gpio/for-next]
[cannot apply to powerpc/next powerpc/fixes soc/for-next linus/master v6.2-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/gpiolib-remove-empty-asm-gpio-h-files/20230207-223652
base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link:    https://lore.kernel.org/r/20230207142952.51844-13-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v3 12/12] gpiolib: Clean up headers
config: hexagon-randconfig-r041-20230205 (https://download.01.org/0day-ci/archive/20230208/202302080102.DkyEbYmt-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project db0e6591612b53910a1b366863348bdb9d7d2fb1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/1b29af54a98628e27cdabe2554fbf29b75a1c18b
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/gpiolib-remove-empty-asm-gpio-h-files/20230207-223652
        git checkout 1b29af54a98628e27cdabe2554fbf29b75a1c18b
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/gpio/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from drivers/gpio/gpio-regmap.c:8:
   In file included from include/linux/gpio/driver.h:6:
   In file included from include/linux/irqchip/chained_irq.h:10:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from drivers/gpio/gpio-regmap.c:8:
   In file included from include/linux/gpio/driver.h:6:
   In file included from include/linux/irqchip/chained_irq.h:10:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from drivers/gpio/gpio-regmap.c:8:
   In file included from include/linux/gpio/driver.h:6:
   In file included from include/linux/irqchip/chained_irq.h:10:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
>> drivers/gpio/gpio-regmap.c:256:33: error: call to undeclared function 'dev_name'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
           chip->label = config->label ?: dev_name(config->parent);
                                          ^
>> drivers/gpio/gpio-regmap.c:256:30: warning: pointer/integer type mismatch in conditional expression ('const char *' and 'int') [-Wconditional-type-mismatch]
           chip->label = config->label ?: dev_name(config->parent);
                         ~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/gpio/gpio-regmap.c:329:8: error: call to undeclared function 'devm_add_action_or_reset'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
           ret = devm_add_action_or_reset(dev, devm_gpio_regmap_unregister, gpio);
                 ^
   7 warnings and 2 errors generated.


vim +/dev_name +256 drivers/gpio/gpio-regmap.c

ebe363197e525f Michael Walle          2020-05-28  191  
ebe363197e525f Michael Walle          2020-05-28  192  /**
ebe363197e525f Michael Walle          2020-05-28  193   * gpio_regmap_register() - Register a generic regmap GPIO controller
ebe363197e525f Michael Walle          2020-05-28  194   * @config: configuration for gpio_regmap
ebe363197e525f Michael Walle          2020-05-28  195   *
ebe363197e525f Michael Walle          2020-05-28  196   * Return: A pointer to the registered gpio_regmap or ERR_PTR error value.
ebe363197e525f Michael Walle          2020-05-28  197   */
ebe363197e525f Michael Walle          2020-05-28  198  struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config)
ebe363197e525f Michael Walle          2020-05-28  199  {
ebe363197e525f Michael Walle          2020-05-28  200  	struct gpio_regmap *gpio;
ebe363197e525f Michael Walle          2020-05-28  201  	struct gpio_chip *chip;
ebe363197e525f Michael Walle          2020-05-28  202  	int ret;
ebe363197e525f Michael Walle          2020-05-28  203  
ebe363197e525f Michael Walle          2020-05-28  204  	if (!config->parent)
ebe363197e525f Michael Walle          2020-05-28  205  		return ERR_PTR(-EINVAL);
ebe363197e525f Michael Walle          2020-05-28  206  
ebe363197e525f Michael Walle          2020-05-28  207  	if (!config->ngpio)
ebe363197e525f Michael Walle          2020-05-28  208  		return ERR_PTR(-EINVAL);
ebe363197e525f Michael Walle          2020-05-28  209  
ebe363197e525f Michael Walle          2020-05-28  210  	/* we need at least one */
ebe363197e525f Michael Walle          2020-05-28  211  	if (!config->reg_dat_base && !config->reg_set_base)
ebe363197e525f Michael Walle          2020-05-28  212  		return ERR_PTR(-EINVAL);
ebe363197e525f Michael Walle          2020-05-28  213  
ebe363197e525f Michael Walle          2020-05-28  214  	/* if we have a direction register we need both input and output */
ebe363197e525f Michael Walle          2020-05-28  215  	if ((config->reg_dir_out_base || config->reg_dir_in_base) &&
ebe363197e525f Michael Walle          2020-05-28  216  	    (!config->reg_dat_base || !config->reg_set_base))
ebe363197e525f Michael Walle          2020-05-28  217  		return ERR_PTR(-EINVAL);
ebe363197e525f Michael Walle          2020-05-28  218  
ebe363197e525f Michael Walle          2020-05-28  219  	/* we don't support having both registers simultaneously for now */
ebe363197e525f Michael Walle          2020-05-28  220  	if (config->reg_dir_out_base && config->reg_dir_in_base)
ebe363197e525f Michael Walle          2020-05-28  221  		return ERR_PTR(-EINVAL);
ebe363197e525f Michael Walle          2020-05-28  222  
ebe363197e525f Michael Walle          2020-05-28  223  	gpio = kzalloc(sizeof(*gpio), GFP_KERNEL);
ebe363197e525f Michael Walle          2020-05-28  224  	if (!gpio)
ebe363197e525f Michael Walle          2020-05-28  225  		return ERR_PTR(-ENOMEM);
ebe363197e525f Michael Walle          2020-05-28  226  
ebe363197e525f Michael Walle          2020-05-28  227  	gpio->parent = config->parent;
9b3c47f124b607 Michael Walle          2021-06-05  228  	gpio->driver_data = config->drvdata;
ebe363197e525f Michael Walle          2020-05-28  229  	gpio->regmap = config->regmap;
ebe363197e525f Michael Walle          2020-05-28  230  	gpio->ngpio_per_reg = config->ngpio_per_reg;
ebe363197e525f Michael Walle          2020-05-28  231  	gpio->reg_stride = config->reg_stride;
ebe363197e525f Michael Walle          2020-05-28  232  	gpio->reg_mask_xlate = config->reg_mask_xlate;
ebe363197e525f Michael Walle          2020-05-28  233  	gpio->reg_dat_base = config->reg_dat_base;
ebe363197e525f Michael Walle          2020-05-28  234  	gpio->reg_set_base = config->reg_set_base;
ebe363197e525f Michael Walle          2020-05-28  235  	gpio->reg_clr_base = config->reg_clr_base;
ebe363197e525f Michael Walle          2020-05-28  236  	gpio->reg_dir_in_base = config->reg_dir_in_base;
ebe363197e525f Michael Walle          2020-05-28  237  	gpio->reg_dir_out_base = config->reg_dir_out_base;
ebe363197e525f Michael Walle          2020-05-28  238  
ebe363197e525f Michael Walle          2020-05-28  239  	/* if not set, assume there is only one register */
ebe363197e525f Michael Walle          2020-05-28  240  	if (!gpio->ngpio_per_reg)
ebe363197e525f Michael Walle          2020-05-28  241  		gpio->ngpio_per_reg = config->ngpio;
ebe363197e525f Michael Walle          2020-05-28  242  
ebe363197e525f Michael Walle          2020-05-28  243  	/* if not set, assume they are consecutive */
ebe363197e525f Michael Walle          2020-05-28  244  	if (!gpio->reg_stride)
ebe363197e525f Michael Walle          2020-05-28  245  		gpio->reg_stride = 1;
ebe363197e525f Michael Walle          2020-05-28  246  
ebe363197e525f Michael Walle          2020-05-28  247  	if (!gpio->reg_mask_xlate)
ebe363197e525f Michael Walle          2020-05-28  248  		gpio->reg_mask_xlate = gpio_regmap_simple_xlate;
ebe363197e525f Michael Walle          2020-05-28  249  
ebe363197e525f Michael Walle          2020-05-28  250  	chip = &gpio->gpio_chip;
ebe363197e525f Michael Walle          2020-05-28  251  	chip->parent = config->parent;
f21ecad451c9b3 Andy Shevchenko        2021-12-23  252  	chip->fwnode = config->fwnode;
ebe363197e525f Michael Walle          2020-05-28  253  	chip->base = -1;
ebe363197e525f Michael Walle          2020-05-28  254  	chip->ngpio = config->ngpio;
ebe363197e525f Michael Walle          2020-05-28  255  	chip->names = config->names;
ebe363197e525f Michael Walle          2020-05-28 @256  	chip->label = config->label ?: dev_name(config->parent);
297a44f664a8ac Michael Walle          2023-01-05  257  	chip->can_sleep = regmap_might_sleep(config->regmap);
ebe363197e525f Michael Walle          2020-05-28  258  
ebe363197e525f Michael Walle          2020-05-28  259  	chip->get = gpio_regmap_get;
ebe363197e525f Michael Walle          2020-05-28  260  	if (gpio->reg_set_base && gpio->reg_clr_base)
ebe363197e525f Michael Walle          2020-05-28  261  		chip->set = gpio_regmap_set_with_clear;
ebe363197e525f Michael Walle          2020-05-28  262  	else if (gpio->reg_set_base)
ebe363197e525f Michael Walle          2020-05-28  263  		chip->set = gpio_regmap_set;
ebe363197e525f Michael Walle          2020-05-28  264  
ebe363197e525f Michael Walle          2020-05-28  265  	chip->get_direction = gpio_regmap_get_direction;
8978277c229b95 William Breathitt Gray 2022-12-27  266  	if (gpio->reg_dir_in_base || gpio->reg_dir_out_base) {
ebe363197e525f Michael Walle          2020-05-28  267  		chip->direction_input = gpio_regmap_direction_input;
ebe363197e525f Michael Walle          2020-05-28  268  		chip->direction_output = gpio_regmap_direction_output;
ebe363197e525f Michael Walle          2020-05-28  269  	}
ebe363197e525f Michael Walle          2020-05-28  270  
ebe363197e525f Michael Walle          2020-05-28  271  	ret = gpiochip_add_data(chip, gpio);
ebe363197e525f Michael Walle          2020-05-28  272  	if (ret < 0)
ebe363197e525f Michael Walle          2020-05-28  273  		goto err_free_gpio;
ebe363197e525f Michael Walle          2020-05-28  274  
ebe363197e525f Michael Walle          2020-05-28  275  	if (config->irq_domain) {
ebe363197e525f Michael Walle          2020-05-28  276  		ret = gpiochip_irqchip_add_domain(chip, config->irq_domain);
ebe363197e525f Michael Walle          2020-05-28  277  		if (ret)
ebe363197e525f Michael Walle          2020-05-28  278  			goto err_remove_gpiochip;
ebe363197e525f Michael Walle          2020-05-28  279  	}
ebe363197e525f Michael Walle          2020-05-28  280  
ebe363197e525f Michael Walle          2020-05-28  281  	return gpio;
ebe363197e525f Michael Walle          2020-05-28  282  
ebe363197e525f Michael Walle          2020-05-28  283  err_remove_gpiochip:
ebe363197e525f Michael Walle          2020-05-28  284  	gpiochip_remove(chip);
ebe363197e525f Michael Walle          2020-05-28  285  err_free_gpio:
ebe363197e525f Michael Walle          2020-05-28  286  	kfree(gpio);
ebe363197e525f Michael Walle          2020-05-28  287  	return ERR_PTR(ret);
ebe363197e525f Michael Walle          2020-05-28  288  }
ebe363197e525f Michael Walle          2020-05-28  289  EXPORT_SYMBOL_GPL(gpio_regmap_register);
ebe363197e525f Michael Walle          2020-05-28  290  
ebe363197e525f Michael Walle          2020-05-28  291  /**
ebe363197e525f Michael Walle          2020-05-28  292   * gpio_regmap_unregister() - Unregister a generic regmap GPIO controller
ebe363197e525f Michael Walle          2020-05-28  293   * @gpio: gpio_regmap device to unregister
ebe363197e525f Michael Walle          2020-05-28  294   */
ebe363197e525f Michael Walle          2020-05-28  295  void gpio_regmap_unregister(struct gpio_regmap *gpio)
ebe363197e525f Michael Walle          2020-05-28  296  {
ebe363197e525f Michael Walle          2020-05-28  297  	gpiochip_remove(&gpio->gpio_chip);
ebe363197e525f Michael Walle          2020-05-28  298  	kfree(gpio);
ebe363197e525f Michael Walle          2020-05-28  299  }
ebe363197e525f Michael Walle          2020-05-28  300  EXPORT_SYMBOL_GPL(gpio_regmap_unregister);
ebe363197e525f Michael Walle          2020-05-28  301  
40e568f9c88db8 Matti Vaittinen        2021-06-03  302  static void devm_gpio_regmap_unregister(void *res)
ebe363197e525f Michael Walle          2020-05-28  303  {
40e568f9c88db8 Matti Vaittinen        2021-06-03  304  	gpio_regmap_unregister(res);
ebe363197e525f Michael Walle          2020-05-28  305  }
ebe363197e525f Michael Walle          2020-05-28  306  
ebe363197e525f Michael Walle          2020-05-28  307  /**
ebe363197e525f Michael Walle          2020-05-28  308   * devm_gpio_regmap_register() - resource managed gpio_regmap_register()
ebe363197e525f Michael Walle          2020-05-28  309   * @dev: device that is registering this GPIO device
ebe363197e525f Michael Walle          2020-05-28  310   * @config: configuration for gpio_regmap
ebe363197e525f Michael Walle          2020-05-28  311   *
ebe363197e525f Michael Walle          2020-05-28  312   * Managed gpio_regmap_register(). For generic regmap GPIO device registered by
ebe363197e525f Michael Walle          2020-05-28  313   * this function, gpio_regmap_unregister() is automatically called on driver
ebe363197e525f Michael Walle          2020-05-28  314   * detach. See gpio_regmap_register() for more information.
ebe363197e525f Michael Walle          2020-05-28  315   *
ebe363197e525f Michael Walle          2020-05-28  316   * Return: A pointer to the registered gpio_regmap or ERR_PTR error value.
ebe363197e525f Michael Walle          2020-05-28  317   */
ebe363197e525f Michael Walle          2020-05-28  318  struct gpio_regmap *devm_gpio_regmap_register(struct device *dev,
ebe363197e525f Michael Walle          2020-05-28  319  					      const struct gpio_regmap_config *config)
ebe363197e525f Michael Walle          2020-05-28  320  {
40e568f9c88db8 Matti Vaittinen        2021-06-03  321  	struct gpio_regmap *gpio;
40e568f9c88db8 Matti Vaittinen        2021-06-03  322  	int ret;
ebe363197e525f Michael Walle          2020-05-28  323  
ebe363197e525f Michael Walle          2020-05-28  324  	gpio = gpio_regmap_register(config);
40e568f9c88db8 Matti Vaittinen        2021-06-03  325  
40e568f9c88db8 Matti Vaittinen        2021-06-03  326  	if (IS_ERR(gpio))
40e568f9c88db8 Matti Vaittinen        2021-06-03  327  		return gpio;
40e568f9c88db8 Matti Vaittinen        2021-06-03  328  
40e568f9c88db8 Matti Vaittinen        2021-06-03 @329  	ret = devm_add_action_or_reset(dev, devm_gpio_regmap_unregister, gpio);
40e568f9c88db8 Matti Vaittinen        2021-06-03  330  	if (ret)
40e568f9c88db8 Matti Vaittinen        2021-06-03  331  		return ERR_PTR(ret);
ebe363197e525f Michael Walle          2020-05-28  332  
ebe363197e525f Michael Walle          2020-05-28  333  	return gpio;
ebe363197e525f Michael Walle          2020-05-28  334  }
ebe363197e525f Michael Walle          2020-05-28  335  EXPORT_SYMBOL_GPL(devm_gpio_regmap_register);
ebe363197e525f Michael Walle          2020-05-28  336  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

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

* Re: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
  2023-02-07 14:29   ` Andy Shevchenko
@ 2023-02-07 18:43     ` Lee Jones
  -1 siblings, 0 replies; 53+ messages in thread
From: Lee Jones @ 2023-02-07 18:43 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, Arnd Bergmann, Bartosz Golaszewski, Tony Lindgren,
	Thomas Gleixner, Krzysztof Kozlowski, Geert Uytterhoeven,
	Christophe Leroy, Michael Ellerman, Devarsh Thakkar,
	Dmitry Torokhov, Stefan Schmidt, Miquel Raynal, linux-gpio,
	linux-doc, linux-kernel, linux-doc-tw-discuss, linux-arm-kernel,
	linux-omap, linux-samsung-soc, linux-m68k, linuxppc-dev,
	linux-sh, linux-acpi, linux-input, linux-media, linux-wpan,
	netdev, linux-wireless, brcm80211-dev-list.pdl,
	SHA-cyfmac-dev-list, linux-arch, devicetree, Bartosz Golaszewski,
	Jonathan Corbet, Alex Shi, Yanteng Si, Hu Haowen, Russell King,
	Aaro Koskinen, Janusz Krzysztofik, Andrew Lunn,
	Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Rob Herring, Frank Rowand

On Tue, 07 Feb 2023, Andy Shevchenko wrote:

> From: Arnd Bergmann <arnd@arndb.de>
> 
> Almost all gpio drivers include linux/gpio/driver.h, and other
> files should not rely on includes from this header.
> 
> Remove the indirect include from here and include the correct
> headers directly from where they are used.
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  arch/arm/mach-omap1/irq.c                              | 1 +
>  arch/arm/mach-orion5x/board-rd88f5182.c                | 1 +
>  arch/arm/mach-s3c/s3c64xx.c                            | 1 +
>  arch/arm/mach-sa1100/assabet.c                         | 1 +
>  arch/arm/plat-orion/gpio.c                             | 1 +
>  drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c | 1 +
>  include/linux/gpio.h                                   | 2 --
>  include/linux/mfd/ucb1x00.h                            | 1 +

Acked-by: Lee Jones <lee@kernel.org>

>  8 files changed, 7 insertions(+), 2 deletions(-)

-- 
Lee Jones [李琼斯]

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

* Re: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
@ 2023-02-07 18:43     ` Lee Jones
  0 siblings, 0 replies; 53+ messages in thread
From: Lee Jones @ 2023-02-07 18:43 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Devarsh Thakkar,
	linux-doc, Tony Lindgren, Linus Walleij, Eric Dumazet,
	Alim Akhtar, Miquel Raynal, Li Yang, Frank Rowand,
	Stefan Schmidt, Qiang Zhao, linux-arch, Jonathan Corbet,
	linux-samsung-soc, Yoshinori Sato, Bartosz Golaszewski,
	Bartosz Golaszewski, linux-sh, Janusz Krzysztofik, Russell King,
	linux-acpi, SHA-cyfmac-dev-list, Geert Uytterhoeven, Alex Shi,
	linux-input

On Tue, 07 Feb 2023, Andy Shevchenko wrote:

> From: Arnd Bergmann <arnd@arndb.de>
> 
> Almost all gpio drivers include linux/gpio/driver.h, and other
> files should not rely on includes from this header.
> 
> Remove the indirect include from here and include the correct
> headers directly from where they are used.
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  arch/arm/mach-omap1/irq.c                              | 1 +
>  arch/arm/mach-orion5x/board-rd88f5182.c                | 1 +
>  arch/arm/mach-s3c/s3c64xx.c                            | 1 +
>  arch/arm/mach-sa1100/assabet.c                         | 1 +
>  arch/arm/plat-orion/gpio.c                             | 1 +
>  drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c | 1 +
>  include/linux/gpio.h                                   | 2 --
>  include/linux/mfd/ucb1x00.h                            | 1 +

Acked-by: Lee Jones <lee@kernel.org>

>  8 files changed, 7 insertions(+), 2 deletions(-)

-- 
Lee Jones [李琼斯]

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

* Re: [PATCH v3 12/12] gpiolib: Clean up headers
  2023-02-07 14:29   ` Andy Shevchenko
  (?)
  (?)
@ 2023-02-07 20:31   ` kernel test robot
  -1 siblings, 0 replies; 53+ messages in thread
From: kernel test robot @ 2023-02-07 20:31 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: oe-kbuild-all

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on brgl/gpio/for-next]
[also build test ERROR on next-20230207]
[cannot apply to soc/for-next linus/master v6.2-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/gpiolib-remove-empty-asm-gpio-h-files/20230207-223652
base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link:    https://lore.kernel.org/r/20230207142952.51844-13-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v3 12/12] gpiolib: Clean up headers
config: microblaze-buildonly-randconfig-r003-20230205 (https://download.01.org/0day-ci/archive/20230208/202302080415.9TcAlrVx-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/1b29af54a98628e27cdabe2554fbf29b75a1c18b
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/gpiolib-remove-empty-asm-gpio-h-files/20230207-223652
        git checkout 1b29af54a98628e27cdabe2554fbf29b75a1c18b
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=microblaze olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=microblaze SHELL=/bin/bash drivers/gpio/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   drivers/gpio/gpio-regmap.c: In function 'gpio_regmap_register':
>> drivers/gpio/gpio-regmap.c:256:40: error: implicit declaration of function 'dev_name' [-Werror=implicit-function-declaration]
     256 |         chip->label = config->label ?: dev_name(config->parent);
         |                                        ^~~~~~~~
>> drivers/gpio/gpio-regmap.c:256:38: warning: pointer/integer type mismatch in conditional expression
     256 |         chip->label = config->label ?: dev_name(config->parent);
         |                                      ^
   drivers/gpio/gpio-regmap.c: In function 'devm_gpio_regmap_register':
>> drivers/gpio/gpio-regmap.c:329:15: error: implicit declaration of function 'devm_add_action_or_reset' [-Werror=implicit-function-declaration]
     329 |         ret = devm_add_action_or_reset(dev, devm_gpio_regmap_unregister, gpio);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/dev_name +256 drivers/gpio/gpio-regmap.c

ebe363197e525ff Michael Walle          2020-05-28  191  
ebe363197e525ff Michael Walle          2020-05-28  192  /**
ebe363197e525ff Michael Walle          2020-05-28  193   * gpio_regmap_register() - Register a generic regmap GPIO controller
ebe363197e525ff Michael Walle          2020-05-28  194   * @config: configuration for gpio_regmap
ebe363197e525ff Michael Walle          2020-05-28  195   *
ebe363197e525ff Michael Walle          2020-05-28  196   * Return: A pointer to the registered gpio_regmap or ERR_PTR error value.
ebe363197e525ff Michael Walle          2020-05-28  197   */
ebe363197e525ff Michael Walle          2020-05-28  198  struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config)
ebe363197e525ff Michael Walle          2020-05-28  199  {
ebe363197e525ff Michael Walle          2020-05-28  200  	struct gpio_regmap *gpio;
ebe363197e525ff Michael Walle          2020-05-28  201  	struct gpio_chip *chip;
ebe363197e525ff Michael Walle          2020-05-28  202  	int ret;
ebe363197e525ff Michael Walle          2020-05-28  203  
ebe363197e525ff Michael Walle          2020-05-28  204  	if (!config->parent)
ebe363197e525ff Michael Walle          2020-05-28  205  		return ERR_PTR(-EINVAL);
ebe363197e525ff Michael Walle          2020-05-28  206  
ebe363197e525ff Michael Walle          2020-05-28  207  	if (!config->ngpio)
ebe363197e525ff Michael Walle          2020-05-28  208  		return ERR_PTR(-EINVAL);
ebe363197e525ff Michael Walle          2020-05-28  209  
ebe363197e525ff Michael Walle          2020-05-28  210  	/* we need at least one */
ebe363197e525ff Michael Walle          2020-05-28  211  	if (!config->reg_dat_base && !config->reg_set_base)
ebe363197e525ff Michael Walle          2020-05-28  212  		return ERR_PTR(-EINVAL);
ebe363197e525ff Michael Walle          2020-05-28  213  
ebe363197e525ff Michael Walle          2020-05-28  214  	/* if we have a direction register we need both input and output */
ebe363197e525ff Michael Walle          2020-05-28  215  	if ((config->reg_dir_out_base || config->reg_dir_in_base) &&
ebe363197e525ff Michael Walle          2020-05-28  216  	    (!config->reg_dat_base || !config->reg_set_base))
ebe363197e525ff Michael Walle          2020-05-28  217  		return ERR_PTR(-EINVAL);
ebe363197e525ff Michael Walle          2020-05-28  218  
ebe363197e525ff Michael Walle          2020-05-28  219  	/* we don't support having both registers simultaneously for now */
ebe363197e525ff Michael Walle          2020-05-28  220  	if (config->reg_dir_out_base && config->reg_dir_in_base)
ebe363197e525ff Michael Walle          2020-05-28  221  		return ERR_PTR(-EINVAL);
ebe363197e525ff Michael Walle          2020-05-28  222  
ebe363197e525ff Michael Walle          2020-05-28  223  	gpio = kzalloc(sizeof(*gpio), GFP_KERNEL);
ebe363197e525ff Michael Walle          2020-05-28  224  	if (!gpio)
ebe363197e525ff Michael Walle          2020-05-28  225  		return ERR_PTR(-ENOMEM);
ebe363197e525ff Michael Walle          2020-05-28  226  
ebe363197e525ff Michael Walle          2020-05-28  227  	gpio->parent = config->parent;
9b3c47f124b6077 Michael Walle          2021-06-05  228  	gpio->driver_data = config->drvdata;
ebe363197e525ff Michael Walle          2020-05-28  229  	gpio->regmap = config->regmap;
ebe363197e525ff Michael Walle          2020-05-28  230  	gpio->ngpio_per_reg = config->ngpio_per_reg;
ebe363197e525ff Michael Walle          2020-05-28  231  	gpio->reg_stride = config->reg_stride;
ebe363197e525ff Michael Walle          2020-05-28  232  	gpio->reg_mask_xlate = config->reg_mask_xlate;
ebe363197e525ff Michael Walle          2020-05-28  233  	gpio->reg_dat_base = config->reg_dat_base;
ebe363197e525ff Michael Walle          2020-05-28  234  	gpio->reg_set_base = config->reg_set_base;
ebe363197e525ff Michael Walle          2020-05-28  235  	gpio->reg_clr_base = config->reg_clr_base;
ebe363197e525ff Michael Walle          2020-05-28  236  	gpio->reg_dir_in_base = config->reg_dir_in_base;
ebe363197e525ff Michael Walle          2020-05-28  237  	gpio->reg_dir_out_base = config->reg_dir_out_base;
ebe363197e525ff Michael Walle          2020-05-28  238  
ebe363197e525ff Michael Walle          2020-05-28  239  	/* if not set, assume there is only one register */
ebe363197e525ff Michael Walle          2020-05-28  240  	if (!gpio->ngpio_per_reg)
ebe363197e525ff Michael Walle          2020-05-28  241  		gpio->ngpio_per_reg = config->ngpio;
ebe363197e525ff Michael Walle          2020-05-28  242  
ebe363197e525ff Michael Walle          2020-05-28  243  	/* if not set, assume they are consecutive */
ebe363197e525ff Michael Walle          2020-05-28  244  	if (!gpio->reg_stride)
ebe363197e525ff Michael Walle          2020-05-28  245  		gpio->reg_stride = 1;
ebe363197e525ff Michael Walle          2020-05-28  246  
ebe363197e525ff Michael Walle          2020-05-28  247  	if (!gpio->reg_mask_xlate)
ebe363197e525ff Michael Walle          2020-05-28  248  		gpio->reg_mask_xlate = gpio_regmap_simple_xlate;
ebe363197e525ff Michael Walle          2020-05-28  249  
ebe363197e525ff Michael Walle          2020-05-28  250  	chip = &gpio->gpio_chip;
ebe363197e525ff Michael Walle          2020-05-28  251  	chip->parent = config->parent;
f21ecad451c9b33 Andy Shevchenko        2021-12-23  252  	chip->fwnode = config->fwnode;
ebe363197e525ff Michael Walle          2020-05-28  253  	chip->base = -1;
ebe363197e525ff Michael Walle          2020-05-28  254  	chip->ngpio = config->ngpio;
ebe363197e525ff Michael Walle          2020-05-28  255  	chip->names = config->names;
ebe363197e525ff Michael Walle          2020-05-28 @256  	chip->label = config->label ?: dev_name(config->parent);
297a44f664a8ac2 Michael Walle          2023-01-05  257  	chip->can_sleep = regmap_might_sleep(config->regmap);
ebe363197e525ff Michael Walle          2020-05-28  258  
ebe363197e525ff Michael Walle          2020-05-28  259  	chip->get = gpio_regmap_get;
ebe363197e525ff Michael Walle          2020-05-28  260  	if (gpio->reg_set_base && gpio->reg_clr_base)
ebe363197e525ff Michael Walle          2020-05-28  261  		chip->set = gpio_regmap_set_with_clear;
ebe363197e525ff Michael Walle          2020-05-28  262  	else if (gpio->reg_set_base)
ebe363197e525ff Michael Walle          2020-05-28  263  		chip->set = gpio_regmap_set;
ebe363197e525ff Michael Walle          2020-05-28  264  
ebe363197e525ff Michael Walle          2020-05-28  265  	chip->get_direction = gpio_regmap_get_direction;
8978277c229b950 William Breathitt Gray 2022-12-27  266  	if (gpio->reg_dir_in_base || gpio->reg_dir_out_base) {
ebe363197e525ff Michael Walle          2020-05-28  267  		chip->direction_input = gpio_regmap_direction_input;
ebe363197e525ff Michael Walle          2020-05-28  268  		chip->direction_output = gpio_regmap_direction_output;
ebe363197e525ff Michael Walle          2020-05-28  269  	}
ebe363197e525ff Michael Walle          2020-05-28  270  
ebe363197e525ff Michael Walle          2020-05-28  271  	ret = gpiochip_add_data(chip, gpio);
ebe363197e525ff Michael Walle          2020-05-28  272  	if (ret < 0)
ebe363197e525ff Michael Walle          2020-05-28  273  		goto err_free_gpio;
ebe363197e525ff Michael Walle          2020-05-28  274  
ebe363197e525ff Michael Walle          2020-05-28  275  	if (config->irq_domain) {
ebe363197e525ff Michael Walle          2020-05-28  276  		ret = gpiochip_irqchip_add_domain(chip, config->irq_domain);
ebe363197e525ff Michael Walle          2020-05-28  277  		if (ret)
ebe363197e525ff Michael Walle          2020-05-28  278  			goto err_remove_gpiochip;
ebe363197e525ff Michael Walle          2020-05-28  279  	}
ebe363197e525ff Michael Walle          2020-05-28  280  
ebe363197e525ff Michael Walle          2020-05-28  281  	return gpio;
ebe363197e525ff Michael Walle          2020-05-28  282  
ebe363197e525ff Michael Walle          2020-05-28  283  err_remove_gpiochip:
ebe363197e525ff Michael Walle          2020-05-28  284  	gpiochip_remove(chip);
ebe363197e525ff Michael Walle          2020-05-28  285  err_free_gpio:
ebe363197e525ff Michael Walle          2020-05-28  286  	kfree(gpio);
ebe363197e525ff Michael Walle          2020-05-28  287  	return ERR_PTR(ret);
ebe363197e525ff Michael Walle          2020-05-28  288  }
ebe363197e525ff Michael Walle          2020-05-28  289  EXPORT_SYMBOL_GPL(gpio_regmap_register);
ebe363197e525ff Michael Walle          2020-05-28  290  
ebe363197e525ff Michael Walle          2020-05-28  291  /**
ebe363197e525ff Michael Walle          2020-05-28  292   * gpio_regmap_unregister() - Unregister a generic regmap GPIO controller
ebe363197e525ff Michael Walle          2020-05-28  293   * @gpio: gpio_regmap device to unregister
ebe363197e525ff Michael Walle          2020-05-28  294   */
ebe363197e525ff Michael Walle          2020-05-28  295  void gpio_regmap_unregister(struct gpio_regmap *gpio)
ebe363197e525ff Michael Walle          2020-05-28  296  {
ebe363197e525ff Michael Walle          2020-05-28  297  	gpiochip_remove(&gpio->gpio_chip);
ebe363197e525ff Michael Walle          2020-05-28  298  	kfree(gpio);
ebe363197e525ff Michael Walle          2020-05-28  299  }
ebe363197e525ff Michael Walle          2020-05-28  300  EXPORT_SYMBOL_GPL(gpio_regmap_unregister);
ebe363197e525ff Michael Walle          2020-05-28  301  
40e568f9c88db8e Matti Vaittinen        2021-06-03  302  static void devm_gpio_regmap_unregister(void *res)
ebe363197e525ff Michael Walle          2020-05-28  303  {
40e568f9c88db8e Matti Vaittinen        2021-06-03  304  	gpio_regmap_unregister(res);
ebe363197e525ff Michael Walle          2020-05-28  305  }
ebe363197e525ff Michael Walle          2020-05-28  306  
ebe363197e525ff Michael Walle          2020-05-28  307  /**
ebe363197e525ff Michael Walle          2020-05-28  308   * devm_gpio_regmap_register() - resource managed gpio_regmap_register()
ebe363197e525ff Michael Walle          2020-05-28  309   * @dev: device that is registering this GPIO device
ebe363197e525ff Michael Walle          2020-05-28  310   * @config: configuration for gpio_regmap
ebe363197e525ff Michael Walle          2020-05-28  311   *
ebe363197e525ff Michael Walle          2020-05-28  312   * Managed gpio_regmap_register(). For generic regmap GPIO device registered by
ebe363197e525ff Michael Walle          2020-05-28  313   * this function, gpio_regmap_unregister() is automatically called on driver
ebe363197e525ff Michael Walle          2020-05-28  314   * detach. See gpio_regmap_register() for more information.
ebe363197e525ff Michael Walle          2020-05-28  315   *
ebe363197e525ff Michael Walle          2020-05-28  316   * Return: A pointer to the registered gpio_regmap or ERR_PTR error value.
ebe363197e525ff Michael Walle          2020-05-28  317   */
ebe363197e525ff Michael Walle          2020-05-28  318  struct gpio_regmap *devm_gpio_regmap_register(struct device *dev,
ebe363197e525ff Michael Walle          2020-05-28  319  					      const struct gpio_regmap_config *config)
ebe363197e525ff Michael Walle          2020-05-28  320  {
40e568f9c88db8e Matti Vaittinen        2021-06-03  321  	struct gpio_regmap *gpio;
40e568f9c88db8e Matti Vaittinen        2021-06-03  322  	int ret;
ebe363197e525ff Michael Walle          2020-05-28  323  
ebe363197e525ff Michael Walle          2020-05-28  324  	gpio = gpio_regmap_register(config);
40e568f9c88db8e Matti Vaittinen        2021-06-03  325  
40e568f9c88db8e Matti Vaittinen        2021-06-03  326  	if (IS_ERR(gpio))
40e568f9c88db8e Matti Vaittinen        2021-06-03  327  		return gpio;
40e568f9c88db8e Matti Vaittinen        2021-06-03  328  
40e568f9c88db8e Matti Vaittinen        2021-06-03 @329  	ret = devm_add_action_or_reset(dev, devm_gpio_regmap_unregister, gpio);
40e568f9c88db8e Matti Vaittinen        2021-06-03  330  	if (ret)
40e568f9c88db8e Matti Vaittinen        2021-06-03  331  		return ERR_PTR(ret);
ebe363197e525ff Michael Walle          2020-05-28  332  
ebe363197e525ff Michael Walle          2020-05-28  333  	return gpio;
ebe363197e525ff Michael Walle          2020-05-28  334  }
ebe363197e525ff Michael Walle          2020-05-28  335  EXPORT_SYMBOL_GPL(devm_gpio_regmap_register);
ebe363197e525ff Michael Walle          2020-05-28  336  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

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

* Re: [PATCH v3 12/12] gpiolib: Clean up headers
  2023-02-07 14:29   ` Andy Shevchenko
                     ` (2 preceding siblings ...)
  (?)
@ 2023-02-07 20:32   ` kernel test robot
  -1 siblings, 0 replies; 53+ messages in thread
From: kernel test robot @ 2023-02-07 20:32 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: oe-kbuild-all

Hi Andy,

I love your patch! Perhaps something to improve:

[auto build test WARNING on brgl/gpio/for-next]
[also build test WARNING on next-20230207]
[cannot apply to powerpc/next powerpc/fixes soc/for-next linus/master v6.2-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/gpiolib-remove-empty-asm-gpio-h-files/20230207-223652
base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link:    https://lore.kernel.org/r/20230207142952.51844-13-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v3 12/12] gpiolib: Clean up headers
config: arm-assabet_defconfig (https://download.01.org/0day-ci/archive/20230208/202302080455.WG29wF0y-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/1b29af54a98628e27cdabe2554fbf29b75a1c18b
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/gpiolib-remove-empty-asm-gpio-h-files/20230207-223652
        git checkout 1b29af54a98628e27cdabe2554fbf29b75a1c18b
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/gpio/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/gpio/gpio-reg.c: In function 'gpio_reg_init':
   drivers/gpio/gpio-reg.c:139:21: error: implicit declaration of function 'devm_kzalloc' [-Werror=implicit-function-declaration]
     139 |                 r = devm_kzalloc(dev, sizeof(*r), GFP_KERNEL);
         |                     ^~~~~~~~~~~~
>> drivers/gpio/gpio-reg.c:139:19: warning: assignment to 'struct gpio_reg *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     139 |                 r = devm_kzalloc(dev, sizeof(*r), GFP_KERNEL);
         |                   ^
   cc1: some warnings being treated as errors


vim +139 drivers/gpio/gpio-reg.c

0e3cb6ee386f384 Russell King 2016-09-02  109  
380639c7cc786ec Russell King 2016-08-31  110  /**
380639c7cc786ec Russell King 2016-08-31  111   * gpio_reg_init - add a fixed in/out register as gpio
380639c7cc786ec Russell King 2016-08-31  112   * @dev: optional struct device associated with this register
380639c7cc786ec Russell King 2016-08-31  113   * @base: start gpio number, or -1 to allocate
380639c7cc786ec Russell King 2016-08-31  114   * @num: number of GPIOs, maximum 32
380639c7cc786ec Russell King 2016-08-31  115   * @label: GPIO chip label
380639c7cc786ec Russell King 2016-08-31  116   * @direction: bitmask of fixed direction, one per GPIO signal, 1 = in
380639c7cc786ec Russell King 2016-08-31  117   * @def_out: initial GPIO output value
0e3cb6ee386f384 Russell King 2016-09-02  118   * @names: array of %num strings describing each GPIO signal or %NULL
0e3cb6ee386f384 Russell King 2016-09-02  119   * @irqdom: irq domain or %NULL
0e3cb6ee386f384 Russell King 2016-09-02  120   * @irqs: array of %num ints describing the interrupt mapping for each
0e3cb6ee386f384 Russell King 2016-09-02  121   *        GPIO signal, or %NULL.  If @irqdom is %NULL, then this
0e3cb6ee386f384 Russell King 2016-09-02  122   *        describes the Linux interrupt number, otherwise it describes
0e3cb6ee386f384 Russell King 2016-09-02  123   *        the hardware interrupt number in the specified irq domain.
380639c7cc786ec Russell King 2016-08-31  124   *
380639c7cc786ec Russell King 2016-08-31  125   * Add a single-register GPIO device containing up to 32 GPIO signals,
380639c7cc786ec Russell King 2016-08-31  126   * where each GPIO has a fixed input or output configuration.  Only
380639c7cc786ec Russell King 2016-08-31  127   * input GPIOs are assumed to be readable from the register, and only
380639c7cc786ec Russell King 2016-08-31  128   * then after a double-read.  Output values are assumed not to be
380639c7cc786ec Russell King 2016-08-31  129   * readable.
380639c7cc786ec Russell King 2016-08-31  130   */
380639c7cc786ec Russell King 2016-08-31  131  struct gpio_chip *gpio_reg_init(struct device *dev, void __iomem *reg,
380639c7cc786ec Russell King 2016-08-31  132  	int base, int num, const char *label, u32 direction, u32 def_out,
0e3cb6ee386f384 Russell King 2016-09-02  133  	const char *const *names, struct irq_domain *irqdom, const int *irqs)
380639c7cc786ec Russell King 2016-08-31  134  {
380639c7cc786ec Russell King 2016-08-31  135  	struct gpio_reg *r;
380639c7cc786ec Russell King 2016-08-31  136  	int ret;
380639c7cc786ec Russell King 2016-08-31  137  
380639c7cc786ec Russell King 2016-08-31  138  	if (dev)
380639c7cc786ec Russell King 2016-08-31 @139  		r = devm_kzalloc(dev, sizeof(*r), GFP_KERNEL);
380639c7cc786ec Russell King 2016-08-31  140  	else
380639c7cc786ec Russell King 2016-08-31  141  		r = kzalloc(sizeof(*r), GFP_KERNEL);
380639c7cc786ec Russell King 2016-08-31  142  
380639c7cc786ec Russell King 2016-08-31  143  	if (!r)
380639c7cc786ec Russell King 2016-08-31  144  		return ERR_PTR(-ENOMEM);
380639c7cc786ec Russell King 2016-08-31  145  
380639c7cc786ec Russell King 2016-08-31  146  	spin_lock_init(&r->lock);
380639c7cc786ec Russell King 2016-08-31  147  
380639c7cc786ec Russell King 2016-08-31  148  	r->gc.label = label;
380639c7cc786ec Russell King 2016-08-31  149  	r->gc.get_direction = gpio_reg_get_direction;
380639c7cc786ec Russell King 2016-08-31  150  	r->gc.direction_input = gpio_reg_direction_input;
380639c7cc786ec Russell King 2016-08-31  151  	r->gc.direction_output = gpio_reg_direction_output;
380639c7cc786ec Russell King 2016-08-31  152  	r->gc.set = gpio_reg_set;
380639c7cc786ec Russell King 2016-08-31  153  	r->gc.get = gpio_reg_get;
380639c7cc786ec Russell King 2016-08-31  154  	r->gc.set_multiple = gpio_reg_set_multiple;
0e3cb6ee386f384 Russell King 2016-09-02  155  	if (irqs)
0e3cb6ee386f384 Russell King 2016-09-02  156  		r->gc.to_irq = gpio_reg_to_irq;
380639c7cc786ec Russell King 2016-08-31  157  	r->gc.base = base;
380639c7cc786ec Russell King 2016-08-31  158  	r->gc.ngpio = num;
380639c7cc786ec Russell King 2016-08-31  159  	r->gc.names = names;
380639c7cc786ec Russell King 2016-08-31  160  	r->direction = direction;
380639c7cc786ec Russell King 2016-08-31  161  	r->out = def_out;
380639c7cc786ec Russell King 2016-08-31  162  	r->reg = reg;
0e3cb6ee386f384 Russell King 2016-09-02  163  	r->irqs = irqs;
380639c7cc786ec Russell King 2016-08-31  164  
380639c7cc786ec Russell King 2016-08-31  165  	if (dev)
380639c7cc786ec Russell King 2016-08-31  166  		ret = devm_gpiochip_add_data(dev, &r->gc, r);
380639c7cc786ec Russell King 2016-08-31  167  	else
380639c7cc786ec Russell King 2016-08-31  168  		ret = gpiochip_add_data(&r->gc, r);
380639c7cc786ec Russell King 2016-08-31  169  
380639c7cc786ec Russell King 2016-08-31  170  	return ret ? ERR_PTR(ret) : &r->gc;
380639c7cc786ec Russell King 2016-08-31  171  }
380639c7cc786ec Russell King 2016-08-31  172  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

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

* Re: [PATCH v3 12/12] gpiolib: Clean up headers
  2023-02-07 14:29   ` Andy Shevchenko
                     ` (3 preceding siblings ...)
  (?)
@ 2023-02-07 20:52   ` kernel test robot
  -1 siblings, 0 replies; 53+ messages in thread
From: kernel test robot @ 2023-02-07 20:52 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: oe-kbuild-all

Hi Andy,

I love your patch! Perhaps something to improve:

[auto build test WARNING on brgl/gpio/for-next]
[also build test WARNING on next-20230207]
[cannot apply to powerpc/next powerpc/fixes soc/for-next linus/master v6.2-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/gpiolib-remove-empty-asm-gpio-h-files/20230207-223652
base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link:    https://lore.kernel.org/r/20230207142952.51844-13-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v3 12/12] gpiolib: Clean up headers
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230208/202302080412.kZeKWUuw-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/1b29af54a98628e27cdabe2554fbf29b75a1c18b
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/gpiolib-remove-empty-asm-gpio-h-files/20230207-223652
        git checkout 1b29af54a98628e27cdabe2554fbf29b75a1c18b
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/gpio/gpio-regmap.c: In function 'gpio_regmap_register':
   drivers/gpio/gpio-regmap.c:256:40: error: implicit declaration of function 'dev_name' [-Werror=implicit-function-declaration]
     256 |         chip->label = config->label ?: dev_name(config->parent);
         |                                        ^~~~~~~~
>> drivers/gpio/gpio-regmap.c:256:38: warning: pointer/integer type mismatch in conditional expression
     256 |         chip->label = config->label ?: dev_name(config->parent);
         |                                      ^
   drivers/gpio/gpio-regmap.c: In function 'devm_gpio_regmap_register':
   drivers/gpio/gpio-regmap.c:329:15: error: implicit declaration of function 'devm_add_action_or_reset' [-Werror=implicit-function-declaration]
     329 |         ret = devm_add_action_or_reset(dev, devm_gpio_regmap_unregister, gpio);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +256 drivers/gpio/gpio-regmap.c

ebe363197e525ff Michael Walle          2020-05-28  191  
ebe363197e525ff Michael Walle          2020-05-28  192  /**
ebe363197e525ff Michael Walle          2020-05-28  193   * gpio_regmap_register() - Register a generic regmap GPIO controller
ebe363197e525ff Michael Walle          2020-05-28  194   * @config: configuration for gpio_regmap
ebe363197e525ff Michael Walle          2020-05-28  195   *
ebe363197e525ff Michael Walle          2020-05-28  196   * Return: A pointer to the registered gpio_regmap or ERR_PTR error value.
ebe363197e525ff Michael Walle          2020-05-28  197   */
ebe363197e525ff Michael Walle          2020-05-28  198  struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config)
ebe363197e525ff Michael Walle          2020-05-28  199  {
ebe363197e525ff Michael Walle          2020-05-28  200  	struct gpio_regmap *gpio;
ebe363197e525ff Michael Walle          2020-05-28  201  	struct gpio_chip *chip;
ebe363197e525ff Michael Walle          2020-05-28  202  	int ret;
ebe363197e525ff Michael Walle          2020-05-28  203  
ebe363197e525ff Michael Walle          2020-05-28  204  	if (!config->parent)
ebe363197e525ff Michael Walle          2020-05-28  205  		return ERR_PTR(-EINVAL);
ebe363197e525ff Michael Walle          2020-05-28  206  
ebe363197e525ff Michael Walle          2020-05-28  207  	if (!config->ngpio)
ebe363197e525ff Michael Walle          2020-05-28  208  		return ERR_PTR(-EINVAL);
ebe363197e525ff Michael Walle          2020-05-28  209  
ebe363197e525ff Michael Walle          2020-05-28  210  	/* we need at least one */
ebe363197e525ff Michael Walle          2020-05-28  211  	if (!config->reg_dat_base && !config->reg_set_base)
ebe363197e525ff Michael Walle          2020-05-28  212  		return ERR_PTR(-EINVAL);
ebe363197e525ff Michael Walle          2020-05-28  213  
ebe363197e525ff Michael Walle          2020-05-28  214  	/* if we have a direction register we need both input and output */
ebe363197e525ff Michael Walle          2020-05-28  215  	if ((config->reg_dir_out_base || config->reg_dir_in_base) &&
ebe363197e525ff Michael Walle          2020-05-28  216  	    (!config->reg_dat_base || !config->reg_set_base))
ebe363197e525ff Michael Walle          2020-05-28  217  		return ERR_PTR(-EINVAL);
ebe363197e525ff Michael Walle          2020-05-28  218  
ebe363197e525ff Michael Walle          2020-05-28  219  	/* we don't support having both registers simultaneously for now */
ebe363197e525ff Michael Walle          2020-05-28  220  	if (config->reg_dir_out_base && config->reg_dir_in_base)
ebe363197e525ff Michael Walle          2020-05-28  221  		return ERR_PTR(-EINVAL);
ebe363197e525ff Michael Walle          2020-05-28  222  
ebe363197e525ff Michael Walle          2020-05-28  223  	gpio = kzalloc(sizeof(*gpio), GFP_KERNEL);
ebe363197e525ff Michael Walle          2020-05-28  224  	if (!gpio)
ebe363197e525ff Michael Walle          2020-05-28  225  		return ERR_PTR(-ENOMEM);
ebe363197e525ff Michael Walle          2020-05-28  226  
ebe363197e525ff Michael Walle          2020-05-28  227  	gpio->parent = config->parent;
9b3c47f124b6077 Michael Walle          2021-06-05  228  	gpio->driver_data = config->drvdata;
ebe363197e525ff Michael Walle          2020-05-28  229  	gpio->regmap = config->regmap;
ebe363197e525ff Michael Walle          2020-05-28  230  	gpio->ngpio_per_reg = config->ngpio_per_reg;
ebe363197e525ff Michael Walle          2020-05-28  231  	gpio->reg_stride = config->reg_stride;
ebe363197e525ff Michael Walle          2020-05-28  232  	gpio->reg_mask_xlate = config->reg_mask_xlate;
ebe363197e525ff Michael Walle          2020-05-28  233  	gpio->reg_dat_base = config->reg_dat_base;
ebe363197e525ff Michael Walle          2020-05-28  234  	gpio->reg_set_base = config->reg_set_base;
ebe363197e525ff Michael Walle          2020-05-28  235  	gpio->reg_clr_base = config->reg_clr_base;
ebe363197e525ff Michael Walle          2020-05-28  236  	gpio->reg_dir_in_base = config->reg_dir_in_base;
ebe363197e525ff Michael Walle          2020-05-28  237  	gpio->reg_dir_out_base = config->reg_dir_out_base;
ebe363197e525ff Michael Walle          2020-05-28  238  
ebe363197e525ff Michael Walle          2020-05-28  239  	/* if not set, assume there is only one register */
ebe363197e525ff Michael Walle          2020-05-28  240  	if (!gpio->ngpio_per_reg)
ebe363197e525ff Michael Walle          2020-05-28  241  		gpio->ngpio_per_reg = config->ngpio;
ebe363197e525ff Michael Walle          2020-05-28  242  
ebe363197e525ff Michael Walle          2020-05-28  243  	/* if not set, assume they are consecutive */
ebe363197e525ff Michael Walle          2020-05-28  244  	if (!gpio->reg_stride)
ebe363197e525ff Michael Walle          2020-05-28  245  		gpio->reg_stride = 1;
ebe363197e525ff Michael Walle          2020-05-28  246  
ebe363197e525ff Michael Walle          2020-05-28  247  	if (!gpio->reg_mask_xlate)
ebe363197e525ff Michael Walle          2020-05-28  248  		gpio->reg_mask_xlate = gpio_regmap_simple_xlate;
ebe363197e525ff Michael Walle          2020-05-28  249  
ebe363197e525ff Michael Walle          2020-05-28  250  	chip = &gpio->gpio_chip;
ebe363197e525ff Michael Walle          2020-05-28  251  	chip->parent = config->parent;
f21ecad451c9b33 Andy Shevchenko        2021-12-23  252  	chip->fwnode = config->fwnode;
ebe363197e525ff Michael Walle          2020-05-28  253  	chip->base = -1;
ebe363197e525ff Michael Walle          2020-05-28  254  	chip->ngpio = config->ngpio;
ebe363197e525ff Michael Walle          2020-05-28  255  	chip->names = config->names;
ebe363197e525ff Michael Walle          2020-05-28 @256  	chip->label = config->label ?: dev_name(config->parent);
297a44f664a8ac2 Michael Walle          2023-01-05  257  	chip->can_sleep = regmap_might_sleep(config->regmap);
ebe363197e525ff Michael Walle          2020-05-28  258  
ebe363197e525ff Michael Walle          2020-05-28  259  	chip->get = gpio_regmap_get;
ebe363197e525ff Michael Walle          2020-05-28  260  	if (gpio->reg_set_base && gpio->reg_clr_base)
ebe363197e525ff Michael Walle          2020-05-28  261  		chip->set = gpio_regmap_set_with_clear;
ebe363197e525ff Michael Walle          2020-05-28  262  	else if (gpio->reg_set_base)
ebe363197e525ff Michael Walle          2020-05-28  263  		chip->set = gpio_regmap_set;
ebe363197e525ff Michael Walle          2020-05-28  264  
ebe363197e525ff Michael Walle          2020-05-28  265  	chip->get_direction = gpio_regmap_get_direction;
8978277c229b950 William Breathitt Gray 2022-12-27  266  	if (gpio->reg_dir_in_base || gpio->reg_dir_out_base) {
ebe363197e525ff Michael Walle          2020-05-28  267  		chip->direction_input = gpio_regmap_direction_input;
ebe363197e525ff Michael Walle          2020-05-28  268  		chip->direction_output = gpio_regmap_direction_output;
ebe363197e525ff Michael Walle          2020-05-28  269  	}
ebe363197e525ff Michael Walle          2020-05-28  270  
ebe363197e525ff Michael Walle          2020-05-28  271  	ret = gpiochip_add_data(chip, gpio);
ebe363197e525ff Michael Walle          2020-05-28  272  	if (ret < 0)
ebe363197e525ff Michael Walle          2020-05-28  273  		goto err_free_gpio;
ebe363197e525ff Michael Walle          2020-05-28  274  
ebe363197e525ff Michael Walle          2020-05-28  275  	if (config->irq_domain) {
ebe363197e525ff Michael Walle          2020-05-28  276  		ret = gpiochip_irqchip_add_domain(chip, config->irq_domain);
ebe363197e525ff Michael Walle          2020-05-28  277  		if (ret)
ebe363197e525ff Michael Walle          2020-05-28  278  			goto err_remove_gpiochip;
ebe363197e525ff Michael Walle          2020-05-28  279  	}
ebe363197e525ff Michael Walle          2020-05-28  280  
ebe363197e525ff Michael Walle          2020-05-28  281  	return gpio;
ebe363197e525ff Michael Walle          2020-05-28  282  
ebe363197e525ff Michael Walle          2020-05-28  283  err_remove_gpiochip:
ebe363197e525ff Michael Walle          2020-05-28  284  	gpiochip_remove(chip);
ebe363197e525ff Michael Walle          2020-05-28  285  err_free_gpio:
ebe363197e525ff Michael Walle          2020-05-28  286  	kfree(gpio);
ebe363197e525ff Michael Walle          2020-05-28  287  	return ERR_PTR(ret);
ebe363197e525ff Michael Walle          2020-05-28  288  }
ebe363197e525ff Michael Walle          2020-05-28  289  EXPORT_SYMBOL_GPL(gpio_regmap_register);
ebe363197e525ff Michael Walle          2020-05-28  290  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

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

* Re: [PATCH v3 01/12] gpiolib: remove empty asm/gpio.h files
  2023-02-07 14:29   ` Andy Shevchenko
@ 2023-02-07 20:53     ` Vincenzo Palazzo
  -1 siblings, 0 replies; 53+ messages in thread
From: Vincenzo Palazzo @ 2023-02-07 20:53 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Bartosz Golaszewski, Jonathan Corbet, Alex Shi, Yanteng Si,
	Hu Haowen, Russell King, Aaro Koskinen, Janusz Krzysztofik,
	Andrew Lunn, Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
	Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
	Keerthy, Mika Westerberg, Mauro Carvalho Chehab, Alexander Aring,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Arend van Spriel, Franky Lin, Hante Meuleman, Kalle Valo,
	Qiang Zhao, Li Yang, Lee Jones, Rob Herring, Frank Rowand,
	Geert Uytterhoeven

> From: Arnd Bergmann <arnd@arndb.de>
>
> The arm and sh versions of this file are identical to the generic
> versions and can just be removed.
>
> The drivers that actually use the sh3 specific version also include
> cpu/gpio.h directly, with the exception of magicpanelr2, which is
> easily fixed. This leaves coldfire as the only gpio driver
> that needs something custom for gpiolib.
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>

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

* Re: [PATCH v3 01/12] gpiolib: remove empty asm/gpio.h files
@ 2023-02-07 20:53     ` Vincenzo Palazzo
  0 siblings, 0 replies; 53+ messages in thread
From: Vincenzo Palazzo @ 2023-02-07 20:53 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, Arnd Bergmann,
	Bartosz Golaszewski, Tony Lindgren, Thomas Gleixner,
	Krzysztof Kozlowski, Geert Uytterhoeven, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Geert Uytterhoeven,
	Eric Dumazet, Alim Akhtar, Frank Rowand, Alex Shi, Qiang Zhao,
	Yanteng Si, Yoshinori Sato, Jonathan Corbet, Bartosz Golaszewski,
	Lee Jones, Janusz Krzysztofik, Russell King, Jakub Kicinski,
	Paolo Abeni, Sebastian Hesselbarth, Gregory Clement, Kalle Valo,
	Hante Meuleman, Nicholas Piggin, Rob Herring,
	Mauro Carvalho Chehab, Mika Westerberg, Franky Lin,
	Arend van Spriel, Mun Yew Tham, Hu Haowen, Keerthy,
	Aaro Koskinen, Li Yang, David S. Miller

> From: Arnd Bergmann <arnd@arndb.de>
>
> The arm and sh versions of this file are identical to the generic
> versions and can just be removed.
>
> The drivers that actually use the sh3 specific version also include
> cpu/gpio.h directly, with the exception of magicpanelr2, which is
> easily fixed. This leaves coldfire as the only gpio driver
> that needs something custom for gpiolib.
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>

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

* Re: [PATCH v3 04/12] gpiolib: remove gpio_set_debounce
  2023-02-07 14:29   ` Andy Shevchenko
@ 2023-02-07 21:32     ` Dmitry Torokhov
  -1 siblings, 0 replies; 53+ messages in thread
From: Dmitry Torokhov @ 2023-02-07 21:32 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, Arnd Bergmann, Bartosz Golaszewski, Tony Lindgren,
	Thomas Gleixner, Krzysztof Kozlowski, Geert Uytterhoeven,
	Christophe Leroy, Michael Ellerman, Devarsh Thakkar,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree, Bartosz Golaszewski, Jonathan Corbet,
	Alex Shi, Yanteng Si, Hu Haowen, Russell King, Aaro Koskinen,
	Janusz Krzysztofik, Andrew Lunn, Sebastian Hesselbarth,
	Gregory Clement, Alim Akhtar, Nicholas Piggin, Yoshinori Sato,
	Rich Felker, Mun Yew Tham, Keerthy, Mika Westerberg,
	Mauro Carvalho Chehab, Alexander Aring, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Arend van Spriel,
	Franky Lin, Hante Meuleman, Kalle Valo, Qiang Zhao, Li Yang,
	Lee Jones, Rob Herring, Frank Rowand

On Tue, Feb 07, 2023 at 04:29:44PM +0200, Andy Shevchenko wrote:
> @@ -1010,14 +1009,21 @@ static int ads7846_setup_pendown(struct spi_device *spi,
>  		}
>  
>  		ts->gpio_pendown = pdata->gpio_pendown;
> -
> -		if (pdata->gpio_pendown_debounce)
> -			gpio_set_debounce(pdata->gpio_pendown,
> -					  pdata->gpio_pendown_debounce);

Can we please change only this to:

			gpiod_set_debounce(gpio_to_desc(pdata->gpio_pendown),
					   pdata->gpio_pendown_debounce);

and not change anything else (i.e. drop the changes below)?

>  	} else {
> -		dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
> -		return -EINVAL;
> +		struct gpio_desc *desc;
> +
> +		desc = devm_gpiod_get(&spi->dev, "pendown", GPIOD_IN);
> +		if (IS_ERR(desc)) {
> +			dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
> +			return PTR_ERR(desc);
> +		}
> +		gpiod_set_consumer_name(desc, "ads7846_pendown");
> +
> +		ts->gpio_pendown = desc_to_gpio(desc);
>  	}
> +	if (pdata->gpio_pendown_debounce)
> +		gpiod_set_debounce(gpio_to_desc(ts->gpio_pendown),
> +				   pdata->gpio_pendown_debounce);
>  
>  	return 0;

Thanks.

-- 
Dmitry

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

* Re: [PATCH v3 04/12] gpiolib: remove gpio_set_debounce
@ 2023-02-07 21:32     ` Dmitry Torokhov
  0 siblings, 0 replies; 53+ messages in thread
From: Dmitry Torokhov @ 2023-02-07 21:32 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Devarsh Thakkar,
	linux-doc, Tony Lindgren, Linus Walleij, Eric Dumazet, Lee Jones,
	Alim Akhtar, Miquel Raynal, Li Yang, Frank Rowand,
	Stefan Schmidt, Qiang Zhao, linux-arch, linux-samsung-soc,
	Yoshinori Sato, Bartosz Golaszewski, Bartosz Golaszewski,
	linux-sh, Janusz Krzysztofik, Russell King, linux-acpi,
	SHA-cyfmac-dev-list, Geert Uytterhoeven, Alex Shi, linux-input,
	Jakub Kicinski, Paolo Abeni, Kalle Valo, linux-media, devicetree,
	Arnd Bergmann, Mauro Carvalho Chehab, Arend van Spriel,
	Nicholas Piggin, Hante Meuleman, linux-gpio, linux-m68k,
	Yanteng Si, Thomas Gleixner, linux-omap, Mika Westerberg,
	linux-arm-kernel, Franky Lin, brcm80211-dev-list.pdl, Keerthy,
	Mun Yew Tham, Hu Haowen, linux-wpan, linux-doc-tw-discuss,
	Jonathan Corbet, linux-wireless, linux-kernel, David S. Miller,
	Krzyszto f Kozlowski, Rob Herring, netdev, Aaro Koskinen,
	Sebastian Hesselbarth, linuxppc-dev, Gregory Clement

On Tue, Feb 07, 2023 at 04:29:44PM +0200, Andy Shevchenko wrote:
> @@ -1010,14 +1009,21 @@ static int ads7846_setup_pendown(struct spi_device *spi,
>  		}
>  
>  		ts->gpio_pendown = pdata->gpio_pendown;
> -
> -		if (pdata->gpio_pendown_debounce)
> -			gpio_set_debounce(pdata->gpio_pendown,
> -					  pdata->gpio_pendown_debounce);

Can we please change only this to:

			gpiod_set_debounce(gpio_to_desc(pdata->gpio_pendown),
					   pdata->gpio_pendown_debounce);

and not change anything else (i.e. drop the changes below)?

>  	} else {
> -		dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
> -		return -EINVAL;
> +		struct gpio_desc *desc;
> +
> +		desc = devm_gpiod_get(&spi->dev, "pendown", GPIOD_IN);
> +		if (IS_ERR(desc)) {
> +			dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
> +			return PTR_ERR(desc);
> +		}
> +		gpiod_set_consumer_name(desc, "ads7846_pendown");
> +
> +		ts->gpio_pendown = desc_to_gpio(desc);
>  	}
> +	if (pdata->gpio_pendown_debounce)
> +		gpiod_set_debounce(gpio_to_desc(ts->gpio_pendown),
> +				   pdata->gpio_pendown_debounce);
>  
>  	return 0;

Thanks.

-- 
Dmitry

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

* Re: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
  2023-02-07 14:55     ` Linus Walleij
  (?)
@ 2023-02-07 22:55       ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 22:55 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Arnd Bergmann, Bartosz Golaszewski, Geert Uytterhoeven,
	Christophe Leroy, Michael Ellerman, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree, Bartosz Golaszewski

On Tue, Feb 07, 2023 at 03:55:23PM +0100, Linus Walleij wrote:
> On Tue, Feb 7, 2023 at 3:29 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> 
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > Almost all gpio drivers include linux/gpio/driver.h, and other
> > files should not rely on includes from this header.
> >
> > Remove the indirect include from here and include the correct
> > headers directly from where they are used.

...

> Make sure you push this to the kernel.org build servers (zeroday builds),

Of course, that is the purpose of publishing this before the release (so we
will have some TODO list that eventually this can be applied for v6.4-rc1).

> I think this patch needs to hit some more files, in my tests with a similar
> patch at least these:

Right. I forgot to also incorporate your stuff into this series.
Do you have anything that I can take as is?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
@ 2023-02-07 22:55       ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 22:55 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-sh, Miquel Raynal, Stefan Schmidt, linux-arch,
	linux-samsung-soc, Bartosz Golaszewski, Bartosz Golaszewski,
	linux-doc, linux-acpi, SHA-cyfmac-dev-list, Geert Uytterhoeven,
	linux-input, linux-media, devicetree, Arnd Bergmann, linux-gpio,
	linux-m68k, linux-omap, linux-arm-kernel, brcm80211-dev-list.pdl,
	linuxppc-dev, linux-doc-tw-discuss, Dmitry Torokhov,
	linux-wireless, linux-kernel, netdev, linux-wpan

On Tue, Feb 07, 2023 at 03:55:23PM +0100, Linus Walleij wrote:
> On Tue, Feb 7, 2023 at 3:29 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> 
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > Almost all gpio drivers include linux/gpio/driver.h, and other
> > files should not rely on includes from this header.
> >
> > Remove the indirect include from here and include the correct
> > headers directly from where they are used.

...

> Make sure you push this to the kernel.org build servers (zeroday builds),

Of course, that is the purpose of publishing this before the release (so we
will have some TODO list that eventually this can be applied for v6.4-rc1).

> I think this patch needs to hit some more files, in my tests with a similar
> patch at least these:

Right. I forgot to also incorporate your stuff into this series.
Do you have anything that I can take as is?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
@ 2023-02-07 22:55       ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 22:55 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Arnd Bergmann, Bartosz Golaszewski, Geert Uytterhoeven,
	Christophe Leroy, Michael Ellerman, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree, Bartosz Golaszewski

On Tue, Feb 07, 2023 at 03:55:23PM +0100, Linus Walleij wrote:
> On Tue, Feb 7, 2023 at 3:29 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> 
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > Almost all gpio drivers include linux/gpio/driver.h, and other
> > files should not rely on includes from this header.
> >
> > Remove the indirect include from here and include the correct
> > headers directly from where they are used.

...

> Make sure you push this to the kernel.org build servers (zeroday builds),

Of course, that is the purpose of publishing this before the release (so we
will have some TODO list that eventually this can be applied for v6.4-rc1).

> I think this patch needs to hit some more files, in my tests with a similar
> patch at least these:

Right. I forgot to also incorporate your stuff into this series.
Do you have anything that I can take as is?

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 04/12] gpiolib: remove gpio_set_debounce
  2023-02-07 21:32     ` Dmitry Torokhov
  (?)
@ 2023-02-07 22:56       ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 22:56 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Linus Walleij, Arnd Bergmann, Bartosz Golaszewski,
	Geert Uytterhoeven, Christophe Leroy, Michael Ellerman,
	Devarsh Thakkar, Stefan Schmidt, Miquel Raynal, linux-gpio,
	linux-doc, linux-kernel, linux-doc-tw-discuss, linux-arm-kernel,
	linux-omap, linux-samsung-soc, linux-m68k, linuxppc-dev,
	linux-sh, linux-acpi, linux-input, linux-media, linux-wpan,
	netdev, linux-wireless, brcm80211-dev-list.pdl,
	SHA-cyfmac-dev-list, linux-arch, devicetree, Bartosz Golaszewski

On Tue, Feb 07, 2023 at 01:32:01PM -0800, Dmitry Torokhov wrote:
> On Tue, Feb 07, 2023 at 04:29:44PM +0200, Andy Shevchenko wrote:
> > @@ -1010,14 +1009,21 @@ static int ads7846_setup_pendown(struct spi_device *spi,
> >  		}
> >  
> >  		ts->gpio_pendown = pdata->gpio_pendown;
> > -
> > -		if (pdata->gpio_pendown_debounce)
> > -			gpio_set_debounce(pdata->gpio_pendown,
> > -					  pdata->gpio_pendown_debounce);
> 
> Can we please change only this to:
> 
> 			gpiod_set_debounce(gpio_to_desc(pdata->gpio_pendown),
> 					   pdata->gpio_pendown_debounce);
> 
> and not change anything else (i.e. drop the changes below)?

Probably. I can try rollback this.

> >  	} else {
> > -		dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
> > -		return -EINVAL;
> > +		struct gpio_desc *desc;
> > +
> > +		desc = devm_gpiod_get(&spi->dev, "pendown", GPIOD_IN);
> > +		if (IS_ERR(desc)) {
> > +			dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
> > +			return PTR_ERR(desc);
> > +		}
> > +		gpiod_set_consumer_name(desc, "ads7846_pendown");
> > +
> > +		ts->gpio_pendown = desc_to_gpio(desc);
> >  	}
> > +	if (pdata->gpio_pendown_debounce)
> > +		gpiod_set_debounce(gpio_to_desc(ts->gpio_pendown),
> > +				   pdata->gpio_pendown_debounce);
> >  
> >  	return 0;

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 04/12] gpiolib: remove gpio_set_debounce
@ 2023-02-07 22:56       ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 22:56 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Devarsh Thakkar, linux-sh, Linus Walleij, Miquel Raynal,
	Stefan Schmidt, linux-arch, linux-samsung-soc,
	Bartosz Golaszewski, Bartosz Golaszewski, linux-doc, linux-acpi,
	SHA-cyfmac-dev-list, Geert Uytterhoeven, linux-input,
	linux-media, devicetree, Arnd Bergmann, linux-gpio, linux-m68k,
	linux-omap, linux-arm-kernel, brcm80211-dev-list.pdl, linux-wpan,
	linux-doc-tw-discuss, linux-wireless, linux-kernel, netdev,
	linuxppc-dev

On Tue, Feb 07, 2023 at 01:32:01PM -0800, Dmitry Torokhov wrote:
> On Tue, Feb 07, 2023 at 04:29:44PM +0200, Andy Shevchenko wrote:
> > @@ -1010,14 +1009,21 @@ static int ads7846_setup_pendown(struct spi_device *spi,
> >  		}
> >  
> >  		ts->gpio_pendown = pdata->gpio_pendown;
> > -
> > -		if (pdata->gpio_pendown_debounce)
> > -			gpio_set_debounce(pdata->gpio_pendown,
> > -					  pdata->gpio_pendown_debounce);
> 
> Can we please change only this to:
> 
> 			gpiod_set_debounce(gpio_to_desc(pdata->gpio_pendown),
> 					   pdata->gpio_pendown_debounce);
> 
> and not change anything else (i.e. drop the changes below)?

Probably. I can try rollback this.

> >  	} else {
> > -		dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
> > -		return -EINVAL;
> > +		struct gpio_desc *desc;
> > +
> > +		desc = devm_gpiod_get(&spi->dev, "pendown", GPIOD_IN);
> > +		if (IS_ERR(desc)) {
> > +			dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
> > +			return PTR_ERR(desc);
> > +		}
> > +		gpiod_set_consumer_name(desc, "ads7846_pendown");
> > +
> > +		ts->gpio_pendown = desc_to_gpio(desc);
> >  	}
> > +	if (pdata->gpio_pendown_debounce)
> > +		gpiod_set_debounce(gpio_to_desc(ts->gpio_pendown),
> > +				   pdata->gpio_pendown_debounce);
> >  
> >  	return 0;

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 04/12] gpiolib: remove gpio_set_debounce
@ 2023-02-07 22:56       ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-07 22:56 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Linus Walleij, Arnd Bergmann, Bartosz Golaszewski,
	Geert Uytterhoeven, Christophe Leroy, Michael Ellerman,
	Devarsh Thakkar, Stefan Schmidt, Miquel Raynal, linux-gpio,
	linux-doc, linux-kernel, linux-doc-tw-discuss, linux-arm-kernel,
	linux-omap, linux-samsung-soc, linux-m68k, linuxppc-dev,
	linux-sh, linux-acpi, linux-input, linux-media, linux-wpan,
	netdev, linux-wireless, brcm80211-dev-list.pdl,
	SHA-cyfmac-dev-list, linux-arch, devicetree, Bartosz Golaszewski

On Tue, Feb 07, 2023 at 01:32:01PM -0800, Dmitry Torokhov wrote:
> On Tue, Feb 07, 2023 at 04:29:44PM +0200, Andy Shevchenko wrote:
> > @@ -1010,14 +1009,21 @@ static int ads7846_setup_pendown(struct spi_device *spi,
> >  		}
> >  
> >  		ts->gpio_pendown = pdata->gpio_pendown;
> > -
> > -		if (pdata->gpio_pendown_debounce)
> > -			gpio_set_debounce(pdata->gpio_pendown,
> > -					  pdata->gpio_pendown_debounce);
> 
> Can we please change only this to:
> 
> 			gpiod_set_debounce(gpio_to_desc(pdata->gpio_pendown),
> 					   pdata->gpio_pendown_debounce);
> 
> and not change anything else (i.e. drop the changes below)?

Probably. I can try rollback this.

> >  	} else {
> > -		dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
> > -		return -EINVAL;
> > +		struct gpio_desc *desc;
> > +
> > +		desc = devm_gpiod_get(&spi->dev, "pendown", GPIOD_IN);
> > +		if (IS_ERR(desc)) {
> > +			dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
> > +			return PTR_ERR(desc);
> > +		}
> > +		gpiod_set_consumer_name(desc, "ads7846_pendown");
> > +
> > +		ts->gpio_pendown = desc_to_gpio(desc);
> >  	}
> > +	if (pdata->gpio_pendown_debounce)
> > +		gpiod_set_debounce(gpio_to_desc(ts->gpio_pendown),
> > +				   pdata->gpio_pendown_debounce);
> >  
> >  	return 0;

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
  2023-02-07 14:29   ` Andy Shevchenko
                     ` (2 preceding siblings ...)
  (?)
@ 2023-02-07 23:05   ` kernel test robot
  -1 siblings, 0 replies; 53+ messages in thread
From: kernel test robot @ 2023-02-07 23:05 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: oe-kbuild-all

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on brgl/gpio/for-next]
[cannot apply to powerpc/next powerpc/fixes soc/for-next linus/master v6.2-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/gpiolib-remove-empty-asm-gpio-h-files/20230207-223652
base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link:    https://lore.kernel.org/r/20230207142952.51844-7-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20230208/202302080617.x8qGSBNL-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/c34b5f7d305e096c35a9b2587084ecde7ee165fb
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/gpiolib-remove-empty-asm-gpio-h-files/20230207-223652
        git checkout c34b5f7d305e096c35a9b2587084ecde7ee165fb
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/hte/hte-tegra194-test.c:96:34: error: array type has incomplete element type 'struct of_device_id'
      96 | static const struct of_device_id tegra_hte_test_of_match[] = {
         |                                  ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/hte/hte-tegra194-test.c:96:34: warning: 'tegra_hte_test_of_match' defined but not used [-Wunused-variable]


vim +96 drivers/hte/hte-tegra194-test.c

9a75a7cd03c957 Dipen Patel 2022-04-22   95  
9a75a7cd03c957 Dipen Patel 2022-04-22  @96  static const struct of_device_id tegra_hte_test_of_match[] = {
9a75a7cd03c957 Dipen Patel 2022-04-22   97  	{ .compatible = "nvidia,tegra194-hte-test"},
9a75a7cd03c957 Dipen Patel 2022-04-22   98  	{ }
9a75a7cd03c957 Dipen Patel 2022-04-22   99  };
9a75a7cd03c957 Dipen Patel 2022-04-22  100  MODULE_DEVICE_TABLE(of, tegra_hte_test_of_match);
9a75a7cd03c957 Dipen Patel 2022-04-22  101  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

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

* Re: [PATCH v3 08/12] gpio: aggregator: Add missing header(s)
  2023-02-07 14:29   ` Andy Shevchenko
@ 2023-02-08 10:08     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 53+ messages in thread
From: Geert Uytterhoeven @ 2023-02-08 10:08 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, Arnd Bergmann, Bartosz Golaszewski, Tony Lindgren,
	Thomas Gleixner, Krzysztof Kozlowski, Christophe Leroy,
	Michael Ellerman, Devarsh Thakkar, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree, Bartosz Golaszewski, Jonathan Corbet,
	Alex Shi, Yanteng Si, Hu Haowen, Russell King, Aaro Koskinen,
	Janusz Krzysztofik, Andrew Lunn, Sebastian Hesselbarth,
	Gregory Clement, Alim Akhtar, Nicholas Piggin, Yoshinori Sato,
	Rich Felker, Mun Yew Tham, Keerthy, Mika Westerberg,
	Mauro Carvalho Chehab, Alexander Aring, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Arend van Spriel,
	Franky Lin, Hante Meuleman, Kalle Valo, Qiang Zhao, Li Yang,
	Lee Jones, Rob Herring, Frank Rowand

Hi Andy,

Thanks for your patch!

On Tue, Feb 7, 2023 at 3:29 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> Do not imply that some of the generic headers may be always included.
> Instead, include explicitly what we are direct user of.

That applies only to the addition of #include <linux/slab.h>...
Please also describe the other changes.

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/gpio/gpio-aggregator.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c
> index 6d17d262ad91..20a686f12df7 100644
> --- a/drivers/gpio/gpio-aggregator.c
> +++ b/drivers/gpio/gpio-aggregator.c
> @@ -10,19 +10,20 @@
>  #include <linux/bitmap.h>
>  #include <linux/bitops.h>
>  #include <linux/ctype.h>
> -#include <linux/gpio.h>
> -#include <linux/gpio/consumer.h>
> -#include <linux/gpio/driver.h>
> -#include <linux/gpio/machine.h>
>  #include <linux/idr.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/overflow.h>
>  #include <linux/platform_device.h>
> +#include <linux/slab.h>
>  #include <linux/spinlock.h>
>  #include <linux/string.h>
>
> +#include <linux/gpio/consumer.h>
> +#include <linux/gpio/driver.h>
> +#include <linux/gpio/machine.h>
> +
>  #define AGGREGATOR_MAX_GPIOS 512

For the actual changes:
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v3 08/12] gpio: aggregator: Add missing header(s)
@ 2023-02-08 10:08     ` Geert Uytterhoeven
  0 siblings, 0 replies; 53+ messages in thread
From: Geert Uytterhoeven @ 2023-02-08 10:08 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andrew Lunn, Alexander Aring, Rich Felker, Devarsh Thakkar,
	linux-doc, Tony Lindgren, Linus Walleij, Eric Dumazet, Lee Jones,
	Alim Akhtar, Miquel Raynal, Li Yang, Frank Rowand,
	Stefan Schmidt, Qiang Zhao, linux-arch, Jonathan Corbet,
	linux-samsung-soc, Yoshinori Sato, Bartosz Golaszewski,
	Bartosz Golaszewski, linux-sh, Janusz Krzysztofik, Russell King,
	linux-acpi, SHA-cyfmac-dev-list, Alex Shi, linux-input,
	Jaku b Kicinski, Paolo Abeni, Kalle Valo, linux-media,
	devicetree, Arnd Bergmann, Mauro Carvalho Chehab,
	Arend van Spriel, Nicholas Piggin, Hante Meuleman, linux-gpio,
	linux-m68k, Yanteng Si, Thomas Gleixner, linux-omap,
	Mika Westerberg, linux-arm-kernel, Franky Lin,
	brcm80211-dev-list.pdl, Keerthy, Mun Yew Tham, Hu Haowen,
	linux-wpan, linux-doc-tw-discuss, Dmitry Torokhov,
	linux-wireless, linux-kernel, David S. Miller,
	Krzysz tof Kozlowski, Rob Herring, netdev, Aaro Koskinen,
	Sebastian Hesselbarth, linuxppc-dev, Gregory Clement

Hi Andy,

Thanks for your patch!

On Tue, Feb 7, 2023 at 3:29 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> Do not imply that some of the generic headers may be always included.
> Instead, include explicitly what we are direct user of.

That applies only to the addition of #include <linux/slab.h>...
Please also describe the other changes.

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/gpio/gpio-aggregator.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c
> index 6d17d262ad91..20a686f12df7 100644
> --- a/drivers/gpio/gpio-aggregator.c
> +++ b/drivers/gpio/gpio-aggregator.c
> @@ -10,19 +10,20 @@
>  #include <linux/bitmap.h>
>  #include <linux/bitops.h>
>  #include <linux/ctype.h>
> -#include <linux/gpio.h>
> -#include <linux/gpio/consumer.h>
> -#include <linux/gpio/driver.h>
> -#include <linux/gpio/machine.h>
>  #include <linux/idr.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/overflow.h>
>  #include <linux/platform_device.h>
> +#include <linux/slab.h>
>  #include <linux/spinlock.h>
>  #include <linux/string.h>
>
> +#include <linux/gpio/consumer.h>
> +#include <linux/gpio/driver.h>
> +#include <linux/gpio/machine.h>
> +
>  #define AGGREGATOR_MAX_GPIOS 512

For the actual changes:
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
  2023-02-07 22:55       ` Andy Shevchenko
  (?)
@ 2023-02-08 14:51         ` Andy Shevchenko
  -1 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-08 14:51 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Arnd Bergmann, Bartosz Golaszewski, Geert Uytterhoeven,
	Christophe Leroy, Michael Ellerman, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree, Bartosz Golaszewski

On Wed, Feb 08, 2023 at 12:55:06AM +0200, Andy Shevchenko wrote:
> On Tue, Feb 07, 2023 at 03:55:23PM +0100, Linus Walleij wrote:
> > On Tue, Feb 7, 2023 at 3:29 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > 
> > > From: Arnd Bergmann <arnd@arndb.de>
> > >
> > > Almost all gpio drivers include linux/gpio/driver.h, and other
> > > files should not rely on includes from this header.
> > >
> > > Remove the indirect include from here and include the correct
> > > headers directly from where they are used.
> 
> ...
> 
> > Make sure you push this to the kernel.org build servers (zeroday builds),
> 
> Of course, that is the purpose of publishing this before the release (so we
> will have some TODO list that eventually this can be applied for v6.4-rc1).
> 
> > I think this patch needs to hit some more files, in my tests with a similar
> > patch at least these:
> 
> Right. I forgot to also incorporate your stuff into this series.
> Do you have anything that I can take as is?

I'm going to incorporate the following:

	gpio: Make the legacy <linux/gpio.h> consumer-only
	ARM: s3c24xx: Use the right include
	ARM: orion/gpio: Use the right include
	hte: tegra-194: Use proper includes
	pcmcia: pxa2xx_viper: Include dependency


-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
@ 2023-02-08 14:51         ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-08 14:51 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-sh, Miquel Raynal, Stefan Schmidt, linux-arch,
	linux-samsung-soc, Bartosz Golaszewski, Bartosz Golaszewski,
	linux-doc, linux-acpi, SHA-cyfmac-dev-list, Geert Uytterhoeven,
	linux-input, linux-media, devicetree, Arnd Bergmann, linux-gpio,
	linux-m68k, linux-omap, linux-arm-kernel, brcm80211-dev-list.pdl,
	linuxppc-dev, linux-doc-tw-discuss, Dmitry Torokhov,
	linux-wireless, linux-kernel, netdev, linux-wpan

On Wed, Feb 08, 2023 at 12:55:06AM +0200, Andy Shevchenko wrote:
> On Tue, Feb 07, 2023 at 03:55:23PM +0100, Linus Walleij wrote:
> > On Tue, Feb 7, 2023 at 3:29 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > 
> > > From: Arnd Bergmann <arnd@arndb.de>
> > >
> > > Almost all gpio drivers include linux/gpio/driver.h, and other
> > > files should not rely on includes from this header.
> > >
> > > Remove the indirect include from here and include the correct
> > > headers directly from where they are used.
> 
> ...
> 
> > Make sure you push this to the kernel.org build servers (zeroday builds),
> 
> Of course, that is the purpose of publishing this before the release (so we
> will have some TODO list that eventually this can be applied for v6.4-rc1).
> 
> > I think this patch needs to hit some more files, in my tests with a similar
> > patch at least these:
> 
> Right. I forgot to also incorporate your stuff into this series.
> Do you have anything that I can take as is?

I'm going to incorporate the following:

	gpio: Make the legacy <linux/gpio.h> consumer-only
	ARM: s3c24xx: Use the right include
	ARM: orion/gpio: Use the right include
	hte: tegra-194: Use proper includes
	pcmcia: pxa2xx_viper: Include dependency


-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
@ 2023-02-08 14:51         ` Andy Shevchenko
  0 siblings, 0 replies; 53+ messages in thread
From: Andy Shevchenko @ 2023-02-08 14:51 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Arnd Bergmann, Bartosz Golaszewski, Geert Uytterhoeven,
	Christophe Leroy, Michael Ellerman, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree, Bartosz Golaszewski

On Wed, Feb 08, 2023 at 12:55:06AM +0200, Andy Shevchenko wrote:
> On Tue, Feb 07, 2023 at 03:55:23PM +0100, Linus Walleij wrote:
> > On Tue, Feb 7, 2023 at 3:29 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > 
> > > From: Arnd Bergmann <arnd@arndb.de>
> > >
> > > Almost all gpio drivers include linux/gpio/driver.h, and other
> > > files should not rely on includes from this header.
> > >
> > > Remove the indirect include from here and include the correct
> > > headers directly from where they are used.
> 
> ...
> 
> > Make sure you push this to the kernel.org build servers (zeroday builds),
> 
> Of course, that is the purpose of publishing this before the release (so we
> will have some TODO list that eventually this can be applied for v6.4-rc1).
> 
> > I think this patch needs to hit some more files, in my tests with a similar
> > patch at least these:
> 
> Right. I forgot to also incorporate your stuff into this series.
> Do you have anything that I can take as is?

I'm going to incorporate the following:

	gpio: Make the legacy <linux/gpio.h> consumer-only
	ARM: s3c24xx: Use the right include
	ARM: orion/gpio: Use the right include
	hte: tegra-194: Use proper includes
	pcmcia: pxa2xx_viper: Include dependency


-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
  2023-02-08 14:51         ` Andy Shevchenko
  (?)
@ 2023-02-08 14:55           ` Linus Walleij
  -1 siblings, 0 replies; 53+ messages in thread
From: Linus Walleij @ 2023-02-08 14:55 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Arnd Bergmann, Bartosz Golaszewski, Geert Uytterhoeven,
	Christophe Leroy, Michael Ellerman, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree, Bartosz Golaszewski

On Wed, Feb 8, 2023 at 3:51 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Wed, Feb 08, 2023 at 12:55:06AM +0200, Andy Shevchenko wrote:
> > On Tue, Feb 07, 2023 at 03:55:23PM +0100, Linus Walleij wrote:
> > > On Tue, Feb 7, 2023 at 3:29 PM Andy Shevchenko
> > > <andriy.shevchenko@linux.intel.com> wrote:
> > >
> > > > From: Arnd Bergmann <arnd@arndb.de>
> > > >
> > > > Almost all gpio drivers include linux/gpio/driver.h, and other
> > > > files should not rely on includes from this header.
> > > >
> > > > Remove the indirect include from here and include the correct
> > > > headers directly from where they are used.
> >
> > ...
> >
> > > Make sure you push this to the kernel.org build servers (zeroday builds),
> >
> > Of course, that is the purpose of publishing this before the release (so we
> > will have some TODO list that eventually this can be applied for v6.4-rc1).
> >
> > > I think this patch needs to hit some more files, in my tests with a similar
> > > patch at least these:
> >
> > Right. I forgot to also incorporate your stuff into this series.
> > Do you have anything that I can take as is?
>
> I'm going to incorporate the following:
>
>         gpio: Make the legacy <linux/gpio.h> consumer-only
>         ARM: s3c24xx: Use the right include
>         ARM: orion/gpio: Use the right include
>         hte: tegra-194: Use proper includes
>         pcmcia: pxa2xx_viper: Include dependency

Excellent, thanks. I don't care about being credited, just want things
to go smooth so you run into less snags.

Yours,
Linus Walleij

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

* Re: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
@ 2023-02-08 14:55           ` Linus Walleij
  0 siblings, 0 replies; 53+ messages in thread
From: Linus Walleij @ 2023-02-08 14:55 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-sh, Miquel Raynal, Stefan Schmidt, linux-arch,
	linux-samsung-soc, Bartosz Golaszewski, Bartosz Golaszewski,
	linux-doc, linux-acpi, SHA-cyfmac-dev-list, Geert Uytterhoeven,
	linux-input, linux-media, devicetree, Arnd Bergmann, linux-gpio,
	linux-m68k, linux-omap, linux-arm-kernel, brcm80211-dev-list.pdl,
	linuxppc-dev, linux-doc-tw-discuss, Dmitry Torokhov,
	linux-wireless, linux-kernel, netdev, linux-wpan

On Wed, Feb 8, 2023 at 3:51 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Wed, Feb 08, 2023 at 12:55:06AM +0200, Andy Shevchenko wrote:
> > On Tue, Feb 07, 2023 at 03:55:23PM +0100, Linus Walleij wrote:
> > > On Tue, Feb 7, 2023 at 3:29 PM Andy Shevchenko
> > > <andriy.shevchenko@linux.intel.com> wrote:
> > >
> > > > From: Arnd Bergmann <arnd@arndb.de>
> > > >
> > > > Almost all gpio drivers include linux/gpio/driver.h, and other
> > > > files should not rely on includes from this header.
> > > >
> > > > Remove the indirect include from here and include the correct
> > > > headers directly from where they are used.
> >
> > ...
> >
> > > Make sure you push this to the kernel.org build servers (zeroday builds),
> >
> > Of course, that is the purpose of publishing this before the release (so we
> > will have some TODO list that eventually this can be applied for v6.4-rc1).
> >
> > > I think this patch needs to hit some more files, in my tests with a similar
> > > patch at least these:
> >
> > Right. I forgot to also incorporate your stuff into this series.
> > Do you have anything that I can take as is?
>
> I'm going to incorporate the following:
>
>         gpio: Make the legacy <linux/gpio.h> consumer-only
>         ARM: s3c24xx: Use the right include
>         ARM: orion/gpio: Use the right include
>         hte: tegra-194: Use proper includes
>         pcmcia: pxa2xx_viper: Include dependency

Excellent, thanks. I don't care about being credited, just want things
to go smooth so you run into less snags.

Yours,
Linus Walleij

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

* Re: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h
@ 2023-02-08 14:55           ` Linus Walleij
  0 siblings, 0 replies; 53+ messages in thread
From: Linus Walleij @ 2023-02-08 14:55 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Arnd Bergmann, Bartosz Golaszewski, Geert Uytterhoeven,
	Christophe Leroy, Michael Ellerman, Dmitry Torokhov,
	Stefan Schmidt, Miquel Raynal, linux-gpio, linux-doc,
	linux-kernel, linux-doc-tw-discuss, linux-arm-kernel, linux-omap,
	linux-samsung-soc, linux-m68k, linuxppc-dev, linux-sh,
	linux-acpi, linux-input, linux-media, linux-wpan, netdev,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	linux-arch, devicetree, Bartosz Golaszewski

On Wed, Feb 8, 2023 at 3:51 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Wed, Feb 08, 2023 at 12:55:06AM +0200, Andy Shevchenko wrote:
> > On Tue, Feb 07, 2023 at 03:55:23PM +0100, Linus Walleij wrote:
> > > On Tue, Feb 7, 2023 at 3:29 PM Andy Shevchenko
> > > <andriy.shevchenko@linux.intel.com> wrote:
> > >
> > > > From: Arnd Bergmann <arnd@arndb.de>
> > > >
> > > > Almost all gpio drivers include linux/gpio/driver.h, and other
> > > > files should not rely on includes from this header.
> > > >
> > > > Remove the indirect include from here and include the correct
> > > > headers directly from where they are used.
> >
> > ...
> >
> > > Make sure you push this to the kernel.org build servers (zeroday builds),
> >
> > Of course, that is the purpose of publishing this before the release (so we
> > will have some TODO list that eventually this can be applied for v6.4-rc1).
> >
> > > I think this patch needs to hit some more files, in my tests with a similar
> > > patch at least these:
> >
> > Right. I forgot to also incorporate your stuff into this series.
> > Do you have anything that I can take as is?
>
> I'm going to incorporate the following:
>
>         gpio: Make the legacy <linux/gpio.h> consumer-only
>         ARM: s3c24xx: Use the right include
>         ARM: orion/gpio: Use the right include
>         hte: tegra-194: Use proper includes
>         pcmcia: pxa2xx_viper: Include dependency

Excellent, thanks. I don't care about being credited, just want things
to go smooth so you run into less snags.

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2023-02-08 14:56 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07 14:29 [PATCH v3 00/12] gpiolib cleanups Andy Shevchenko
2023-02-07 14:29 ` Andy Shevchenko
2023-02-07 14:29 ` [PATCH v3 01/12] gpiolib: remove empty asm/gpio.h files Andy Shevchenko
2023-02-07 14:29   ` Andy Shevchenko
2023-02-07 20:53   ` Vincenzo Palazzo
2023-02-07 20:53     ` Vincenzo Palazzo
2023-02-07 14:29 ` [PATCH v3 02/12] gpiolib: coldfire: remove custom asm/gpio.h Andy Shevchenko
2023-02-07 14:29   ` Andy Shevchenko
2023-02-07 14:29 ` [PATCH v3 03/12] gpiolib: remove asm-generic/gpio.h Andy Shevchenko
2023-02-07 14:29   ` Andy Shevchenko
2023-02-07 14:29 ` [PATCH v3 04/12] gpiolib: remove gpio_set_debounce Andy Shevchenko
2023-02-07 14:29   ` Andy Shevchenko
2023-02-07 21:32   ` Dmitry Torokhov
2023-02-07 21:32     ` Dmitry Torokhov
2023-02-07 22:56     ` Andy Shevchenko
2023-02-07 22:56       ` Andy Shevchenko
2023-02-07 22:56       ` Andy Shevchenko
2023-02-07 14:29 ` [PATCH v3 05/12] gpiolib: remove legacy gpio_export Andy Shevchenko
2023-02-07 14:29   ` Andy Shevchenko
2023-02-07 14:29 ` [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h Andy Shevchenko
2023-02-07 14:29   ` Andy Shevchenko
2023-02-07 14:55   ` Linus Walleij
2023-02-07 14:55     ` Linus Walleij
2023-02-07 22:55     ` Andy Shevchenko
2023-02-07 22:55       ` Andy Shevchenko
2023-02-07 22:55       ` Andy Shevchenko
2023-02-08 14:51       ` Andy Shevchenko
2023-02-08 14:51         ` Andy Shevchenko
2023-02-08 14:51         ` Andy Shevchenko
2023-02-08 14:55         ` Linus Walleij
2023-02-08 14:55           ` Linus Walleij
2023-02-08 14:55           ` Linus Walleij
2023-02-07 18:43   ` Lee Jones
2023-02-07 18:43     ` Lee Jones
2023-02-07 23:05   ` kernel test robot
2023-02-07 14:29 ` [PATCH v3 07/12] gpiolib: split of_mm_gpio_chip out of linux/of_gpio.h Andy Shevchenko
2023-02-07 14:29   ` Andy Shevchenko
2023-02-07 14:29 ` [PATCH v3 08/12] gpio: aggregator: Add missing header(s) Andy Shevchenko
2023-02-07 14:29   ` Andy Shevchenko
2023-02-08 10:08   ` Geert Uytterhoeven
2023-02-08 10:08     ` Geert Uytterhoeven
2023-02-07 14:29 ` [PATCH v3 09/12] gpiolib: Drop unused forward declaration from driver.h Andy Shevchenko
2023-02-07 14:29   ` Andy Shevchenko
2023-02-07 14:29 ` [PATCH v3 10/12] gpiolib: Deduplicate forward declarations in consumer.h Andy Shevchenko
2023-02-07 14:29   ` Andy Shevchenko
2023-02-07 14:29 ` [PATCH v3 11/12] gpiolib: Group " Andy Shevchenko
2023-02-07 14:29   ` Andy Shevchenko
2023-02-07 14:29 ` [PATCH v3 12/12] gpiolib: Clean up headers Andy Shevchenko
2023-02-07 14:29   ` Andy Shevchenko
2023-02-07 17:46   ` kernel test robot
2023-02-07 20:31   ` kernel test robot
2023-02-07 20:32   ` kernel test robot
2023-02-07 20:52   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.