Skip to contentSkip to conversation

gpiolib: fence off legacy interfaces

PATCH Applied Arnd Bergmann 12 participants 32 messages May 20 – Jul 7

Subsystems (21)

v2 of 6 Applied Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 cover gpiolib: fence off legacy interfaces

From: Arnd Bergmann <[email protected]>

This is an update of all the patches that are still required before we can actually turn off CONFIG_GPIOLIB_LEGACY for most platforms in the final patch of this series.

I originally posted this as a series in
https://lore.kernel.org/all/[email protected]/

I added more patches for the p54spi driver that I had originally sent separately and submitted the remaining ones separately to the subsystem maintainers, with about two thirds getting picked up so far.

If possible, please apply the patches to the respective architecture (mips, sh, x86, soc/omap) or subsystem (wireless, net-next, led, input) trees.

Arnd

Arnd Bergmann (10):
[v2] [net-next] net: dsa: b53: hide legacy gpiolib usage on non-mips [v3] input: gpio-keys: make legacy gpiolib optional
[v2] x86/olpc: select GPIOLIB_LEGACY
[v2] sh: select legacy gpiolib interface
[v2] mips: select legacy gpiolib interfaces where used [v4] leds: gpio: make legacy gpiolib interface optional [v6 net-next] dt-bindings: net: add st,stlc4560/p54spi binding [v6 net-next] p54spi: convert to devicetree
[v6 omap] ARM: dts: omap2: add stlc4560 spi-wireless node
gpiolib: turn off legacy interface by default

Cc Christian Lamparter <[email protected]>
Cc Johannes Berg <[email protected]>
Cc Aaro Koskinen <[email protected]>
Cc Andreas Kemnade <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Roger Quadros <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc John Paul Adrian Glaubitz <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Lee Jones <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Matti Vaittinen <[email protected]>
Cc Florian Fainelli <[email protected]>
Cc Jonas Gorski <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Vladimir Oltean <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Arnd Bergmann <[email protected]>
 .../bindings/net/wireless/st,stlc4560.yaml    | 61 +++++++++++++++++
 MAINTAINERS                                   |  1 +
 arch/arm/boot/dts/ti/omap/omap2.dtsi          |  4 ++
 .../dts/ti/omap/omap2420-n8x0-common.dtsi     | 12 ++++
 arch/arm/mach-omap2/board-n8x0.c              | 18 -----
 arch/mips/Kconfig                             |  5 ++
 arch/mips/alchemy/Kconfig                     |  1 -
 arch/mips/txx9/Kconfig                        |  1 +
 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 +
 drivers/gpio/Kconfig                          |  9 ++-
 drivers/input/keyboard/gpio_keys.c            |  7 +-
 drivers/input/keyboard/gpio_keys_polled.c     |  2 +
 drivers/leds/leds-gpio.c                      | 51 +++++++++-----
 drivers/mfd/rohm-bd71828.c                    |  1 -
 drivers/mfd/rohm-bd718x7.c                    |  1 -
 drivers/net/dsa/b53/b53_common.c              | 17 ++---
 drivers/net/dsa/b53/b53_priv.h                | 25 +++++--
 drivers/net/wireless/intersil/p54/p54spi.c    | 67 +++++++------------
 drivers/net/wireless/intersil/p54/p54spi.h    |  3 +
 include/linux/gpio_keys.h                     |  2 +
 include/linux/leds.h                          |  2 +
 sound/pci/Kconfig                             |  1 +
 26 files changed, 201 insertions(+), 104 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml
Signature · 1 line
2.39.5
#1 lore raw

PATCH v2 1/10 net: dsa: b53: hide legacy gpiolib usage on non-mips

From: Arnd Bergmann <[email protected]>

The MIPS bcm53xx platform still uses the legacy gpiolib interfaces based on gpio numbers, but other platforms do not.

Hide these interfaces inside of the existing #ifdef block and use the modern interfaces in the common parts of the driver to allow building it when the gpio_set_value() is left out of the kernel.

---
 drivers/net/dsa/b53/b53_common.c | 17 +++++------------
 drivers/net/dsa/b53/b53_priv.h   | 25 +++++++++++++++++++------
 2 files changed, 24 insertions(+), 18 deletions(-)
drivers/net/dsa/b53/b53_common.c +5 -12
index 2c4131ed7e30..d838511ae674 100644
@@ -19,7 +19,7 @@
 
 #include <linux/delay.h>
 #include <linux/export.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/kernel.h>
 #include <linux/math.h>
 #include <linux/minmax.h>
@@ -965,17 +965,17 @@ EXPORT_SYMBOL(b53_configure_vlan);
 
 static void b53_switch_reset_gpio(struct b53_device *dev)
 {
-	int gpio = dev->reset_gpio;
+	struct gpio_desc *gpio = dev->reset_gpio;
 
-	if (gpio < 0)
+	if (IS_ERR(gpio))
 		return;
 
 	/* Reset sequence: RESET low(50ms)->high(20ms)
 	 */
-	gpio_set_value(gpio, 0);
+	gpiod_set_value(gpio, 0);
 	mdelay(50);
 
-	gpio_set_value(gpio, 1);
+	gpiod_set_value(gpio, 1);
 	mdelay(20);
 
 	dev->current_page = 0xff;
@@ -3092,7 +3092,6 @@ static int b53_switch_init(struct b53_device *dev)
 {
 	u32 chip_id = dev->chip_id;
 	unsigned int i;
-	int ret;
 
 	if (is63xx(dev))
 		chip_id = BCM63XX_DEVICE_ID;
@@ -3173,12 +3172,6 @@ static int b53_switch_init(struct b53_device *dev)
 		return -ENOMEM;
 
 	dev->reset_gpio = b53_switch_get_reset_gpio(dev);
-	if (dev->reset_gpio >= 0) {
-		ret = devm_gpio_request_one(dev->dev, dev->reset_gpio,
-					    GPIOF_OUT_INIT_HIGH, "robo_reset");
-		if (ret)
-			return ret;
-	}
 
 	return 0;
 }
drivers/net/dsa/b53/b53_priv.h +19 -6
index bd6849e5bb93..cd27a7344e89 100644
@@ -148,7 +148,7 @@ struct b53_device {
 	u8 duplex_reg;
 	u8 jumbo_pm_reg;
 	u8 jumbo_size_reg;
-	int reset_gpio;
+	struct gpio_desc *reset_gpio;
 	u8 num_arl_bins;
 	u16 num_arl_buckets;
 	enum dsa_tag_protocol tag_protocol;
@@ -467,23 +467,36 @@ static inline void b53_arl_search_read(struct b53_device *dev, u8 idx,
 #ifdef CONFIG_BCM47XX
 
 #include <linux/bcm47xx_nvram.h>
+#include <linux/gpio.h>
 #include <bcm47xx_board.h>
-static inline int b53_switch_get_reset_gpio(struct b53_device *dev)
+static inline struct gpio_desc *b53_switch_get_reset_gpio(struct b53_device *dev)
 {
 	enum bcm47xx_board board = bcm47xx_board_get();
+	int gpio, ret;
 
 	switch (board) {
 	case BCM47XX_BOARD_LINKSYS_WRT300NV11:
 	case BCM47XX_BOARD_LINKSYS_WRT310NV1:
-		return 8;
+		gpio = 8;
+		break;
 	default:
-		return bcm47xx_nvram_gpio_pin("robo_reset");
+		gpio = bcm47xx_nvram_gpio_pin("robo_reset");
 	}
+
+	if (!gpio_is_valid(gpio))
+		return ERR_PTR(-EINVAL);
+
+	ret = devm_gpio_request_one(dev->dev, gpio,
+				    GPIOF_OUT_INIT_HIGH, "robo_reset");
+	if (ret)
+		return ERR_PTR(ret);
+
+	return gpio_to_desc(gpio);
 }
 #else
-static inline int b53_switch_get_reset_gpio(struct b53_device *dev)
+static inline struct gpio_desc *b53_switch_get_reset_gpio(struct b53_device *dev)
 {
-	return -ENOENT;
+	return ERR_PTR(-ENODEV);
 }
 #endif
 
Signature · 1 line
2.39.5
#2 lore raw

Re: [PATCH 01/10] [v2] [net-next] net: dsa: b53: hide legacy gpiolib usage on non-mips

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Probe errors from devm_gpio_request_one() are silently ignored, failing to propagate critical…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Probe errors from devm_gpio_request_one() are silently ignored, failing to propagate critical errors such as -EPROBE_DEFER. --

commit 46ca85c6cb9da93cad093c8eb342afc0ea94be33
Author: Arnd Bergmann <[email protected]>

net: dsa: b53: hide legacy gpiolib usage on non-mips

This commit moves legacy gpiolib usage inside an #ifdef block and transitions the common parts of the driver to use modern GPIO descriptors. This allows building the driver even when gpio_set_value is left out of the kernel.

Quoted 4 lines
drivers/net/dsa/b53/b53_common.c +0 -0
index 2c4131ed7e30b..d838511ae6744 100644

[ ... ]

drivers/net/dsa/b53/b53_common.c static int b53_switch_init(struct b53_device *dev) · line 3177

Quoted 13 lines
drivers/net/dsa/b53/b53_common.c +0 -6
@@ -3173,12 +3172,6 @@ static int b53_switch_init(struct b53_device *dev)
 		return -ENOMEM;
 
 	dev->reset_gpio = b53_switch_get_reset_gpio(dev);
-	if (dev->reset_gpio >= 0) {
-		ret = devm_gpio_request_one(dev->dev, dev->reset_gpio,
-					    GPIOF_OUT_INIT_HIGH, "robo_reset");
-		if (ret)
-			return ret;
-	}
 
 	return 0;
 }

[Severity: High]
Does this silently ignore probe errors like -EPROBE_DEFER?

Previously, if devm_gpio_request_one failed, the error was returned to the caller. Now, b53_switch_get_reset_gpio handles the request and returns an ERR_PTR on failure, but that error pointer is simply stored in dev->reset_gpio while b53_switch_init unconditionally returns 0.

Later in the code, b53_switch_reset_gpio relies on IS_ERR(dev->reset_gpio) to gracefully return, which would silently skip the reset sequence entirely if the GPIO controller simply isn't ready yet (-EPROBE_DEFER) or if there was a memory allocation failure (-ENOMEM).

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

Re: [PATCH 01/10] [v2] [net-next] net: dsa: b53: hide legacy gpiolib usage on non-mips

Quoted 9 lines · On Sat, May 30, 2026, at 02:45, [email protected] wrote:

[Severity: High]
Does this silently ignore probe errors like -EPROBE_DEFER?

Previously, if devm_gpio_request_one failed, the error was returned to the caller. Now, b53_switch_get_reset_gpio handles the request and returns an ERR_PTR on failure, but that error pointer is simply stored in dev->reset_gpio while b53_switch_init unconditionally returns 0.

Quoted 4 lines

Later in the code, b53_switch_reset_gpio relies on IS_ERR(dev->reset_gpio) to gracefully return, which would silently skip the reset sequence entirely if the GPIO controller simply isn't ready yet (-EPROBE_DEFER) or if there was a memory allocation failure (-ENOMEM).

The driver already ignored errors previously on BCM47xx. and I can see that -EPROBE_DEFER cannot happen because the gpio driver is very simplistic and always built-in.

I've updated the patch to propagate -EPROBE_DEFER anway as that is clearly the correct thing to do in case it ever gets used extended to other platforms. All other errors continue to be ignored to keep the current behavior of the driver.

Arnd

#4 lore raw

PATCH v3 2/10 input: gpio-keys: make legacy gpiolib optional

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

---
v3: resend
v2: skip the fake GPIO number passing from mfd

The removal of the arm platforms using this is not yet going to happen for 7.2, and Dmitry's changes for the Rohm drivers have not yet made it into linux-next as of 2026-05-20, so for the moment I would still like to see this patch get merged, even if we are closing in on completely removing the legacy gpio support in the gpio_keys driver, so we can make CONFIG_GPIOLIB_LEGACY default-disabled sooner.

---
 drivers/input/keyboard/gpio_keys.c        | 7 ++++---
 drivers/input/keyboard/gpio_keys_polled.c | 2 ++
 drivers/mfd/rohm-bd71828.c                | 1 -
 drivers/mfd/rohm-bd718x7.c                | 1 -
 include/linux/gpio_keys.h                 | 2 ++
 5 files changed, 8 insertions(+), 5 deletions(-)
drivers/input/keyboard/gpio_keys.c +4 -3
index e19617485679..d748a54dc51c 100644
@@ -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;
drivers/input/keyboard/gpio_keys_polled.c +2 -0
index e6707d72210e..0ae0e53910ea 100644
@@ -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;
drivers/mfd/rohm-bd71828.c +0 -1
index a79f354bf5cb..df6dad762ec9 100644
@@ -39,7 +39,6 @@
 
 static struct gpio_keys_button button = {
 	.code = KEY_POWER,
-	.gpio = -1,
 	.type = EV_KEY,
 	.wakeup = 1,
 };
drivers/mfd/rohm-bd718x7.c +0 -1
index ff714fd4f54d..dd774aa8828b 100644
@@ -20,7 +20,6 @@
 
 static struct gpio_keys_button button = {
 	.code = KEY_POWER,
-	.gpio = -1,
 	.type = EV_KEY,
 };
 
include/linux/gpio_keys.h +2 -0
index 80fa930b04c6..e8d6dc290efb 100644
@@ -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;
Signature · 1 line
2.39.5
maintainer Reviewed-by on v3 2/10
#5 lore raw

Re: [PATCH 02/10] [v3] input: gpio-keys: make legacy gpiolib optional

Quoted 14 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

Quoted 4 lines

---

maintainer Reviewed-by on v3 2/10
#6 lore raw

Re: [PATCH 02/10] [v3] input: gpio-keys: make legacy gpiolib optional

In reply to Arnd Bergmann
Quoted 21 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

---
v3: resend
v2: skip the fake GPIO number passing from mfd

Quoted 7 lines

The removal of the arm platforms using this is not yet going to happen for 7.2, and Dmitry's changes for the Rohm drivers have not yet made it into linux-next as of 2026-05-20, so for the moment I would still like to see this patch get merged, even if we are closing in on completely removing the legacy gpio support in the gpio_keys driver, so we can make CONFIG_GPIOLIB_LEGACY default-disabled sooner.

I am (still) all fine with this, even though I like Dmitry's set. I suppose you already have a plan for merging this, but I still have to ask - why the MFD changes aren't in own patch? I feel it would have simplified merging, backporting, reviewing and reverting if needed.

Well, other than that:

Yours,
-- Matti

---
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~

#7 lore raw

Re: [PATCH 02/10] [v3] input: gpio-keys: make legacy gpiolib optional

Quoted 9 lines · Matti Vaittinen
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

Quoted 4 lines

I am (still) all fine with this, even though I like Dmitry's set. I suppose you already have a plan for merging this, but I still have to ask - why the MFD changes aren't in own patch? I feel it would have simplified merging, backporting, reviewing and reverting if needed.

Splitting it out would break bisection: The gpio-leds change without the mfd change causes a build failure when assigning the .gpio field, and the reverse causes a runtime failure when .gpio=0 is a valid line.

It would be possible to only do the gpio-led driver patch without the header file change first. This would let us apply the last patch in the series without regression, but it would risk having not catching other drivers that incorrectly set the .gpio field while CONFIG_GPIOLIB_LEGACY is disabled.

Arnd

maintainer
#8 lore raw

Re: [PATCH 02/10] [v3] input: gpio-keys: make legacy gpiolib optional

Quoted 15 lines · Arnd Bergmann
Quoted 9 lines · Matti Vaittinen
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

Quoted 4 lines

I am (still) all fine with this, even though I like Dmitry's set. I suppose you already have a plan for merging this, but I still have to ask - why the MFD changes aren't in own patch? I feel it would have simplified merging, backporting, reviewing and reverting if needed.

Quoted 4 lines

Splitting it out would break bisection: The gpio-leds change without the mfd change causes a build failure when assigning the .gpio field, and the reverse causes a runtime failure when .gpio=0 is a valid line.

Ah, yes. Thanks for explanation. (I feel a bit [a lot] stupid, as I somehow missed the problem of .gpio = 0 being valid. That even though I had it explicitly set to -1 myself :rolleyes: ).

No further questions ;)

Yours,
-- Matti

Signature · 6 lines
---
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~
maintainer Reviewed-by on v3 2/10
#9 lore raw

Re: [PATCH 02/10] [v3] input: gpio-keys: make legacy gpiolib optional

In reply to Arnd Bergmann
Quoted 9 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

Quoted 8 lines

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.

Yours,
Linus Walleij

maintainer
#10 lore raw

Re: [PATCH 02/10] [v3] input: gpio-keys: make legacy gpiolib optional

Quoted 16 lines · Linus Walleij
Quoted 14 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

Quoted 5 lines
Quoted 3 lines

OK, if Lee Acks MFD changes I can pick this up.

Thanks.

Signature · 1 line
Dmitry
#11 lore raw

Re: [PATCH 02/10] [v3] input: gpio-keys: make legacy gpiolib optional

In reply to Arnd Bergmann
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Modifying the legacy GPIO validation to check `!button->irq` breaks legacy devices that…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Modifying the legacy GPIO validation to check !button->irq breaks legacy devices that legitimately provide both a GPIO and an IRQ.
- [Medium] Conditionally removing the gpio field from struct gpio_keys_button causes build failures in drivers that assign to this field when CONFIG_GPIOLIB_LEGACY is disabled. --

commit cb399daff5ceabcf54d5ea611fd309f5c0600ab4
Author: Arnd Bergmann <[email protected]>

input: gpio-keys: make legacy gpiolib optional

This commit makes the legacy gpiolib interface optional for gpio-keys and gpio-keys-polled by adding ifdef blocks. It also modifies the gpio-keys driver to ignore the gpio number if an IRQ is passed to keep Rohm PMIC drivers working with and without CONFIG_GPIOLIB_LEGACY.

Quoted 3 lines
drivers/input/keyboard/gpio_keys.c +0 -0

[ ... ]

drivers/input/keyboard/gpio_keys.c static int gpio_keys_setup_key(struct platform_device *pdev, · line 532

Quoted 7 lines
drivers/input/keyboard/gpio_keys.c +2 -1
@@ -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 change break legacy devices that legitimately provide both a valid GPIO and a valid IRQ?

If a legacy platform provides both a valid GPIO and an IRQ, this condition now evaluates to false.

By skipping the GPIO request entirely, the driver falls back to treating the device as a pure IRQ button. This forces the driver to lose hardware debouncing and rely on a simulated release timer instead of checking the physical GPIO line.

[ ... ]

Quoted 3 lines
include/linux/gpio_keys.h +0 -0

[ ... ]

include/linux/gpio_keys.h struct device; · line 31

Quoted 8 lines
include/linux/gpio_keys.h +2 -0
@@ -25,7 +25,9 @@ struct device;
  */
 struct gpio_keys_button {
 	unsigned int code;
+#ifdef CONFIG_GPIOLIB_LEGACY
 	int gpio;
+#endif
 	int active_low;

[Severity: Medium]
Will this cause build failures for drivers that assign to this field when CONFIG_GPIOLIB_LEGACY is disabled?

Other modern drivers dynamically create the platform device and pass legacy GPIO numbers by directly assigning to this field:

drivers/input/misc/soc_button_array.c:soc_button_device_create() {
    ...
    gpio_keys[n_buttons].gpio = gpio;
    ...
}

When CONFIG_GPIOLIB_LEGACY is disabled, this results in a compilation failure since struct gpio_keys_button no longer has the gpio member.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#12 lore raw

Re: [PATCH 02/10] [v3] input: gpio-keys: make legacy gpiolib optional

Quoted 11 lines · On Sat, May 30, 2026, at 02:45, [email protected] wrote:

[Severity: High]
Does this change break legacy devices that legitimately provide both a valid GPIO and a valid IRQ?

If a legacy platform provides both a valid GPIO and an IRQ, this condition now evaluates to false.

By skipping the GPIO request entirely, the driver falls back to treating the device as a pure IRQ button. This forces the driver to lose hardware debouncing and rely on a simulated release timer instead of checking the physical GPIO line.

There are only three drivers that provide the ->irq field. Two are the ones that I'm changing in this patch, the soc_button_array driver is the third and none of them set ->irq and ->gpio at the same time.

Quoted 11 lines

include/linux/gpio_keys.h struct device; · line 31

Quoted 7 lines

*/
struct gpio_keys_button {

include/linux/gpio_keys.h +2 -0
 	unsigned int code;
+#ifdef CONFIG_GPIOLIB_LEGACY
 	int gpio;
+#endif
 	int active_low;

[Severity: Medium]
Will this cause build failures for drivers that assign to this field when CONFIG_GPIOLIB_LEGACY is disabled?

Yes, that is the intention of the patch: nothing should set the ->gpio field unless GPIOLIB_LEGACY is set.

Quoted 11 lines

Other modern drivers dynamically create the platform device and pass legacy GPIO numbers by directly assigning to this field:

drivers/input/misc/soc_button_array.c:soc_button_device_create() {
    ...
    gpio_keys[n_buttons].gpio = gpio;
    ...
}

When CONFIG_GPIOLIB_LEGACY is disabled, this results in a compilation failure since struct gpio_keys_button no longer has the gpio member.

I previously included a patch force-enable GPIOLIB_LEGACY in this patch series, see

https://lore.kernel.org/all/npijagtgyad33xxlq46b7kwzydhcgt5tkgd5ihsjl6t4czbqyf@umovipwh73i2/

I made a mistake during a rebase, so my older patch was still included in my randconfig testing but not in the series I sent. All the other changes in it are now redundant, bit the soc_button_array portion indeed still remains.

Hans, Dmitry, do you already have plans to deal with the soc_button_array driver to move it away from legacy GPIOs?

So far I can see four possible ways we can deal with it, but none that I actually like:

a) delay the problem, apply my original oneline change to 'select GPIOLIB_LEGACY' and fix it later, so we can make GPIOLIB_LEGACY default-disabled in 7.3.

b) add a gpiod member to struct gpio_keys_button and skip the intermediate gpio number here. Clean it up later.

c) always pass the gpio as an interrupt, as the driver already does for some machines

d) add dynamic device properties that duplicate the information from ACPI/DMI, so the driver can stop using platform data

e) disconnect gpio_keys_button from gpio-keys.c and register the buttons to the input subsystem directly from soc_button_device_create().

Any suggestions?

Arnd

maintainer
#13 lore raw

Re: [PATCH 02/10] [v3] input: gpio-keys: make legacy gpiolib optional

Quoted 70 lines · Arnd Bergmann
Quoted 11 lines · On Sat, May 30, 2026, at 02:45, [email protected] wrote:

[Severity: High]
Does this change break legacy devices that legitimately provide both a valid GPIO and a valid IRQ?

If a legacy platform provides both a valid GPIO and an IRQ, this condition now evaluates to false.

By skipping the GPIO request entirely, the driver falls back to treating the device as a pure IRQ button. This forces the driver to lose hardware debouncing and rely on a simulated release timer instead of checking the physical GPIO line.

There are only three drivers that provide the ->irq field. Two are the ones that I'm changing in this patch, the soc_button_array driver is the third and none of them set ->irq and ->gpio at the same time.

Quoted 11 lines

Review

Quoted 7 lines

*/
struct gpio_keys_button {

(quoted diff) +2 -0
 	unsigned int code;
+#ifdef CONFIG_GPIOLIB_LEGACY
 	int gpio;
+#endif
 	int active_low;

[Severity: Medium]
Will this cause build failures for drivers that assign to this field when CONFIG_GPIOLIB_LEGACY is disabled?

Yes, that is the intention of the patch: nothing should set the ->gpio field unless GPIOLIB_LEGACY is set.

Quoted 11 lines

Other modern drivers dynamically create the platform device and pass legacy GPIO numbers by directly assigning to this field:

drivers/input/misc/soc_button_array.c:soc_button_device_create() {
    ...
    gpio_keys[n_buttons].gpio = gpio;
    ...
}

When CONFIG_GPIOLIB_LEGACY is disabled, this results in a compilation failure since struct gpio_keys_button no longer has the gpio member.

I previously included a patch force-enable GPIOLIB_LEGACY in this patch series, see

https://lore.kernel.org/all/npijagtgyad33xxlq46b7kwzydhcgt5tkgd5ihsjl6t4czbqyf@umovipwh73i2/

I made a mistake during a rebase, so my older patch was still included in my randconfig testing but not in the series I sent. All the other changes in it are now redundant, bit the soc_button_array portion indeed still remains.

Hans, Dmitry, do you already have plans to deal with the soc_button_array driver to move it away from legacy GPIOs?

So far I can see four possible ways we can deal with it, but none that I actually like:

a) delay the problem, apply my original oneline change to 'select GPIOLIB_LEGACY' and fix it later, so we can make GPIOLIB_LEGACY default-disabled in 7.3.

b) add a gpiod member to struct gpio_keys_button and skip the intermediate gpio number here. Clean it up later.

c) always pass the gpio as an interrupt, as the driver already does for some machines

Quoted 7 lines

d) add dynamic device properties that duplicate the information from ACPI/DMI, so the driver can stop using platform data

e) disconnect gpio_keys_button from gpio-keys.c and register the buttons to the input subsystem directly from soc_button_device_create().

I tried doing e) and while it is possible I ended up re-implementing most of gpio_keys.c which is not great. We still need both GPIO and IRQ-only modes, and handling debouncing, both software and hardware, and so on. So I would like to see if d) is possible. The problem is that we need to reconstruct GPIO reference from existing gpio_desc. If Bart will be OK with something like below then I think the conversion should be achievable.

gpiolib: Introduce gpiod_get_software_node_reference()

From: Dmitry Torokhov <[email protected]>

To support converting drivers (such as soc_button_array) to use static device properties/software nodes, we need a way to reconstruct a GPIO reference from an existing gpio_desc.

Introduce gpiod_get_software_node_reference() which populates a struct software_node_ref_args with the GPIO device's fwnode, the pin offset, and the appropriate active-low flag.

Assisted-by Gemini:gemini-3.1-pro
---
 drivers/gpio/gpiolib.c        |   35 +++++++++++++++++++++++++++++++++++
 include/linux/gpio/consumer.h |   12 ++++++++++++
 2 files changed, 47 insertions(+)
drivers/gpio/gpiolib.c +35 -0
index 1e6dce430dca..63cef0fb02b5 100644
@@ -247,6 +247,41 @@ int gpiod_hwgpio(const struct gpio_desc *desc)
 }
 EXPORT_SYMBOL_GPL(gpiod_hwgpio);
 
+/**
+ * gpiod_get_software_node_reference() - Reconstruct a software node reference
+ *                                       from a GPIO descriptor
+ * @desc: GPIO descriptor
+ * @args: Pointer to software node reference arguments structure to populate
+ *
+ * This function can be used to construct a software node reference from
+ * an existing GPIO descriptor. This is useful when a driver wants to pass
+ * a software node to a secondary device, but needs to reconstruct a GPIO
+ * reference dynamically.
+ *
+ * Returns:
+ * 0 on success, or a negative error code on failure.
+ */
+int gpiod_get_software_node_reference(const struct gpio_desc *desc,
+				      struct software_node_ref_args *args)
+{
+	struct gpio_device *gdev;
+
+	if (IS_ERR_OR_NULL(desc) || !args)
+		return -EINVAL;
+
+	gdev = desc->gdev;
+
+	memset(args, 0, sizeof(*args));
+	args->fwnode = dev_fwnode(&gdev->dev);
+	args->nargs = 2;
+	args->args[0] = gpiod_hwgpio(desc);
+	if (test_bit(GPIOD_FLAG_ACTIVE_LOW, &desc->flags))
+		args->args[1] = GPIO_ACTIVE_LOW;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(gpiod_get_software_node_reference);
+
 /**
  * gpiod_to_chip - Return the GPIO chip to which a GPIO descriptor belongs
  * @desc:	descriptor to return the chip of
include/linux/gpio/consumer.h +12 -0
index 3efb5cb1e1d1..c95b715a1d15 100644
@@ -11,6 +11,7 @@
 struct acpi_device;
 struct device;
 struct fwnode_handle;
+struct software_node_ref_args;
 
 struct gpio_array;
 struct gpio_desc;
@@ -177,6 +178,9 @@ int desc_to_gpio(const struct gpio_desc *desc);
 
 int gpiod_hwgpio(const struct gpio_desc *desc);
 
+int gpiod_get_software_node_reference(const struct gpio_desc *desc,
+				      struct software_node_ref_args *args);
+
 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
 					 const char *con_id, int index,
 					 enum gpiod_flags flags,
@@ -545,6 +549,14 @@ static inline int desc_to_gpio(const struct gpio_desc *desc)
 	return -EINVAL;
 }
 
+static inline
+int gpiod_get_software_node_reference(const struct gpio_desc *desc,
+				      struct software_node_ref_args *args)
+{
+	WARN_ON(desc);
+	return -EINVAL;
+}
+
 static inline
 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
 					 const char *con_id, int index,

Thanks.

Signature · 1 line
Dmitry
maintainer
#14 lore raw

Re: [PATCH 02/10] [v3] input: gpio-keys: make legacy gpiolib optional

Quoted 26 lines · Dmitry Torokhov
Quoted 17 lines · Arnd Bergmann

Hans, Dmitry, do you already have plans to deal with the soc_button_array driver to move it away from legacy GPIOs?

So far I can see four possible ways we can deal with it, but none that I actually like:

a) delay the problem, apply my original oneline change to 'select GPIOLIB_LEGACY' and fix it later, so we can make GPIOLIB_LEGACY default-disabled in 7.3.

b) add a gpiod member to struct gpio_keys_button and skip the intermediate gpio number here. Clean it up later.

c) always pass the gpio as an interrupt, as the driver already does for some machines

Quoted 7 lines

d) add dynamic device properties that duplicate the information from ACPI/DMI, so the driver can stop using platform data

e) disconnect gpio_keys_button from gpio-keys.c and register the buttons to the input subsystem directly from soc_button_device_create().

Quoted 7 lines

I tried doing e) and while it is possible I ended up re-implementing most of gpio_keys.c which is not great. We still need both GPIO and IRQ-only modes, and handling debouncing, both software and hardware, and so on. So I would like to see if d) is possible. The problem is that we need to reconstruct GPIO reference from existing gpio_desc. If Bart will be OK with something like below then I think the conversion should be achievable.

It turns out Bart was not on the CC list so I was waiting for response in vain...

Bart, will you be OK with something like below?

Quoted 106 lines

gpiolib: Introduce gpiod_get_software_node_reference()

From: Dmitry Torokhov <[email protected]>

To support converting drivers (such as soc_button_array) to use static device properties/software nodes, we need a way to reconstruct a GPIO reference from an existing gpio_desc.

Introduce gpiod_get_software_node_reference() which populates a struct software_node_ref_args with the GPIO device's fwnode, the pin offset, and the appropriate active-low flag.

Assisted-by Gemini:gemini-3.1-pro
---
 drivers/gpio/gpiolib.c        |   35 +++++++++++++++++++++++++++++++++++
 include/linux/gpio/consumer.h |   12 ++++++++++++
 2 files changed, 47 insertions(+)
drivers/gpio/gpiolib.c +35 -0
index 1e6dce430dca..63cef0fb02b5 100644
@@ -247,6 +247,41 @@ int gpiod_hwgpio(const struct gpio_desc *desc)
 }
 EXPORT_SYMBOL_GPL(gpiod_hwgpio);
 
+/**
+ * gpiod_get_software_node_reference() - Reconstruct a software node reference
+ *                                       from a GPIO descriptor
+ * @desc: GPIO descriptor
+ * @args: Pointer to software node reference arguments structure to populate
+ *
+ * This function can be used to construct a software node reference from
+ * an existing GPIO descriptor. This is useful when a driver wants to pass
+ * a software node to a secondary device, but needs to reconstruct a GPIO
+ * reference dynamically.
+ *
+ * Returns:
+ * 0 on success, or a negative error code on failure.
+ */
+int gpiod_get_software_node_reference(const struct gpio_desc *desc,
+				      struct software_node_ref_args *args)
+{
+	struct gpio_device *gdev;
+
+	if (IS_ERR_OR_NULL(desc) || !args)
+		return -EINVAL;
+
+	gdev = desc->gdev;
+
+	memset(args, 0, sizeof(*args));
+	args->fwnode = dev_fwnode(&gdev->dev);
+	args->nargs = 2;
+	args->args[0] = gpiod_hwgpio(desc);
+	if (test_bit(GPIOD_FLAG_ACTIVE_LOW, &desc->flags))
+		args->args[1] = GPIO_ACTIVE_LOW;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(gpiod_get_software_node_reference);
+
 /**
  * gpiod_to_chip - Return the GPIO chip to which a GPIO descriptor belongs
  * @desc:	descriptor to return the chip of
include/linux/gpio/consumer.h +12 -0
index 3efb5cb1e1d1..c95b715a1d15 100644
@@ -11,6 +11,7 @@
 struct acpi_device;
 struct device;
 struct fwnode_handle;
+struct software_node_ref_args;
 
 struct gpio_array;
 struct gpio_desc;
@@ -177,6 +178,9 @@ int desc_to_gpio(const struct gpio_desc *desc);
 
 int gpiod_hwgpio(const struct gpio_desc *desc);
 
+int gpiod_get_software_node_reference(const struct gpio_desc *desc,
+				      struct software_node_ref_args *args);
+
 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
 					 const char *con_id, int index,
 					 enum gpiod_flags flags,
@@ -545,6 +549,14 @@ static inline int desc_to_gpio(const struct gpio_desc *desc)
 	return -EINVAL;
 }
 
+static inline
+int gpiod_get_software_node_reference(const struct gpio_desc *desc,
+				      struct software_node_ref_args *args)
+{
+	WARN_ON(desc);
+	return -EINVAL;
+}
+
 static inline
 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
 					 const char *con_id, int index,

Thanks.

Signature · 1 line
Dmitry
#15 lore raw

PATCH v2 3/10 x86/olpc: select GPIOLIB_LEGACY

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

---
v2: update changelog text

---
 arch/x86/Kconfig  | 1 +
 sound/pci/Kconfig | 1 +
 2 files changed, 2 insertions(+)
arch/x86/Kconfig +1 -0
index f24810015234..69089d2f5dad 100644
@@ -2978,6 +2978,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
sound/pci/Kconfig +1 -0
index e0996a9d90b0..6366f72b3667 100644
@@ -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
Signature · 1 line
2.39.5
#16 lore raw

PATCH v2 4/10 sh: select legacy gpiolib interface

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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 <[email protected]>

---
v2: no changes. Adrian said he'll pick it up for 7.2, but so
far the patch is not in linux-next yet, so I'm including it for completeness here.

---
 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(+)
arch/sh/Kconfig +1 -0
index d5795067befa..d60f1d5a94c0 100644
@@ -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
arch/sh/boards/Kconfig +8 -0
index 1af93be61b1f..d89b74177233 100644
@@ -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.
arch/sh/boards/mach-highlander/Kconfig +1 -0
index b0abd03cac4e..cd3a553ce30c 100644
@@ -20,6 +20,7 @@ config SH_R7785RP
 	bool "R7785RP board support"
 	depends on CPU_SUBTYPE_SH7785
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 
 endchoice
 
arch/sh/boards/mach-rsk/Kconfig +3 -0
index f0299bc4416f..3810937aa5d4 100644
@@ -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
Signature · 1 line
2.39.5
#17 lore raw

Re: [PATCH 04/10] [v2] sh: select legacy gpiolib interface

Hi Arnd,

Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

Quoted 6 lines
Cc John Paul Adrian Glaubitz <[email protected]>

---
v2: no changes. Adrian said he'll pick it up for 7.2, but so
far the patch is not in linux-next yet, so I'm including it for completeness here.

Sorry, I hadn't gotten around to pick the changes for v7.2 yet. I can pick it up this weekend as I was planning to review and merge some patches this weekend.

I have received quite a lot of patches for SH recently, so it will take some time to dig myself through the queue.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#18 lore raw

PATCH v2 5/10 mips: select legacy gpiolib interfaces where used

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

A few old machines have not been converted away from the old-style gpiolib interfaces. Make these select the new CONFIG_GPIOLIB_LEGACY symbol so the code still works where it is needed but can be left out otherwise.

This is the list of all gpio_request() calls in mips:

  arch/mips/alchemy/devboards/db1000.c:           gpio_request(19, "sd0_cd");
  arch/mips/alchemy/devboards/db1000.c:           gpio_request(20, "sd1_cd");
  arch/mips/alchemy/devboards/db1200.c:   gpio_request(215, "otg-vbus");
  arch/mips/bcm47xx/workarounds.c:        err = gpio_request_one(usb_power, GPIOF_OUT_INIT_HIGH, "usb_power");
  arch/mips/bcm63xx/boards/board_bcm963xx.c:              gpio_request_one(board.ephy_reset_gpio,
  arch/mips/txx9/rbtx4927/setup.c:        gpio_request(15, "sio-dtr");

Most of these should be easy enough to change to modern gpio descriptors or remove if they are no longer in use.

---
v2: no changes. There was no discussion on this, but the patch
has so far not made it into the linux-mips tree, so I'm including it for completeness.

---
 arch/mips/Kconfig         | 5 +++++
 arch/mips/alchemy/Kconfig | 1 -
 arch/mips/txx9/Kconfig    | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)
arch/mips/Kconfig +5 -0
index 4364f3dba688..b91e62d69a5d 100644
@@ -206,6 +206,8 @@ config MIPS_ALCHEMY
 	select CSRC_R4K
 	select IRQ_MIPS_CPU
 	select DMA_NONCOHERENT		# Au1000,1500,1100 aren't, rest is
+	select GPIOLIB
+	select GPIOLIB_LEGACY
 	select MIPS_FIXUP_BIGPHYS_ADDR if PCI
 	select SYS_HAS_CPU_MIPS32_R1
 	select SYS_SUPPORTS_32BIT_KERNEL
@@ -307,6 +309,7 @@ config BCM47XX
 	select SYS_HAS_EARLY_PRINTK
 	select USE_GENERIC_EARLY_PRINTK_8250
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	select LEDS_GPIO_REGISTER
 	select BCM47XX_NVRAM
 	select BCM47XX_SPROM
@@ -330,6 +333,7 @@ config BCM63XX
 	select SYS_HAS_CPU_BMIPS4380
 	select SWAP_IO_SPACE
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	select MIPS_L1_CACHE_SHIFT_4
 	select HAVE_LEGACY_CLK
 	help
@@ -999,6 +1003,7 @@ config MIKROTIK_RB532
 	select SWAP_IO_SPACE
 	select BOOT_RAW
 	select GPIOLIB
+	select GPIOLIB_LEGACY
 	select MIPS_L1_CACHE_SHIFT_4
 	help
 	  Support the Mikrotik(tm) RouterBoard 532 series,
arch/mips/alchemy/Kconfig +0 -1
index 6ca81e1bd35c..cf5ad52c0a0f 100644
@@ -12,7 +12,6 @@ config MIPS_MTX1
 
 config MIPS_DB1XXX
 	bool "Alchemy DB1XXX / PB1XXX boards"
-	select GPIOLIB
 	select HAVE_PCI
 	select HAVE_PATA_PLATFORM
 	select SYS_SUPPORTS_LITTLE_ENDIAN
arch/mips/txx9/Kconfig +1 -0
index 7335efa4d528..92b759a434c0 100644
@@ -37,6 +37,7 @@ config SOC_TX4927
 	select IRQ_TXX9
 	select PCI_TX4927
 	select GPIO_TXX9
+	select GPIOLIB_LEGACY
 
 config SOC_TX4938
 	bool
Signature · 1 line
2.39.5
#19 lore raw

Re: [PATCH 05/10] [v2] mips: select legacy gpiolib interfaces where used

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] Duplicate `select GPIOLIB` in `config MIPS_ALCHEMY`. - [Low] Unnecessary `select GPIOLIB_LEGACY`…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Duplicate select GPIOLIB in config MIPS_ALCHEMY.
- [Low] Unnecessary select GPIOLIB_LEGACY for config MIKROTIK_RB532.
--

commit 0726793f1a39f1a0b2ac5d24243bcbe5e8999b93
Author: Arnd Bergmann <[email protected]>

mips: select legacy gpiolib interfaces where used

This commit updates several old mips machines that have not been converted away from the old-style gpiolib interfaces to select CONFIG_GPIOLIB_LEGACY. This ensures the legacy code continues to work where needed but can be omitted otherwise.

arch/mips/Kconfig config MIPS_ALCHEMY · line 210

Quoted 10 lines
arch/mips/Kconfig +2 -0
index 4364f3dba688f..b91e62d69a5db 100644
@@ -206,6 +206,8 @@ config MIPS_ALCHEMY
 	select CSRC_R4K
 	select IRQ_MIPS_CPU
 	select DMA_NONCOHERENT		# Au1000,1500,1100 aren't, rest is
+	select GPIOLIB
+	select GPIOLIB_LEGACY

[Severity: Low]
Is this select GPIOLIB a duplicate? It appears select GPIOLIB is already present further down in the MIPS_ALCHEMY block.

Quoted 3 lines
arch/mips/Kconfig +0 -0
 	select MIPS_FIXUP_BIGPHYS_ADDR if PCI
 	select SYS_HAS_CPU_MIPS32_R1
 	select SYS_SUPPORTS_32BIT_KERNEL

[ ... ]

arch/mips/Kconfig config MIKROTIK_RB532 · line 1006

Quoted 5 lines
arch/mips/Kconfig +1 -0
@@ -999,6 +1003,7 @@ config MIKROTIK_RB532
 	select SWAP_IO_SPACE
 	select BOOT_RAW
 	select GPIOLIB
+	select GPIOLIB_LEGACY

[Severity: Low]
Does this select GPIOLIB_LEGACY introduce an unnecessary dependency for MIKROTIK_RB532? A look at the code indicates that MIKROTIK_RB532 and its associated drivers (like pata_rb532_cf and rb532_button) use the modern descriptor-based gpiod API and do not seem to call the legacy GPIO functions. Could this dependency be omitted so we don't compile legacy interfaces unnecessarily?

Quoted 2 lines
arch/mips/Kconfig +0 -0
 	select MIPS_L1_CACHE_SHIFT_4
 	help
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
maintainer Applied
#20 lore raw

Re: [PATCH 05/10] [v2] mips: select legacy gpiolib interfaces where used

In reply to Arnd Bergmann
Quoted 26 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

A few old machines have not been converted away from the old-style gpiolib interfaces. Make these select the new CONFIG_GPIOLIB_LEGACY symbol so the code still works where it is needed but can be left out otherwise.

This is the list of all gpio_request() calls in mips:

  arch/mips/alchemy/devboards/db1000.c:           gpio_request(19, "sd0_cd");
  arch/mips/alchemy/devboards/db1000.c:           gpio_request(20, "sd1_cd");
  arch/mips/alchemy/devboards/db1200.c:   gpio_request(215, "otg-vbus");
  arch/mips/bcm47xx/workarounds.c:        err = gpio_request_one(usb_power, GPIOF_OUT_INIT_HIGH, "usb_power");
  arch/mips/bcm63xx/boards/board_bcm963xx.c:              gpio_request_one(board.ephy_reset_gpio,
  arch/mips/txx9/rbtx4927/setup.c:        gpio_request(15, "sio-dtr");

Most of these should be easy enough to change to modern gpio descriptors or remove if they are no longer in use.

---
v2: no changes. There was no discussion on this, but the patch
has so far not made it into the linux-mips tree, so I'm including it for completeness.

Quoted 5 lines
---
 arch/mips/Kconfig         | 5 +++++
 arch/mips/alchemy/Kconfig | 1 -
 arch/mips/txx9/Kconfig    | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)

applied to mips-next

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#21 lore raw

PATCH v4 6/10 leds: gpio: make legacy gpiolib interface optional

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

---
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

Related to this, we may also want to remove support for passing a gpio descriptor in the ->gpiod flag. The only user doing this at the moment was introduced in commit 1892e87a3e91 ("powerpc/warp:
switch to using gpiod API").

---
 drivers/leds/leds-gpio.c | 51 ++++++++++++++++++++++++++--------------
 include/linux/leds.h     |  2 ++
 2 files changed, 36 insertions(+), 17 deletions(-)
drivers/leds/leds-gpio.c +34 -17
index a3428b22de3a..d6a0369eeb92 100644
@@ -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;
 			}
 
include/linux/leds.h +2 -0
index b16b803cc1ac..e646bffcd8e7 100644
@@ -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;
Signature · 1 line
2.39.5
#22 lore raw

PATCH v6 7/10 dt-bindings: net: add st,stlc4560/p54spi binding

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The SPI version of Prism54 was sold under a couple of different names and supported by the Linux p54spi driver, but there was never a DT binding for it.

Document the four known names of this device and the properties that are sufficient for its use on the Nokia N8x0 tablet.

As I don't have this hardware or documentation for it, this is purely based on existing usage in the driver.

---
v6: no changes
v5: fix name in MAINTAINERS file
v4: renamed file to st,stlc4560, matching the primary compatible string
require st,stlc4560 string

---
 .../bindings/net/wireless/st,stlc4560.yaml    | 61 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 62 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml new file +61 -0
new file mode 100644
index 000000000000..a32265c07350
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/wireless/st,stlc4560.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ST/Intersil/Conexant stlc45xx/p54spi/cx3110x SPI wireless device
+
+maintainers:
+  - Christian Lamparter <[email protected]>
+
+description:
+  The SPI variant of the Intersil Prism54 wireless device was sold
+  under a variety of names, including Conexant CX3110x and
+  ST Microelectronics STLC4560.
+
+allOf:
+  - $ref: ieee80211.yaml#
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+properties:
+  compatible:
+    oneOf:
+      - const: st,stlc4560
+      - items:
+          - enum:
+              - cnxt,3110x
+              - isil,p54spi
+              - st,stlc4550
+          - const: st,stlc4560
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  powerdown-gpios:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        wifi@0 {
+            compatible = "st,stlc4560";
+            reg = <0>;
+            spi-max-frequency = <48000000>;
+            interrupts-extended = <&gpio 23>;
+            powerdown-gpios = <&gpio 1>;
+        };
+    };
MAINTAINERS +1 -0
index 8063cb56feef..93cf1fb72357 100644
@@ -20306,6 +20306,7 @@ M:	Christian Lamparter <[email protected]>
 L:	[email protected]
 S:	Maintained
 W:	https://wireless.wiki.kernel.org/en/users/Drivers/p54
+F:	Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml
 F:	drivers/net/wireless/intersil/
 
 PACKET SOCKETS
Signature · 1 line
2.39.5
maintainer Reviewed-by on v6 7/10
#23 lore raw

Re: [PATCH 07/10] [v6 net-next] dt-bindings: net: add st,stlc4560/p54spi binding

Quoted 12 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The SPI version of Prism54 was sold under a couple of different names and supported by the Linux p54spi driver, but there was never a DT binding for it.

Document the four known names of this device and the properties that are sufficient for its use on the Nokia N8x0 tablet.

As I don't have this hardware or documentation for it, this is purely based on existing usage in the driver.

Quoted 6 lines

---

#24 lore raw

PATCH v6 8/10 p54spi: convert to devicetree

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The Prism54 SPI driver hardcodes GPIO numbers and expects users to pass them as module parameters, apparently a relic from its life as a staging driver. This works because there is only one user, the Nokia N8x0 tablet.

Convert this to the gpio descriptor interface and DT based probing to improve this and simplify the code at the same time.

---
v6:
- no changes. Sashiko comments about incorrect on-stack SPI transfers and error handling in the IRQ registration turned out to be irrelevant for this submission.

v5:
- fix irq assignment # https://sashiko.dev/#/patchset/20260430081242.3686993-1-arnd%40kernel.org

v4:
- make gpio line optional again
- fix EPROBE_DEFER handling
- match only st,stlc4560 compatible value, with binding change

v3:
- rebase an older patch

---
 arch/arm/mach-omap2/board-n8x0.c           | 18 ------
 drivers/net/wireless/intersil/p54/p54spi.c | 67 ++++++++--------------
 drivers/net/wireless/intersil/p54/p54spi.h |  3 +
 3 files changed, 26 insertions(+), 62 deletions(-)
arch/arm/mach-omap2/board-n8x0.c +0 -18
index 969265d5d5c6..d9acd32c5457 100644
@@ -20,7 +20,6 @@
 #include <linux/spi/spi.h>
 #include <linux/usb/musb.h>
 #include <linux/mmc/host.h>
-#include <linux/platform_data/spi-omap2-mcspi.h>
 #include <linux/platform_data/mmc-omap.h>
 #include <linux/mfd/menelaus.h>
 
@@ -106,21 +105,6 @@ static void __init n8x0_usb_init(void) {}
 
 #endif /*CONFIG_USB_MUSB_TUSB6010 */
 
-
-static struct omap2_mcspi_device_config p54spi_mcspi_config = {
-	.turbo_mode	= 0,
-};
-
-static struct spi_board_info n800_spi_board_info[] __initdata = {
-	{
-		.modalias	= "p54spi",
-		.bus_num	= 2,
-		.chip_select	= 0,
-		.max_speed_hz   = 48000000,
-		.controller_data = &p54spi_mcspi_config,
-	},
-};
-
 #if defined(CONFIG_MENELAUS) && IS_ENABLED(CONFIG_MMC_OMAP)
 
 /*
@@ -524,7 +508,5 @@ omap_late_initcall(n8x0_late_initcall);
 void * __init n8x0_legacy_init(void)
 {
 	board_check_revision();
-	spi_register_board_info(n800_spi_board_info,
-				ARRAY_SIZE(n800_spi_board_info));
 	return &mmc1_data;
 }
drivers/net/wireless/intersil/p54/p54spi.c +23 -44

131 lines not on this page · raw message

drivers/net/wireless/intersil/p54/p54spi.h +3 -0
index e5619a13fd61..118785cc635a 100644
@@ -107,6 +107,9 @@ struct p54s_priv {
 
 	enum fw_state fw_state;
 	const struct firmware *firmware;
+
+	struct gpio_desc *gpio_powerdown;
+	int irq;
 };
 
 #endif /* P54SPI_H */
Signature · 1 line
2.39.5
#25 lore raw

Re: [PATCH 08/10] [v6 net-next] p54spi: convert to devicetree

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] SPI transfers are using stack-allocated buffers for tx_buf and rx_buf, violating the SPI subsystem's DMA requirements. --

commit 8ba2b2da7516b867a52706d993b9ce2d49c99105
Author: Arnd Bergmann <[email protected]>

p54spi: convert to devicetree

The Prism54 SPI driver hardcodes GPIO numbers and expects users to pass them as module parameters, apparently a relic from its life as a staging driver. This works because there is only one user, the Nokia N8x0 tablet.

Convert this to the gpio descriptor interface and DT based probing to improve this and simplify the code at the same time.

Quoted 4 lines
drivers/net/wireless/intersil/p54/p54spi.c +0 -0
index 9d66dcae54e02..d18be25450285 100644

[ ... ]

Quoted 10 lines
drivers/net/wireless/intersil/p54/p54spi.c +0 -6
@@ -30,19 +31,6 @@
 MODULE_FIRMWARE("3826.arm");
 MODULE_FIRMWARE("3826.eeprom");
 
-/* gpios should be handled in board files and provided via platform data,
- * but because it's currently impossible for p54spi to have a header file
- * in include/linux, let's use module parameters for now
- */
-
-static int p54spi_gpio_power = 97;

drivers/net/wireless/intersil/p54/p54spi.c line 36

Quoted 10 lines
drivers/net/wireless/intersil/p54/p54spi.c +0 -7
-module_param(p54spi_gpio_power, int, 0444);
-MODULE_PARM_DESC(p54spi_gpio_power, "gpio number for power line");
-
-static int p54spi_gpio_irq = 87;
-module_param(p54spi_gpio_irq, int, 0444);
-MODULE_PARM_DESC(p54spi_gpio_irq, "gpio number for irq line");
-
 static void p54spi_spi_read(struct p54s_priv *priv, u8 address,
 			      void *buf, size_t len)
 {

[Severity: High]
This isn't a bug introduced by this patch, but does this code use stack-allocated buffers for SPI transfers?

It appears that p54spi_spi_read() and other similar functions pass stack variables (e.g., addr in p54spi_spi_read(), rx_head in p54spi_rx(), and val in p54spi_read32()) directly into spi_sync() as tx_buf and rx_buf.

If the underlying SPI controller uses DMA, the SPI core maps these buffers. Using stack memory for DMA is unsafe because, with options like CONFIG_VMAP_STACK enabled, the stack may not be physically contiguous.

Even without it, stack DMA leads to cache-line sharing and incoherency, which can result in severe memory corruption or kernel panics.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
#26 lore raw

PATCH v6 9/10 ARM: dts: omap2: add stlc4560 spi-wireless node

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Converted from the platform_device creation in board-n8x0.c.

---
v6: no changes
v1 through v5: adaptations that correspond to the binding updates

---
 arch/arm/boot/dts/ti/omap/omap2.dtsi                |  4 ++++
 arch/arm/boot/dts/ti/omap/omap2420-n8x0-common.dtsi | 12 ++++++++++++
 2 files changed, 16 insertions(+)
arch/arm/boot/dts/ti/omap/omap2.dtsi +4 -0
index afabb36a8ac1..fdc1790adf43 100644
@@ -129,6 +129,8 @@ i2c2: i2c@48072000 {
 		};
 
 		mcspi1: spi@48098000 {
+			#address-cells = <1>;
+			#size-cells = <0>;
 			compatible = "ti,omap2-mcspi";
 			ti,hwmods = "mcspi1";
 			reg = <0x48098000 0x100>;
@@ -140,6 +142,8 @@ mcspi1: spi@48098000 {
 		};
 
 		mcspi2: spi@4809a000 {
+			#address-cells = <1>;
+			#size-cells = <0>;
 			compatible = "ti,omap2-mcspi";
 			ti,hwmods = "mcspi2";
 			reg = <0x4809a000 0x100>;
arch/arm/boot/dts/ti/omap/omap2420-n8x0-common.dtsi +12 -0
index 63b0b4921e4e..fe9dd8bbfc85 100644
@@ -109,3 +109,15 @@ partition@5 {
 		};
 	};
 };
+
+&mcspi2 {
+	status = "okay";
+
+	wifi@0 {
+		reg = <0>;
+		compatible = "st,stlc4560";
+		spi-max-frequency = <48000000>;
+		interrupts-extended = <&gpio3 23 IRQ_TYPE_EDGE_RISING>;
+		powerdown-gpios = <&gpio4 1 GPIO_ACTIVE_LOW>; /* gpio 97 */
+	};
+};
Signature · 1 line
2.39.5
maintainer
#27 lore raw

Re: [PATCH 09/10] [v6 omap] ARM: dts: omap2: add stlc4560 spi-wireless node

Quoted 2 lines · Arnd Bergmann

v1 through v5: adaptations that correspond to the binding updates

FWIW, I had just applied v5 of these three patches today, but didn't send out a pull request yet. I'll do that tomorrow morning.

johannes

maintainer Reviewed-by on v6 9/10
#28 lore raw

Re: [PATCH 09/10] [v6 omap] ARM: dts: omap2: add stlc4560 spi-wireless node

In reply to Arnd Bergmann
Quoted 8 lines · On Wed, 20 May 2026 20:38:14 +0200 Arnd Bergmann <[email protected]> wrote:

From: Arnd Bergmann <[email protected]>

Converted from the platform_device creation in board-n8x0.c.

Quoted 8 lines

---
v6: no changes
v1 through v5: adaptations that correspond to the binding updates

---
 arch/arm/boot/dts/ti/omap/omap2.dtsi                |  4 ++++
 arch/arm/boot/dts/ti/omap/omap2420-n8x0-common.dtsi | 12 ++++++++++++
 2 files changed, 16 insertions(+)
#29 lore raw

PATCH v2 10/10 gpiolib: turn off legacy interface by default

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

---
 drivers/gpio/Kconfig | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

This patch depends on patches 1 through 9 to be applied first.

drivers/gpio/Kconfig +8 -1
index 00fcab5d09a4..eec17089eaa6 100644
@@ -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
Signature · 1 line
2.39.5
#30 lore raw

Re: [PATCH 10/10] gpiolib: turn off legacy interface by default

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Turning off `CONFIG_GPIOLIB_LEGACY` by default will break the build for multiple architectures and…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Turning off CONFIG_GPIOLIB_LEGACY by default will break the build for multiple architectures and platforms that still rely on the legacy GPIO interface but do not select CONFIG_GPIOLIB_LEGACY. --

commit a920fbf61a1d127c3a98b41cb32f7260acd5657b
Author: Arnd Bergmann <[email protected]>

gpiolib: turn off legacy interface by default

This commit removes the default enablement of GPIOLIB_LEGACY, requiring platforms to explicitly select it if they still use the legacy interface. It also adds a prompt to enable it manually for compile testing.

Quoted 3 lines

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: Low]
Is this statement accurate? There appear to be platforms like ARM PXA (arch/arm/mach-pxa/spitz_pm.c), ARM Orion5x, and m68k Coldfire that still contain direct calls to legacy GPIO functions like gpio_request() but do not select GPIOLIB_LEGACY in their Kconfig files.

drivers/gpio/Kconfig line 7

Quoted 9 lines
drivers/gpio/Kconfig +0 -1
index 020e51e30317a..543de15a12f63 100644
@@ -4,7 +4,14 @@
 #
 
 config GPIOLIB_LEGACY
-	def_bool y

[Severity: Low]
Will removing this default cause build regressions for the unconverted platforms mentioned above?

It seems the legacy function declarations in include/linux/gpio.h will be hidden, leading to implicit declaration errors when compiling those architectures.

Quoted 1 line
drivers/gpio/Kconfig +1 -0
+	bool "Legacy GPIO interfaces" if COMPILE_TEST

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
maintainer Applied
#31 lore raw

Re: (subset) [PATCH v2 00/10] gpiolib: fence off legacy interfaces

In reply to Arnd Bergmann
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

This is an update of all the patches that are still required before we can actually turn off CONFIG_GPIOLIB_LEGACY for most platforms in the final patch of this series.

I originally posted this as a series in
https://lore.kernel.org/all/[email protected]/

[...]

Applied, thanks!

[09/10] ARM: dts: omap2: add stlc4560 spi-wireless node

        commit: c5a0ac76b364bbd1d4fb7e440edabcd2a369343c

Best regards,

Signature · 1 line
Kevin Hilman (TI) <[email protected]>