Linux LED subsystem development
 help / color / mirror / Atom feed
* [PATCH v5 0/6] gpiolib: fence off legacy interfaces
@ 2026-06-29 13:03 Arnd Bergmann
  2026-06-29 13:03 ` [PATCH 1/6] [v5] sh: select legacy gpiolib interface Arnd Bergmann
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Arnd Bergmann @ 2026-06-29 13:03 UTC (permalink / raw)
  To: linux-gpio
  Cc: Arnd Bergmann, John Paul Adrian Glaubitz, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov, Lee Jones,
	Pavel Machek, linux-sh, linux-kernel, linux-input, linux-leds

From: Arnd Bergmann <arnd@arndb.de>

This is the remainder of the series previously posted as v2
in [1]. I've changed the version to v5 for all patches to
not confuse b4 too much, but the patches are mostly unchanged.

The patch "Input: soc_button_array - select CONFIG_GPIOLIB_LEGACY"
was not part of the series last time, but the build bots reported
this as a regression since I had dropped that since v1.

I hope that all that remains now can just get merged through the
gpio tree. The gpio-keys patch needs a bit coordination with
another patch addressing the same issue that is already in
flight, so I expect that I'll rebase my series once more when
that is in a stable branch, but the state I have here should
just work as-is on top of v7.2-rc1.

     Arnd

[1] https://lore.kernel.org/all/20260520183815.2510387-1-arnd@kernel.org/

Arnd Bergmann (6):
  [v5] sh: select legacy gpiolib interface
  [v5] x86/olpc: select GPIOLIB_LEGACY
  [v5] Input: soc_button_array - select CONFIG_GPIOLIB_LEGACY
  [v5] Input: gpio-keys: make legacy gpiolib optional
  [v5] leds: gpio: make legacy gpiolib interface optional
  [v5] gpiolib: turn off legacy interface by default

 arch/sh/Kconfig                           |  1 +
 arch/sh/boards/Kconfig                    |  8 ++++
 arch/sh/boards/mach-highlander/Kconfig    |  1 +
 arch/sh/boards/mach-rsk/Kconfig           |  3 ++
 arch/x86/Kconfig                          |  1 +
 arch/x86/platform/olpc/olpc-xo1-sci.c     |  2 +-
 drivers/gpio/Kconfig                      |  9 +++-
 drivers/input/keyboard/gpio_keys.c        |  9 ++--
 drivers/input/keyboard/gpio_keys_polled.c |  4 +-
 drivers/input/misc/Kconfig                |  3 ++
 drivers/input/misc/soc_button_array.c     |  2 +-
 drivers/leds/leds-gpio.c                  | 53 +++++++++++++++--------
 drivers/mfd/rohm-bd71828.c                |  1 -
 drivers/mfd/rohm-bd718x7.c                |  1 -
 include/linux/gpio_keys.h                 |  2 +
 include/linux/leds.h                      |  2 +
 sound/pci/Kconfig                         |  1 +
 sound/pci/cs5535audio/cs5535audio_olpc.c  |  2 +-
 18 files changed, 76 insertions(+), 29 deletions(-)

-- 
2.39.5

Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Thomas Gleixner <tglx@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Linus Walleij <linusw@kernel.org>
Cc: Bartosz Golaszewski <brgl@kernel.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Lee Jones <lee@kernel.org>
Cc: Pavel Machek <pavel@kernel.org>
Cc: linux-sh@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-gpio@vger.kernel.org
Cc: linux-input@vger.kernel.org
Cc: linux-leds@vger.kernel.org

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

* [PATCH 1/6] [v5] sh: select legacy gpiolib interface
  2026-06-29 13:03 [PATCH v5 0/6] gpiolib: fence off legacy interfaces Arnd Bergmann
@ 2026-06-29 13:03 ` Arnd Bergmann
  2026-06-29 13:12   ` sashiko-bot
  2026-06-29 13:03 ` [PATCH 2/6] [v5] x86/olpc: select GPIOLIB_LEGACY Arnd Bergmann
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: Arnd Bergmann @ 2026-06-29 13:03 UTC (permalink / raw)
  To: linux-gpio
  Cc: Arnd Bergmann, John Paul Adrian Glaubitz, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov, Lee Jones,
	Pavel Machek, linux-sh, linux-kernel, linux-input, linux-leds

From: Arnd Bergmann <arnd@arndb.de>

Many board files on sh reference the legacy gpiolib interfaces that
are becoming optional. To ensure the boards can keep building, select
CONFIG_GPIOLIB_LEGACY on each of the boards that have one of the
hardcoded calls.

Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2..v5: no changes. The patch did not make it into v7.2-rc1, so
        I'm keeping it with the rest of the series
---
 arch/sh/Kconfig                        | 1 +
 arch/sh/boards/Kconfig                 | 8 ++++++++
 arch/sh/boards/mach-highlander/Kconfig | 1 +
 arch/sh/boards/mach-rsk/Kconfig        | 3 +++
 4 files changed, 13 insertions(+)

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index d5795067befa..d60f1d5a94c0 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -462,6 +462,7 @@ config CPU_SUBTYPE_SHX3
 	select CPU_SHX3
 	select GENERIC_CLOCKEVENTS_BROADCAST if SMP
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	select PINCTRL
 
 # SH4AL-DSP Processor Support
diff --git a/arch/sh/boards/Kconfig b/arch/sh/boards/Kconfig
index 1af93be61b1f..d89b74177233 100644
--- a/arch/sh/boards/Kconfig
+++ b/arch/sh/boards/Kconfig
@@ -80,6 +80,7 @@ config SH_7724_SOLUTION_ENGINE
 	select SOLUTION_ENGINE
 	depends on CPU_SUBTYPE_SH7724
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	select REGULATOR_FIXED_VOLTAGE if REGULATOR
 	imply SND_SOC_AK4642 if SND_SIMPLE_CARD
 	help
@@ -199,6 +200,7 @@ config SH_SH7757LCR
 	bool "SH7757LCR"
 	depends on CPU_SUBTYPE_SH7757
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	select REGULATOR_FIXED_VOLTAGE if REGULATOR
 
 config SH_SH7785LCR
@@ -226,6 +228,7 @@ config SH_URQUELL
 	bool "Urquell"
 	depends on CPU_SUBTYPE_SH7786
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	select HAVE_PCI
 	select NO_IOPORT_MAP if !PCI
 
@@ -233,6 +236,7 @@ config SH_MIGOR
 	bool "Migo-R"
 	depends on CPU_SUBTYPE_SH7722
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	select REGULATOR_FIXED_VOLTAGE if REGULATOR
 	help
 	  Select Migo-R if configuring for the SH7722 Migo-R platform
@@ -242,6 +246,7 @@ config SH_AP325RXA
 	bool "AP-325RXA"
 	depends on CPU_SUBTYPE_SH7723
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	select REGULATOR_FIXED_VOLTAGE if REGULATOR
 	help
 	  Renesas "AP-325RXA" support.
@@ -251,6 +256,7 @@ config SH_KFR2R09
 	bool "KFR2R09"
 	depends on CPU_SUBTYPE_SH7724
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	select REGULATOR_FIXED_VOLTAGE if REGULATOR
 	help
 	  "Kit For R2R for 2009" support.
@@ -259,6 +265,7 @@ config SH_ECOVEC
 	bool "EcoVec"
 	depends on CPU_SUBTYPE_SH7724
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	select REGULATOR_FIXED_VOLTAGE if REGULATOR
 	imply SND_SOC_DA7210 if SND_SIMPLE_CARD
 	help
@@ -329,6 +336,7 @@ config SH_MAGIC_PANEL_R2
 	bool "Magic Panel R2"
 	depends on CPU_SUBTYPE_SH7720
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	select REGULATOR_FIXED_VOLTAGE if REGULATOR
 	help
 	  Select Magic Panel R2 if configuring for Magic Panel R2.
diff --git a/arch/sh/boards/mach-highlander/Kconfig b/arch/sh/boards/mach-highlander/Kconfig
index b0abd03cac4e..cd3a553ce30c 100644
--- a/arch/sh/boards/mach-highlander/Kconfig
+++ b/arch/sh/boards/mach-highlander/Kconfig
@@ -20,6 +20,7 @@ config SH_R7785RP
 	bool "R7785RP board support"
 	depends on CPU_SUBTYPE_SH7785
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 
 endchoice
 
diff --git a/arch/sh/boards/mach-rsk/Kconfig b/arch/sh/boards/mach-rsk/Kconfig
index f0299bc4416f..3810937aa5d4 100644
--- a/arch/sh/boards/mach-rsk/Kconfig
+++ b/arch/sh/boards/mach-rsk/Kconfig
@@ -12,16 +12,19 @@ config SH_RSK7201
 config SH_RSK7203
 	bool "RSK7203"
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	depends on CPU_SUBTYPE_SH7203
 
 config SH_RSK7264
 	bool "RSK2+SH7264"
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	depends on CPU_SUBTYPE_SH7264
 
 config SH_RSK7269
 	bool "RSK2+SH7269"
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	depends on CPU_SUBTYPE_SH7269
 
 endchoice
-- 
2.39.5


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

* [PATCH 2/6] [v5] x86/olpc: select GPIOLIB_LEGACY
  2026-06-29 13:03 [PATCH v5 0/6] gpiolib: fence off legacy interfaces Arnd Bergmann
  2026-06-29 13:03 ` [PATCH 1/6] [v5] sh: select legacy gpiolib interface Arnd Bergmann
@ 2026-06-29 13:03 ` Arnd Bergmann
  2026-06-29 13:25   ` sashiko-bot
  2026-06-29 13:03 ` [PATCH 3/6] [v5] Input: soc_button_array - select CONFIG_GPIOLIB_LEGACY Arnd Bergmann
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: Arnd Bergmann @ 2026-06-29 13:03 UTC (permalink / raw)
  To: linux-gpio
  Cc: Arnd Bergmann, John Paul Adrian Glaubitz, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov, Lee Jones,
	Pavel Machek, linux-sh, linux-kernel, linux-input, linux-leds,
	Takashi Iwai, Bartosz Golaszewski

From: Arnd Bergmann <arnd@arndb.de>

The OLPC GPIO controller sets up a fixed number space that is used
by at least two drivers:

arch/x86/platform/olpc/olpc-xo1-sci.c: In function 'setup_ec_sci':
arch/x86/platform/olpc/olpc-xo1-sci.c:358:13: error: implicit declaration of function 'gpio_request' [-Wimplicit-function-declaration]
  358 |         r = gpio_request(OLPC_GPIO_ECSCI, "OLPC-ECSCI");
      |             ^~~~~~~~~~~~
sound/pci/cs5535audio/cs5535audio_olpc.c: In function 'olpc_analog_input':
sound/pci/cs5535audio/cs5535audio_olpc.c:41:9: error: implicit declaration of function 'gpio_set_value'; did you mean 'gpiod_set_value'? [-Wimplicit-function-declaration]
   41 |         gpio_set_value(OLPC_GPIO_MIC_AC, on);

The AMD Geode platform that this is based on is now marked as
'Orphaned' in Kconfig, and it is likely that there are no XO1
users on modern kernels, but so far there is no consensus on
removing it entirely.

Select CONFIG_GPIOLIB_LEGACY for this platform and make sure the
sound driver portion cannot be compiled without this.

Acked-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v3..v5: no changes
    v2: update changelog text
---
 arch/x86/Kconfig                         | 1 +
 arch/x86/platform/olpc/olpc-xo1-sci.c    | 2 +-
 sound/pci/Kconfig                        | 1 +
 sound/pci/cs5535audio/cs5535audio_olpc.c | 2 +-
 4 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index bdad90f210e4..4ad8a7bbd93d 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2976,6 +2976,7 @@ config OLPC
 	bool "One Laptop Per Child support"
 	depends on !X86_PAE
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	select OF
 	select OF_PROMTREE
 	select IRQ_DOMAIN
diff --git a/arch/x86/platform/olpc/olpc-xo1-sci.c b/arch/x86/platform/olpc/olpc-xo1-sci.c
index 30751b42d54e..a5b47960ba32 100644
--- a/arch/x86/platform/olpc/olpc-xo1-sci.c
+++ b/arch/x86/platform/olpc/olpc-xo1-sci.c
@@ -9,7 +9,7 @@
 
 #include <linux/cs5535.h>
 #include <linux/device.h>
-#include <linux/gpio.h>
+#include <linux/gpio/legacy.h>
 #include <linux/input.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index e0996a9d90b0..6366f72b3667 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -300,6 +300,7 @@ config SND_CS5535AUDIO
 	tristate "CS5535/CS5536 Audio"
 	depends on X86_32 || MIPS || COMPILE_TEST
 	depends on HAS_IOPORT
+	depends on GPIOLIB_LEGACY || !OLPC
 	select SND_PCM
 	select SND_AC97_CODEC
 	help
diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c
index 122170a410d9..cfdcc5bf4341 100644
--- a/sound/pci/cs5535audio/cs5535audio_olpc.c
+++ b/sound/pci/cs5535audio/cs5535audio_olpc.c
@@ -9,7 +9,7 @@
 #include <sound/info.h>
 #include <sound/control.h>
 #include <sound/ac97_codec.h>
-#include <linux/gpio.h>
+#include <linux/gpio/legacy.h>
 
 #include <asm/olpc.h>
 #include "cs5535audio.h"
-- 
2.39.5


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

* [PATCH 3/6] [v5] Input: soc_button_array - select CONFIG_GPIOLIB_LEGACY
  2026-06-29 13:03 [PATCH v5 0/6] gpiolib: fence off legacy interfaces Arnd Bergmann
  2026-06-29 13:03 ` [PATCH 1/6] [v5] sh: select legacy gpiolib interface Arnd Bergmann
  2026-06-29 13:03 ` [PATCH 2/6] [v5] x86/olpc: select GPIOLIB_LEGACY Arnd Bergmann
@ 2026-06-29 13:03 ` Arnd Bergmann
  2026-06-29 13:18   ` sashiko-bot
  2026-06-29 13:03 ` [PATCH 4/6] [v5] Input: gpio-keys: make legacy gpiolib optional Arnd Bergmann
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: Arnd Bergmann @ 2026-06-29 13:03 UTC (permalink / raw)
  To: linux-gpio
  Cc: Arnd Bergmann, John Paul Adrian Glaubitz, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov, Lee Jones,
	Pavel Machek, linux-sh, linux-kernel, linux-input, linux-leds

From: Arnd Bergmann <arnd@arndb.de>

This driver converts information from ACPI in x86 based tablets and
laptops into platform_data for the gpio_keys driver, using the obsolete
gpio number based interfaces.

This should really be converted to some other method, but since the
conversion is nontrivial, have this one select GPIOLIB_LEGACY for the
time being.

This enables turning GPIOLIB_LEGACY off by default on most kernel
builds. Since the driver is only used on x86 portables, add a CONFIG_X86
dependency, which means non-x86 allmodconfig builds usuallly build
without the legacy gpio support.

Link: https://lore.kernel.org/all/ah-1z9LhVG0wtfBw@google.com/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v5: This was part of an earlier "x86/platform: select legacy
    gpiolib interfaces where used" patch that covered several
    drivers. This is the only one left as of linux-7.2-rc1
---
 drivers/input/misc/Kconfig            | 3 +++
 drivers/input/misc/soc_button_array.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 1f6c57dba030..9c66e3a67127 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -892,6 +892,9 @@ config INPUT_IDEAPAD_SLIDEBAR
 config INPUT_SOC_BUTTON_ARRAY
 	tristate "Windows-compatible SoC Button Array"
 	depends on KEYBOARD_GPIO && ACPI
+	depends on X86
+	depends on GPIOLIB
+	select GPIOLIB_LEGACY
 	help
 	  Say Y here if you have a SoC-based tablet that originally runs
 	  Windows 8 or a Microsoft Surface Book 2, Pro 5, Laptop 1 or later.
diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index b8cad415c62c..eb11bf2e9436 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -15,7 +15,7 @@
 #include <linux/dmi.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio_keys.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/platform_device.h>
 
 static bool use_low_level_irq;
-- 
2.39.5


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

* [PATCH 4/6] [v5] Input: gpio-keys: make legacy gpiolib optional
  2026-06-29 13:03 [PATCH v5 0/6] gpiolib: fence off legacy interfaces Arnd Bergmann
                   ` (2 preceding siblings ...)
  2026-06-29 13:03 ` [PATCH 3/6] [v5] Input: soc_button_array - select CONFIG_GPIOLIB_LEGACY Arnd Bergmann
@ 2026-06-29 13:03 ` Arnd Bergmann
  2026-06-29 13:32   ` sashiko-bot
  2026-06-29 13:03 ` [PATCH 5/6] [v5] leds: gpio: make legacy gpiolib interface optional Arnd Bergmann
  2026-06-29 13:03 ` [PATCH 6/6] [v5] gpiolib: turn off legacy interface by default Arnd Bergmann
  5 siblings, 1 reply; 18+ messages in thread
From: Arnd Bergmann @ 2026-06-29 13:03 UTC (permalink / raw)
  To: linux-gpio
  Cc: Arnd Bergmann, John Paul Adrian Glaubitz, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov, Lee Jones,
	Pavel Machek, linux-sh, linux-kernel, linux-input, linux-leds

From: Arnd Bergmann <arnd@arndb.de>

Most users of gpio-keys and gpio-keys-polled use modern gpiolib
interfaces, but there are still number of ancient sh, arm32 and x86
machines that have never been converted.

Add an #ifdef block for the parts of the driver that are only used on
those legacy machines.

The two Rohm PMIC drivers use a gpio-keys device without an actual GPIO,
passing an IRQ number instead. In order to keep this working both with
and with CONFIG_GPIOLIB_LEGACY, change the gpio-keys driver to ignore
the gpio number if an IRQ is passed.

Link: https://lore.kernel.org/all/b3c94552-c104-42e3-be15-7e8362e8039e@gmail.com/
Link: https://lore.kernel.org/all/afJXG4_rtaj3l2Dk@google.com/
Link: https://lore.kernel.org/all/ajQ-CtU131FAJ9ES@google.com/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v3..v5: resend
    v2: skip the fake GPIO number passing from mfd

This patch now has a small conflict with the rework of the rohm drivers
to use software nodes. That patch is the one we want, and then
the drivers/mfd changes here can get dropped, but the two need to
get merged in the correct order.
---
 drivers/input/keyboard/gpio_keys.c        | 9 +++++----
 drivers/input/keyboard/gpio_keys_polled.c | 4 +++-
 drivers/mfd/rohm-bd71828.c                | 1 -
 drivers/mfd/rohm-bd718x7.c                | 1 -
 include/linux/gpio_keys.h                 | 2 ++
 5 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index e19617485679..e988657f97cb 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -23,8 +23,8 @@
 #include <linux/input.h>
 #include <linux/gpio_keys.h>
 #include <linux/workqueue.h>
-#include <linux/gpio.h>
 #include <linux/gpio/consumer.h>
+#include <linux/gpio/legacy.h>
 #include <linux/of.h>
 #include <linux/of_irq.h>
 #include <linux/spinlock.h>
@@ -528,7 +528,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 			 */
 			bdata->gpiod = NULL;
 		}
-	} else if (gpio_is_valid(button->gpio)) {
+#ifdef CONFIG_GPIOLIB_LEGACY
+	} else if (!button->irq && gpio_is_valid(button->gpio)) {
 		/*
 		 * Legacy GPIO number, so request the GPIO here and
 		 * convert it to descriptor.
@@ -546,6 +547,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 
 		if (button->active_low ^ gpiod_is_active_low(bdata->gpiod))
 			gpiod_toggle_active_low(bdata->gpiod);
+#endif
 	}
 
 	if (bdata->gpiod) {
@@ -583,8 +585,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 			if (irq < 0) {
 				error = irq;
 				dev_err_probe(dev, error,
-					      "Unable to get irq number for GPIO %d\n",
-					      button->gpio);
+					      "Unable to get irq number for GPIO\n");
 				return error;
 			}
 			bdata->irq = irq;
diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
index e6707d72210e..4e7a366ff05b 100644
--- a/drivers/input/keyboard/gpio_keys_polled.c
+++ b/drivers/input/keyboard/gpio_keys_polled.c
@@ -18,8 +18,8 @@
 #include <linux/input.h>
 #include <linux/ioport.h>
 #include <linux/platform_device.h>
-#include <linux/gpio.h>
 #include <linux/gpio/consumer.h>
+#include <linux/gpio/legacy.h>
 #include <linux/gpio_keys.h>
 #include <linux/property.h>
 
@@ -301,6 +301,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 				return dev_err_probe(dev, PTR_ERR(bdata->gpiod),
 						     "failed to get gpio\n");
 			}
+#ifdef CONFIG_GPIOLIB_LEGACY
 		} else if (gpio_is_valid(button->gpio)) {
 			/*
 			 * Legacy GPIO number so request the GPIO here and
@@ -323,6 +324,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 
 			if (button->active_low ^ gpiod_is_active_low(bdata->gpiod))
 				gpiod_toggle_active_low(bdata->gpiod);
+#endif
 		}
 
 		bdata->last_state = -1;
diff --git a/drivers/mfd/rohm-bd71828.c b/drivers/mfd/rohm-bd71828.c
index a79f354bf5cb..df6dad762ec9 100644
--- a/drivers/mfd/rohm-bd71828.c
+++ b/drivers/mfd/rohm-bd71828.c
@@ -39,7 +39,6 @@
 
 static struct gpio_keys_button button = {
 	.code = KEY_POWER,
-	.gpio = -1,
 	.type = EV_KEY,
 	.wakeup = 1,
 };
diff --git a/drivers/mfd/rohm-bd718x7.c b/drivers/mfd/rohm-bd718x7.c
index ff714fd4f54d..dd774aa8828b 100644
--- a/drivers/mfd/rohm-bd718x7.c
+++ b/drivers/mfd/rohm-bd718x7.c
@@ -20,7 +20,6 @@
 
 static struct gpio_keys_button button = {
 	.code = KEY_POWER,
-	.gpio = -1,
 	.type = EV_KEY,
 };
 
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index 80fa930b04c6..e8d6dc290efb 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -25,7 +25,9 @@ struct device;
  */
 struct gpio_keys_button {
 	unsigned int code;
+#ifdef CONFIG_GPIOLIB_LEGACY
 	int gpio;
+#endif
 	int active_low;
 	const char *desc;
 	unsigned int type;
-- 
2.39.5


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

* [PATCH 5/6] [v5] leds: gpio: make legacy gpiolib interface optional
  2026-06-29 13:03 [PATCH v5 0/6] gpiolib: fence off legacy interfaces Arnd Bergmann
                   ` (3 preceding siblings ...)
  2026-06-29 13:03 ` [PATCH 4/6] [v5] Input: gpio-keys: make legacy gpiolib optional Arnd Bergmann
@ 2026-06-29 13:03 ` Arnd Bergmann
  2026-06-29 13:38   ` sashiko-bot
  2026-06-29 15:09   ` Andy Shevchenko
  2026-06-29 13:03 ` [PATCH 6/6] [v5] gpiolib: turn off legacy interface by default Arnd Bergmann
  5 siblings, 2 replies; 18+ messages in thread
From: Arnd Bergmann @ 2026-06-29 13:03 UTC (permalink / raw)
  To: linux-gpio
  Cc: Arnd Bergmann, John Paul Adrian Glaubitz, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov, Lee Jones,
	Pavel Machek, linux-sh, linux-kernel, linux-input, linux-leds,
	Bartosz Golaszewski, Andy Shevchenko

From: Arnd Bergmann <arnd@arndb.de>

There are still a handful of ancient mips/armv5/sh boards that use the
gpio_led:gpio member to pass an old-style gpio number, but all modern
users have been converted to gpio descriptors.

While the CONFIG_GPIOLIB_LEGACY option that guards devm_gpio_request_one()
and related helpers is currently turned on in all kernel builds,
the plan is to only enable it on the few platforms that actually
pass gpio numbers in any platform_data.

Split out the legacy portion of the platform_data handling into a custom
helper function that is guarded with in #ifdef block, to allow the
the leds-gpio driver to compile cleanly when CONFIG_GPIOLIB_LEGACY
gets turned off. Once the last user is converted, this function can
be removed.

Link: https://lore.kernel.org/all/e9252384-a55c-4a91-9c61-06e05a0b2ce4@app.fastmail.com/
Reviewed-by: Linus Walleij <linusw@kernel.org>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v5: no changes
v4: whitespace changes only
v3: simplify gpio_led_get_gpiod
v2: rework a little bit to keep the legacy code path more separate,
    extend changelog description
---
 drivers/leds/leds-gpio.c | 53 ++++++++++++++++++++++++++--------------
 include/linux/leds.h     |  2 ++
 2 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index a3428b22de3a..740772c2504a 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -9,8 +9,8 @@
 #include <linux/container_of.h>
 #include <linux/device.h>
 #include <linux/err.h>
-#include <linux/gpio.h>
 #include <linux/gpio/consumer.h>
+#include <linux/gpio/legacy.h>
 #include <linux/leds.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
@@ -212,7 +212,6 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,
 					    const struct gpio_led *template)
 {
 	struct gpio_desc *gpiod;
-	int ret;
 
 	/*
 	 * This means the LED does not come from the device tree
@@ -221,18 +220,30 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,
 	 * the GPIO from there.
 	 */
 	gpiod = devm_gpiod_get_index_optional(dev, NULL, idx, GPIOD_OUT_LOW);
-	if (IS_ERR(gpiod))
-		return gpiod;
-	if (gpiod) {
+	if (!IS_ERR(gpiod))
 		gpiod_set_consumer_name(gpiod, template->name);
-		return gpiod;
-	}
 
-	/*
-	 * This is the legacy code path for platform code that
-	 * still uses GPIO numbers. Ultimately we would like to get
-	 * rid of this block completely.
-	 */
+	return gpiod;
+}
+
+#ifdef CONFIG_GPIOLIB_LEGACY
+/*
+ * This is the legacy code path for platform code that still uses
+ * GPIO numbers, mainly MIPS and SuperH board files.
+ * Ultimately we would like to get rid of this block completely.
+ *
+ * ppc44x-warp sets the template->gpiod directly instead of
+ * adding a lookup table or device properties. This is not
+ * much better.
+ */
+static struct gpio_desc *gpio_led_get_legacy_gpiod(struct device *dev, int idx,
+						   const struct gpio_led *template)
+{
+	struct gpio_desc *gpiod;
+	int ret;
+
+	if (template->gpiod)
+		return template->gpiod;
 
 	/* skip leds that aren't available */
 	if (!gpio_is_valid(template->gpio))
@@ -252,6 +263,13 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,
 
 	return gpiod;
 }
+#else
+static struct gpio_desc *gpio_led_get_legacy_gpiod(struct device *dev, int idx,
+						   const struct gpio_led *template)
+{
+	return template->gpiod ?: ERR_PTR(-ENOENT);
+}
+#endif
 
 static int gpio_led_probe(struct platform_device *pdev)
 {
@@ -270,14 +288,13 @@ static int gpio_led_probe(struct platform_device *pdev)
 			const struct gpio_led *template = &pdata->leds[i];
 			struct gpio_led_data *led_dat = &priv->leds[i];
 
-			if (template->gpiod)
-				led_dat->gpiod = template->gpiod;
-			else
+			led_dat->gpiod = gpio_led_get_gpiod(dev, i, template);
+			if (!led_dat->gpiod)
 				led_dat->gpiod =
-					gpio_led_get_gpiod(dev, i, template);
+					 gpio_led_get_legacy_gpiod(dev, i, template);
 			if (IS_ERR(led_dat->gpiod)) {
-				dev_info(dev, "Skipping unavailable LED gpio %d (%s)\n",
-					 template->gpio, template->name);
+				dev_info(dev, "Skipping unavailable LED gpio %s\n",
+					 template->name);
 				continue;
 			}
 
diff --git a/include/linux/leds.h b/include/linux/leds.h
index b16b803cc1ac..e646bffcd8e7 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -676,8 +676,10 @@ typedef int (*gpio_blink_set_t)(struct gpio_desc *desc, int state,
 struct gpio_led {
 	const char *name;
 	const char *default_trigger;
+#ifdef CONFIG_GPIOLIB_LEGACY
 	unsigned 	gpio;
 	unsigned	active_low : 1;
+#endif
 	unsigned	retain_state_suspended : 1;
 	unsigned	panic_indicator : 1;
 	unsigned	default_state : 2;
-- 
2.39.5


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

* [PATCH 6/6] [v5] gpiolib: turn off legacy interface by default
  2026-06-29 13:03 [PATCH v5 0/6] gpiolib: fence off legacy interfaces Arnd Bergmann
                   ` (4 preceding siblings ...)
  2026-06-29 13:03 ` [PATCH 5/6] [v5] leds: gpio: make legacy gpiolib interface optional Arnd Bergmann
@ 2026-06-29 13:03 ` Arnd Bergmann
  2026-06-29 13:46   ` sashiko-bot
  2026-06-29 16:04   ` Geert Uytterhoeven
  5 siblings, 2 replies; 18+ messages in thread
From: Arnd Bergmann @ 2026-06-29 13:03 UTC (permalink / raw)
  To: linux-gpio
  Cc: Arnd Bergmann, John Paul Adrian Glaubitz, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov, Lee Jones,
	Pavel Machek, linux-sh, linux-kernel, linux-input, linux-leds

From: Arnd Bergmann <arnd@arndb.de>

All users of the legacy interface now select CONFIG_GPIOLIB_LEGACY,
so it can be turned off by default and only get built on platforms
that still have one unconverted driver.

Allow turning it on manually for compile testing, in order to keep
the build coverage of the legacy drivers in allmodconfig and
randconfig.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v5: added patch, now that we are getting closer to completing
    the series
---
 drivers/gpio/Kconfig | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 28cf6d2e83c2..f063bdfd111b 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -4,7 +4,14 @@
 #
 
 config GPIOLIB_LEGACY
-	def_bool y
+	bool "Legacy GPIO interfaces" if COMPILE_TEST
+	help
+	  There are a few legacy platforms that use the traditional GPIO
+	  number based interfaces instead of GPIO descriptors.
+	  Say Y here to enable build testing drivers that are specific
+	  to those platforms.
+
+	  If unsure, say N.
 
 config HAVE_SHARED_GPIOS
 	bool
-- 
2.39.5


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

* Re: [PATCH 1/6] [v5] sh: select legacy gpiolib interface
  2026-06-29 13:03 ` [PATCH 1/6] [v5] sh: select legacy gpiolib interface Arnd Bergmann
@ 2026-06-29 13:12   ` sashiko-bot
  0 siblings, 0 replies; 18+ messages in thread
From: sashiko-bot @ 2026-06-29 13:12 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: dmitry.torokhov, linux-leds, lee, linux-input

> From: Arnd Bergmann <arnd@arndb.de>
> 
> Many board files on sh reference the legacy gpiolib interfaces that
> are becoming optional. To ensure the boards can keep building, select
> CONFIG_GPIOLIB_LEGACY on each of the boards that have one of the
> hardcoded calls.
> 
> Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260629130329.1291953-1-arnd@kernel.org?part=1


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

* Re: [PATCH 3/6] [v5] Input: soc_button_array - select CONFIG_GPIOLIB_LEGACY
  2026-06-29 13:03 ` [PATCH 3/6] [v5] Input: soc_button_array - select CONFIG_GPIOLIB_LEGACY Arnd Bergmann
@ 2026-06-29 13:18   ` sashiko-bot
  0 siblings, 0 replies; 18+ messages in thread
From: sashiko-bot @ 2026-06-29 13:18 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-input, dmitry.torokhov, lee, linux-leds

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Duplicate inclusion of `<linux/gpio/consumer.h>`.
--

commit 2bb9f5b4a775c5b3c871a4230ef5de7eb9ac7ae6
Author: Arnd Bergmann <arnd@arndb.de>

Input: soc_button_array - select CONFIG_GPIOLIB_LEGACY

This commit adds dependencies and selects CONFIG_GPIOLIB_LEGACY for the
soc_button_array driver since it uses obsolete gpio interfaces. It also
replaces linux/gpio.h with linux/gpio/consumer.h in the driver source.

Link: https://lore.kernel.org/all/ah-1z9LhVG0wtfBw@google.com/

[ ... ]

> diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
> index b8cad415c62ca..eb11bf2e94362 100644
> --- a/drivers/input/misc/soc_button_array.c
> +++ b/drivers/input/misc/soc_button_array.c
> @@ -15,7 +15,7 @@
>  #include <linux/dmi.h>
>  #include <linux/gpio/consumer.h>
>  #include <linux/gpio_keys.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/consumer.h>

[Severity: Low]
This isn't a bug, but is it intentional to include <linux/gpio/consumer.h>
twice here?

>  #include <linux/platform_device.h>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260629130329.1291953-1-arnd@kernel.org?part=3

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

* Re: [PATCH 2/6] [v5] x86/olpc: select GPIOLIB_LEGACY
  2026-06-29 13:03 ` [PATCH 2/6] [v5] x86/olpc: select GPIOLIB_LEGACY Arnd Bergmann
@ 2026-06-29 13:25   ` sashiko-bot
  2026-06-29 13:40     ` Arnd Bergmann
  0 siblings, 1 reply; 18+ messages in thread
From: sashiko-bot @ 2026-06-29 13:25 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-input, lee, dmitry.torokhov, linux-leds

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The patch introduces `#include <linux/gpio/legacy.h>` but this file does not exist in the tree, causing a fatal compiler error.
--

commit 0da87dc4a65872189dc6e83e56582e1870d842f6
Author: Arnd Bergmann <arnd@arndb.de>

x86/olpc: select GPIOLIB_LEGACY

This commit selects CONFIG_GPIOLIB_LEGACY for the OLPC platform to resolve
implicit declaration warnings for legacy GPIO functions. It also updates
dependencies for the cs5535audio driver to require the legacy GPIO library.

[ ... ]

> diff --git a/arch/x86/platform/olpc/olpc-xo1-sci.c b/arch/x86/platform/olpc/olpc-xo1-sci.c
> index 30751b42d54ef..a5b47960ba32e 100644
> --- a/arch/x86/platform/olpc/olpc-xo1-sci.c
> +++ b/arch/x86/platform/olpc/olpc-xo1-sci.c
> @@ -9,7 +9,7 @@
>  
>  #include <linux/cs5535.h>
>  #include <linux/device.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/legacy.h>

[Severity: Low]
Does this cause a build failure when setup_ec_sci() and other functions in
this file are compiled? It appears include/linux/gpio/legacy.h does not exist
in the tree, and the legacy GPIO APIs might still be declared directly in
include/linux/gpio.h.

[ ... ]

> diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c
> index 122170a410d9e..cfdcc5bf4341e 100644
> --- a/sound/pci/cs5535audio/cs5535audio_olpc.c
> +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c
> @@ -9,7 +9,7 @@
>  #include <sound/info.h>
>  #include <sound/control.h>
>  #include <sound/ac97_codec.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/legacy.h>

[Severity: Low]
Could this missing include file similarly break the compilation of
olpc_analog_input() in the sound driver?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260629130329.1291953-1-arnd@kernel.org?part=2

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

* Re: [PATCH 4/6] [v5] Input: gpio-keys: make legacy gpiolib optional
  2026-06-29 13:03 ` [PATCH 4/6] [v5] Input: gpio-keys: make legacy gpiolib optional Arnd Bergmann
@ 2026-06-29 13:32   ` sashiko-bot
  0 siblings, 0 replies; 18+ messages in thread
From: sashiko-bot @ 2026-06-29 13:32 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-leds, lee, linux-input, dmitry.torokhov

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The target patch breaks button hold and debounce functionality for legacy boards that specify both a GPIO and an IRQ in their platform data.
--

commit 7c2e3c482d0d5858bfbdee73da72e2a7bcba0509
Author: Arnd Bergmann <arnd@arndb.de>

Input: gpio-keys: make legacy gpiolib optional

This commit makes the legacy gpiolib interfaces optional in the gpio-keys
and gpio-keys-polled drivers by enclosing them in an #ifdef block. It also
modifies the gpio-keys driver to ignore the GPIO number if an IRQ is passed
to keep the Rohm PMIC drivers working.

Link: https://lore.kernel.org/all/b3c94552-c104-42e3-be15-7e8362e8039e@gmail.com/
Link: https://lore.kernel.org/all/afJXG4_rtaj3l2Dk@google.com/
Link: https://lore.kernel.org/all/ajQ-CtU131FAJ9ES@google.com/

> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c

[ ... ]

> @@ -528,7 +528,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
>  			 */
>  			bdata->gpiod = NULL;
>  		}
> -	} else if (gpio_is_valid(button->gpio)) {
> +#ifdef CONFIG_GPIOLIB_LEGACY
> +	} else if (!button->irq && gpio_is_valid(button->gpio)) {

[Severity: High]
Does this skip requesting the legacy GPIO descriptor if an IRQ is provided,
breaking platforms that explicitly provide both?

Legacy boards (like assabet, collie, or h3xxx) use both a GPIO and an IRQ
to allow reading the button state alongside a custom IRQ trigger.

By skipping the GPIO setup when an IRQ is provided, bdata->gpiod remains
NULL. The driver then falls back to its IRQ-only mode where it can no
longer read the physical state of the GPIO, instead simulating an immediate
key press and release via a timer.

Could this break button hold and debounce functionality for these legacy
machines?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260629130329.1291953-1-arnd@kernel.org?part=4

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

* Re: [PATCH 5/6] [v5] leds: gpio: make legacy gpiolib interface optional
  2026-06-29 13:03 ` [PATCH 5/6] [v5] leds: gpio: make legacy gpiolib interface optional Arnd Bergmann
@ 2026-06-29 13:38   ` sashiko-bot
  2026-06-29 15:09   ` Andy Shevchenko
  1 sibling, 0 replies; 18+ messages in thread
From: sashiko-bot @ 2026-06-29 13:38 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: dmitry.torokhov, linux-input, linux-leds, lee

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Fatal build error due to missing header file `linux/gpio/legacy.h`.
--

commit 2f558c72edeac39e19dec733e556e60219934526
Author: Arnd Bergmann <arnd@arndb.de>

leds: gpio: make legacy gpiolib interface optional

This commit splits out the legacy portion of the platform_data handling into
a custom helper function guarded by CONFIG_GPIOLIB_LEGACY. The goal is to
allow the leds-gpio driver to compile cleanly when the legacy configuration
gets turned off for modern platforms.

Link: https://lore.kernel.org/all/e9252384-a55c-4a91-9c61-06e05a0b2ce4@app.fastmail.com/

> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
> index a3428b22de3a1..740772c2504a1 100644
> --- a/drivers/leds/leds-gpio.c
> +++ b/drivers/leds/leds-gpio.c
> @@ -9,8 +9,8 @@
>  #include <linux/container_of.h>
>  #include <linux/device.h>
>  #include <linux/err.h>
> -#include <linux/gpio.h>
>  #include <linux/gpio/consumer.h>
> +#include <linux/gpio/legacy.h>

[Severity: Low]
Does this cause a build failure? It looks like linux/gpio/legacy.h doesn't
exist in the kernel source tree, and the legacy GPIO APIs remain conditionally
available within include/linux/gpio.h itself.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260629130329.1291953-1-arnd@kernel.org?part=5

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

* Re: [PATCH 2/6] [v5] x86/olpc: select GPIOLIB_LEGACY
  2026-06-29 13:25   ` sashiko-bot
@ 2026-06-29 13:40     ` Arnd Bergmann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2026-06-29 13:40 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: linux-input, Lee Jones, Dmitry Torokhov, linux-leds

On Mon, Jun 29, 2026, at 15:25, sashiko-bot@kernel.org wrote:
>> diff --git a/arch/x86/platform/olpc/olpc-xo1-sci.c b/arch/x86/platform/olpc/olpc-xo1-sci.c
>> index 30751b42d54ef..a5b47960ba32e 100644
>> --- a/arch/x86/platform/olpc/olpc-xo1-sci.c
>> +++ b/arch/x86/platform/olpc/olpc-xo1-sci.c
>> @@ -9,7 +9,7 @@
>>  
>>  #include <linux/cs5535.h>
>>  #include <linux/device.h>
>> -#include <linux/gpio.h>
>> +#include <linux/gpio/legacy.h>
>
> [Severity: Low]
> Does this cause a build failure when setup_ec_sci() and other functions in
> this file are compiled? It appears include/linux/gpio/legacy.h does not exist
> in the tree, and the legacy GPIO APIs might still be declared directly in
> include/linux/gpio.h.

The header was added in 7.2-rc1.

     Arnd

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

* Re: [PATCH 6/6] [v5] gpiolib: turn off legacy interface by default
  2026-06-29 13:03 ` [PATCH 6/6] [v5] gpiolib: turn off legacy interface by default Arnd Bergmann
@ 2026-06-29 13:46   ` sashiko-bot
  2026-06-29 14:13     ` Arnd Bergmann
  2026-06-29 16:04   ` Geert Uytterhoeven
  1 sibling, 1 reply; 18+ messages in thread
From: sashiko-bot @ 2026-06-29 13:46 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-input, linux-leds, dmitry.torokhov, lee

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Drivers depending on `GPIOLIB_LEGACY` rather than selecting it are rendered unselectable and silently disabled on normal builds.
- [Low] Disabling CONFIG_GPIOLIB_LEGACY by default causes widespread build failures for platforms and drivers still relying on legacy GPIO functions.
--

commit bad1a2df68babe59200c7570528e8b8606464b68
Author: Arnd Bergmann <arnd@arndb.de>

gpiolib: turn off legacy interface by default

This commit changes the GPIOLIB_LEGACY configuration to default to 'n' instead
of 'y'. It restricts manual selection to builds where COMPILE_TEST is enabled,
intending to only build the legacy interface on platforms that require it.

> All users of the legacy interface now select CONFIG_GPIOLIB_LEGACY,
> so it can be turned off by default and only get built on platforms
> that still have one unconverted driver.

[Severity: High]
Is this description entirely accurate?

There appear to be drivers that use 'depends on GPIOLIB_LEGACY' rather than
selecting it, such as MFD_AAT2870_CORE, MFD_SI476X_CORE, and
SND_SOC_TLV320DAC33.

If GPIOLIB_LEGACY defaults to 'n' without COMPILE_TEST enabled, will these
drivers be rendered unselectable and silently disabled on normal builds?

> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index 020e51e30317a..543de15a12f63 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -4,7 +4,14 @@
>  #
>  
>  config GPIOLIB_LEGACY
> -	def_bool y
> +	bool "Legacy GPIO interfaces" if COMPILE_TEST

[Severity: Low]
Could disabling this by default cause build failures on legacy platforms that
still call GPIO functions but do not explicitly select GPIOLIB_LEGACY?

For instance, arch/arm/mach-pxa/am200epd.c still uses gpio_request():

arch/arm/mach-pxa/am200epd.c:am200_init_gpio_regs() {
        ...
        err = gpio_request(gpios[i], gpio_names[i]);
        ...
}

Because include/linux/gpio.h excludes the legacy prototypes when
CONFIG_GPIOLIB_LEGACY is disabled, will this cause implicit declaration
compiler errors during standard builds for architectures like PXA?

> +	help
> +	  There are a few legacy platforms that use the traditional GPIO
> +	  number based interfaces instead of GPIO descriptors.
> +	  Say Y here to enable build testing drivers that are specific
> +	  to those platforms.
> +
> +	  If unsure, say N.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260629130329.1291953-1-arnd@kernel.org?part=6

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

* Re: [PATCH 6/6] [v5] gpiolib: turn off legacy interface by default
  2026-06-29 13:46   ` sashiko-bot
@ 2026-06-29 14:13     ` Arnd Bergmann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2026-06-29 14:13 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: linux-input, linux-leds, Dmitry Torokhov, Lee Jones

On Mon, Jun 29, 2026, at 15:46, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential 
> issue(s) to consider:
> - [High] Drivers depending on `GPIOLIB_LEGACY` rather than selecting it 
> are rendered unselectable and silently disabled on normal builds.
> - [Low] Disabling CONFIG_GPIOLIB_LEGACY by default causes widespread 
> build failures for platforms and drivers still relying on legacy GPIO 
> functions.

That is the idea, yes: If someone adds back a new legacy user, they
will get a build failure after this patch.

>> All users of the legacy interface now select CONFIG_GPIOLIB_LEGACY,
>> so it can be turned off by default and only get built on platforms
>> that still have one unconverted driver.
>
> [Severity: High]
> Is this description entirely accurate?
>
> There appear to be drivers that use 'depends on GPIOLIB_LEGACY' rather than
> selecting it, such as MFD_AAT2870_CORE, MFD_SI476X_CORE, and
> SND_SOC_TLV320DAC33.
>
> If GPIOLIB_LEGACY defaults to 'n' without COMPILE_TEST enabled, will these
> drivers be rendered unselectable and silently disabled on normal builds?

Yes, correct. I made sure that all platforms that do use GPIO
numbers select those symbols. The three drivers listed above
can only work if a platform has a board file with the corresponding
platform data, but nothing provides si476x_platform_data or
aat2870_platform_data, and SND_SOC_TLV320DAC33 is already
a hidden Kconfig symbol and disabled for all platforms.

      Arnd

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

* Re: [PATCH 5/6] [v5] leds: gpio: make legacy gpiolib interface optional
  2026-06-29 13:03 ` [PATCH 5/6] [v5] leds: gpio: make legacy gpiolib interface optional Arnd Bergmann
  2026-06-29 13:38   ` sashiko-bot
@ 2026-06-29 15:09   ` Andy Shevchenko
  2026-06-29 15:58     ` Arnd Bergmann
  1 sibling, 1 reply; 18+ messages in thread
From: Andy Shevchenko @ 2026-06-29 15:09 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-gpio, Arnd Bergmann, John Paul Adrian Glaubitz,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Linus Walleij, Bartosz Golaszewski,
	Dmitry Torokhov, Lee Jones, Pavel Machek, linux-sh, linux-kernel,
	linux-input, linux-leds, Bartosz Golaszewski

On Mon, Jun 29, 2026 at 03:03:28PM +0200, Arnd Bergmann wrote:

> There are still a handful of ancient mips/armv5/sh boards that use the
> gpio_led:gpio member to pass an old-style gpio number, but all modern
> users have been converted to gpio descriptors.
> 
> While the CONFIG_GPIOLIB_LEGACY option that guards devm_gpio_request_one()
> and related helpers is currently turned on in all kernel builds,
> the plan is to only enable it on the few platforms that actually
> pass gpio numbers in any platform_data.
> 
> Split out the legacy portion of the platform_data handling into a custom
> helper function that is guarded with in #ifdef block, to allow the
> the leds-gpio driver to compile cleanly when CONFIG_GPIOLIB_LEGACY
> gets turned off. Once the last user is converted, this function can
> be removed.

...

>  	gpiod = devm_gpiod_get_index_optional(dev, NULL, idx, GPIOD_OUT_LOW);
> -	if (IS_ERR(gpiod))
> -		return gpiod;

We can leave these and rather have

	gpiod_set_consumer_name(gpiod, template->name);
	return gpiod;

than introduce irregular pattern.

> -	if (gpiod) {
> +	if (!IS_ERR(gpiod))
>  		gpiod_set_consumer_name(gpiod, template->name);
> -		return gpiod;
> -	}
>  
> -	/*
> -	 * This is the legacy code path for platform code that
> -	 * still uses GPIO numbers. Ultimately we would like to get
> -	 * rid of this block completely.
> -	 */
> +	return gpiod;
> +}

I haven't insisted on this previously as I thought that this was on track to be
applied. Since it's not (yet), please, amend the change.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 5/6] [v5] leds: gpio: make legacy gpiolib interface optional
  2026-06-29 15:09   ` Andy Shevchenko
@ 2026-06-29 15:58     ` Arnd Bergmann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2026-06-29 15:58 UTC (permalink / raw)
  To: Andy Shevchenko, Arnd Bergmann
  Cc: open list:GPIO SUBSYSTEM, John Paul Adrian Glaubitz,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Linus Walleij, Bartosz Golaszewski,
	Dmitry Torokhov, Lee Jones, Pavel Machek, linux-sh, linux-kernel,
	linux-input, linux-leds, Bartosz Golaszewski

On Mon, Jun 29, 2026, at 17:09, Andy Shevchenko wrote:
> On Mon, Jun 29, 2026 at 03:03:28PM +0200, Arnd Bergmann wrote:
>
>>  	gpiod = devm_gpiod_get_index_optional(dev, NULL, idx, GPIOD_OUT_LOW);
>> -	if (IS_ERR(gpiod))
>> -		return gpiod;
>
> We can leave these and rather have
>
> 	gpiod_set_consumer_name(gpiod, template->name);
> 	return gpiod;
>
> than introduce irregular pattern.
>

Ok, changed now.

      Arnd

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

* Re: [PATCH 6/6] [v5] gpiolib: turn off legacy interface by default
  2026-06-29 13:03 ` [PATCH 6/6] [v5] gpiolib: turn off legacy interface by default Arnd Bergmann
  2026-06-29 13:46   ` sashiko-bot
@ 2026-06-29 16:04   ` Geert Uytterhoeven
  1 sibling, 0 replies; 18+ messages in thread
From: Geert Uytterhoeven @ 2026-06-29 16:04 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-gpio, Arnd Bergmann, John Paul Adrian Glaubitz,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Linus Walleij, Bartosz Golaszewski,
	Dmitry Torokhov, Lee Jones, Pavel Machek, linux-sh, linux-kernel,
	linux-input, linux-leds

On Mon, 29 Jun 2026 at 15:18, Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> All users of the legacy interface now select CONFIG_GPIOLIB_LEGACY,
> so it can be turned off by default and only get built on platforms
> that still have one unconverted driver.
>
> Allow turning it on manually for compile testing, in order to keep
> the build coverage of the legacy drivers in allmodconfig and
> randconfig.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v5: added patch, now that we are getting closer to completing
>     the series

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] 18+ messages in thread

end of thread, other threads:[~2026-06-29 16:04 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 13:03 [PATCH v5 0/6] gpiolib: fence off legacy interfaces Arnd Bergmann
2026-06-29 13:03 ` [PATCH 1/6] [v5] sh: select legacy gpiolib interface Arnd Bergmann
2026-06-29 13:12   ` sashiko-bot
2026-06-29 13:03 ` [PATCH 2/6] [v5] x86/olpc: select GPIOLIB_LEGACY Arnd Bergmann
2026-06-29 13:25   ` sashiko-bot
2026-06-29 13:40     ` Arnd Bergmann
2026-06-29 13:03 ` [PATCH 3/6] [v5] Input: soc_button_array - select CONFIG_GPIOLIB_LEGACY Arnd Bergmann
2026-06-29 13:18   ` sashiko-bot
2026-06-29 13:03 ` [PATCH 4/6] [v5] Input: gpio-keys: make legacy gpiolib optional Arnd Bergmann
2026-06-29 13:32   ` sashiko-bot
2026-06-29 13:03 ` [PATCH 5/6] [v5] leds: gpio: make legacy gpiolib interface optional Arnd Bergmann
2026-06-29 13:38   ` sashiko-bot
2026-06-29 15:09   ` Andy Shevchenko
2026-06-29 15:58     ` Arnd Bergmann
2026-06-29 13:03 ` [PATCH 6/6] [v5] gpiolib: turn off legacy interface by default Arnd Bergmann
2026-06-29 13:46   ` sashiko-bot
2026-06-29 14:13     ` Arnd Bergmann
2026-06-29 16:04   ` Geert Uytterhoeven

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