Skip to contentSkip to conversation

gpiolib: finish the legacy cleanup

PATCH In review Arnd Bergmann 4 participants 8 messages Nov 23

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v8 cover gpiolib: finish the legacy cleanup

From: Arnd Bergmann <[email protected]>

These two patches are left from my cleanup series, finishing off the work to turn off CONFIG_GPIOLIB_LEGACY by default, and removing the include/linux/gpio.h header.

This was planned for 7.3 originally[1], but kept conflicting with ongoing cleanups for the broken rsk7203 board. I've skipped the oneline rsk change now, which will be fixed properly by Dmitry's patch [2].

Arnd

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Arnd Bergmann (2):
[v8] gpiolib: turn off legacy interface by default [v8] gpiolib: remove linux/gpio.h

 MAINTAINERS                                  |  1 -
 arch/mips/txx9/rbtx4927/setup.c              |  2 +-
 drivers/gpio/Kconfig                         |  9 +++++++-
 drivers/gpio/TODO                            |  4 +---
 drivers/gpio/gpiolib-cdev.c                  |  2 +-
 drivers/gpio/gpiolib-legacy.c                |  3 +--
 drivers/gpio/gpiolib.c                       |  2 +-
 drivers/net/wireless/morsemicro/mm81x/hw.c   |  1 -
 drivers/net/wireless/morsemicro/mm81x/yaps.c |  1 -
 include/linux/gpio.h                         | 22 --------------------
 10 files changed, 13 insertions(+), 34 deletions(-)
 delete mode 100644 include/linux/gpio.h
Signature · 14 lines
2.53.0

Cc: Bartosz Golaszewski <[email protected]>
Cc: Dmitry Torokhov <[email protected]>
Cc: Johannes Berg <[email protected]>
Cc: John Paul Adrian Glaubitz <[email protected]>
Cc: Kent Gibson <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
#1 lore raw

PATCH v8 1/2 gpiolib: turn off legacy interface by default

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(-)
drivers/gpio/Kconfig +8 -1
index 9db764a3bcfd..56b5553b51de 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.53.0
#2 lore raw

PATCH v8 2/2 gpiolib: remove linux/gpio.h

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

After all other drivers have converted to linux/gpio/consumer.h or linux/gpio/legacy.h, remove the final leftover bits here.

---
 MAINTAINERS                                  |  1 -
 arch/mips/txx9/rbtx4927/setup.c              |  2 +-
 drivers/gpio/TODO                            |  4 +---
 drivers/gpio/gpiolib-cdev.c                  |  2 +-
 drivers/gpio/gpiolib-legacy.c                |  3 +--
 drivers/gpio/gpiolib.c                       |  2 +-
 drivers/net/wireless/morsemicro/mm81x/hw.c   |  1 -
 drivers/net/wireless/morsemicro/mm81x/yaps.c |  1 -
 include/linux/gpio.h                         | 22 --------------------
 9 files changed, 5 insertions(+), 33 deletions(-)
 delete mode 100644 include/linux/gpio.h
MAINTAINERS +0 -1
index 829c795c13b3..7efa1e6446a7 100644
@@ -11589,7 +11589,6 @@ F:	Documentation/devicetree/bindings/gpio/
 F:	Documentation/driver-api/gpio/
 F:	drivers/gpio/
 F:	include/dt-bindings/gpio/
-F:	include/linux/gpio.h
 F:	include/linux/gpio/
 K:	(devm_)?gpio_(request|free|direction|get|set)
 K:	GPIOD_FLAGS_BIT_NONEXCLUSIVE
arch/mips/txx9/rbtx4927/setup.c +1 -1
index 223889c03186..fdbe2bd87979 100644
@@ -48,7 +48,7 @@
 #include <linux/ioport.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio/machine.h>
 #include <linux/leds.h>
 #include <asm/io.h>
drivers/gpio/TODO +1 -3
index 7ce80fde1f17..4fce4a7e4704 100644
@@ -52,9 +52,7 @@ Work items:
   base can be made dynamic (set to -1) if CONFIG_GPIO_SYSFS is disabled.
 
 - When this work is complete (will require some of the items in the
-  following ongoing work as well) we can delete the old global
-  numberspace accessors from <linux/gpio.h> and eventually delete
-  <linux/gpio.h> altogether.
+  following ongoing work as well) we can delete <linux/gpio/legacy.h>.
 
 -------------------------------------------------------------------------------
 
drivers/gpio/gpiolib-cdev.c +1 -1
index d877f2de506c..795f7df5b540 100644
@@ -11,7 +11,7 @@
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/file.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/hte.h>
 #include <linux/interrupt.h>
drivers/gpio/gpiolib-legacy.c +1 -2
index c2b04605b203..a841208dc19a 100644
@@ -7,8 +7,7 @@
 
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
-
-#include <linux/gpio.h>
+#include <linux/gpio/legacy.h>
 
 #include "gpiolib.h"
 
drivers/gpio/gpiolib.c +1 -1
index c09342fc52cb..c16d69761e04 100644
@@ -30,7 +30,7 @@
 #include <linux/string_choices.h>
 #include <linux/workqueue.h>
 
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/gpio/machine.h>
 
drivers/net/wireless/morsemicro/mm81x/hw.c +0 -1
index 9293f4094db1..e48eaf151faa 100644
@@ -7,7 +7,6 @@
 #include <linux/stringify.h>
 #include <linux/types.h>
 #include <linux/unaligned.h>
-#include <linux/gpio.h>
 #include "hif.h"
 #include "mac.h"
 #include "bus.h"
drivers/net/wireless/morsemicro/mm81x/yaps.c +0 -1
index 2d1728c1a6de..a843c1c16216 100644
@@ -2,7 +2,6 @@
 /*
  * Copyright (c) 2017-2026 Morse Micro
  */
-#include <linux/gpio.h>
 #include <linux/random.h>
 #include <linux/timer.h>
 #include <linux/bitops.h>
include/linux/gpio.h deleted +0 -22
deleted file mode 100644
index b0d4942a65de..000000000000
@@ -1,22 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * NOTE: This header *must not* be included.
- *
- * If you're implementing a GPIO driver, only include <linux/gpio/driver.h>
- * If you're implementing a GPIO consumer, only include <linux/gpio/consumer.h>
- * If you're using the legacy interfaces, include <linux/gpio/legacy.h>
- */
-
-#ifndef __LINUX_GPIO_H
-#define __LINUX_GPIO_H
-
-#include <linux/types.h>
-#ifdef CONFIG_GPIOLIB
-#include <linux/gpio/consumer.h>
-#endif
-
-#ifdef CONFIG_GPIOLIB_LEGACY
-#include <linux/gpio/legacy.h>
-#endif /* CONFIG_GPIOLIB_LEGACY */
-
-#endif /* __LINUX_GPIO_H */
Signature · 1 line
2.53.0
#3 lore raw

Re: [PATCH 2/2] [v8] gpiolib: remove linux/gpio.h

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] gpiolib: build failure in rsk7203_devices_setup() after removing linux/gpio.h --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] gpiolib: build failure in rsk7203_devices_setup() after removing linux/gpio.h
--

commit 29b33c0e6261ed7e945f5222da273adda4c798f3
Author: Arnd Bergmann <[email protected]>

gpiolib: remove linux/gpio.h

This commit removes the remaining includes of <linux/gpio.h> in gpiolib, rbtx4927, and mm81x, and deletes include/linux/gpio.h.

Quoted 18 lines
include/linux/gpio.h deleted +0 -12
deleted file mode 100644
index b0d4942a65de2..0000000000000
@@ -1,22 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * NOTE: This header *must not* be included.
- *
- * If you're implementing a GPIO driver, only include <linux/gpio/driver.h>
- * If you're implementing a GPIO consumer, only include <linux/gpio/consumer.h>
- * If you're using the legacy interfaces, include <linux/gpio/legacy.h>
- */
-
-#ifndef __LINUX_GPIO_H
-#define __LINUX_GPIO_H
-

include/linux/gpio.h line 22

Quoted 10 lines
include/linux/gpio.h deleted +0 -10
-#include <linux/types.h>
-#ifdef CONFIG_GPIOLIB
-#include <linux/gpio/consumer.h>
-#endif
-
-#ifdef CONFIG_GPIOLIB_LEGACY
-#include <linux/gpio/legacy.h>
-#endif /* CONFIG_GPIOLIB_LEGACY */
-
-#endif /* __LINUX_GPIO_H */

[Severity: High]
Does removing include/linux/gpio.h break the build for arch/sh/boards/mach-rsk/devices-rsk7203.c (CONFIG_SH_RSK7203)?

That file still includes <linux/gpio.h>, which now resolves to include/uapi/linux/gpio.h without pulling in <linux/gpio/legacy.h>, leaving gpio_request() undeclared in rsk7203_devices_setup():

arch/sh/boards/mach-rsk/devices-rsk7203.c:rsk7203_devices_setup() {
    ...
	/* Select pins for SCIF0 */
	gpio_request(GPIO_FN_TXD0, NULL);
	gpio_request(GPIO_FN_RXD0, NULL);
    ...
}

Should arch/sh/boards/mach-rsk/devices-rsk7203.c be updated to include <linux/gpio/legacy.h>?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#4 lore raw
In reply to Arnd Bergmann
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

These two patches are left from my cleanup series, finishing off the work to turn off CONFIG_GPIOLIB_LEGACY by default, and removing the include/linux/gpio.h header.

This was planned for 7.3 originally[1], but kept conflicting with ongoing cleanups for the broken rsk7203 board. I've skipped the oneline rsk change now, which will be fixed properly by Dmitry's patch [2].

What is the base commit? It doesn't apply on top of linux-next.

Bart

#5 lore raw
Quoted 7 lines · Bartosz Golaszewski
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

These two patches are left from my cleanup series, finishing off the work to turn off CONFIG_GPIOLIB_LEGACY by default, and removing the include/linux/gpio.h header.

Quoted 7 lines
Quoted 4 lines

This was planned for 7.3 originally[1], but kept conflicting with ongoing cleanups for the broken rsk7203 board. I've skipped the oneline rsk change now, which will be fixed properly by Dmitry's patch [2].

What is the base commit? It doesn't apply on top of linux-next.

Scratch that, PEBKAC.

Sashiko is right:

CC arch/sh/boards/mach-rsk/devices-rsk7203.o
arch/sh/boards/mach-rsk/devices-rsk7203.c: In function ‘rsk7203_devices_setup’:
arch/sh/boards/mach-rsk/devices-rsk7203.c:127:9: error: implicit declaration of function ‘gpio_request’; did you mean ‘symbol_request’? [-Wimplicit-function-declaration]

  127 |         gpio_request(GPIO_FN_TXD0, NULL);
      |         ^~~~~~~~~~~~
      |         symbol_request

make[5]: *** [scripts/Makefile.build:321: arch/sh/boards/mach-rsk/devices-rsk7203.o] Error 1 make[4]: *** [scripts/Makefile.build:606: arch/sh/boards/mach-rsk] Error 2 make[3]: *** [scripts/Makefile.build:606: arch/sh/boards] Error 2
make[2]: *** [scripts/Makefile.build:606: arch/sh] Error 2
make[1]: *** [/home/brgl/workspace/linux/Makefile:2257: .] Error 2

Bart

#6 lore raw
Quoted 16 lines · Bartosz Golaszewski
Quoted 7 lines · Bartosz Golaszewski
Quoted 5 lines · Arnd Bergmann

This was planned for 7.3 originally[1], but kept conflicting with ongoing cleanups for the broken rsk7203 board. I've skipped the oneline rsk change now, which will be fixed properly by Dmitry's patch [2].

Sashiko is right:

CC arch/sh/boards/mach-rsk/devices-rsk7203.o
arch/sh/boards/mach-rsk/devices-rsk7203.c: In function ‘rsk7203_devices_setup’:
arch/sh/boards/mach-rsk/devices-rsk7203.c:127:9: error: implicit declaration of function ‘gpio_request’; did you mean ‘symbol_request’? [-Wimplicit-function-declaration]

Quoted 3 lines
  127 |         gpio_request(GPIO_FN_TXD0, NULL);
      |         ^~~~~~~~~~~~
      |         symbol_request

Yes, this just seemed the easiest way out to avoid clashing with Dmitry's patches again. If you want the version that doesn't break the build, you can still apply v7 [1], but that likely means his series has go through another revision to undo my change and remove the linux/gpio/legacy.h inclusion.

Arnd

[1] https://lore.kernel.org/all/[email protected]/

#7 lore raw
Quoted 21 lines · Arnd Bergmann
Quoted 16 lines · Bartosz Golaszewski
Quoted 7 lines · Bartosz Golaszewski
Quoted 5 lines · Arnd Bergmann

This was planned for 7.3 originally[1], but kept conflicting with ongoing cleanups for the broken rsk7203 board. I've skipped the oneline rsk change now, which will be fixed properly by Dmitry's patch [2].

Sashiko is right:

CC arch/sh/boards/mach-rsk/devices-rsk7203.o
arch/sh/boards/mach-rsk/devices-rsk7203.c: In function ‘rsk7203_devices_setup’:
arch/sh/boards/mach-rsk/devices-rsk7203.c:127:9: error: implicit declaration of function ‘gpio_request’; did you mean ‘symbol_request’? [-Wimplicit-function-declaration]

Quoted 3 lines
  127 |         gpio_request(GPIO_FN_TXD0, NULL);
      |         ^~~~~~~~~~~~
      |         symbol_request
Quoted 6 lines

Yes, this just seemed the easiest way out to avoid clashing with Dmitry's patches again. If you want the version that doesn't break the build, you can still apply v7 [1], but that likely means his series has go through another revision to undo my change and remove the linux/gpio/legacy.h inclusion.

Can I apply v7 and provide it to the SH maintainers on an immutable branch?

Bart