gpiolib: fence off legacy interfaces
Subsystems (30)
cover gpiolib: fence off legacy interfaces
From: Arnd Bergmann <[email protected]>
Commit 678bae2eaa81 ("gpiolib: make legacy interfaces optional") was merged for linux-6.17, so now it is possible to use the legacy interfaces conditionally and eventually have the support left out of the kernel whenever it is not needed.
I created six patches to force-enable CONFIG_GPIOLIB_LEGACY on the few (mostly ancient) platforms that still require this, plus a set of patches to either add the corresponding Kconfig dependencies that make the device drivers conditional on that symbol, or change them to no longer require it.
The final patch ends up turning the Kconfig symbol off by default, which of course depends on everything else getting merged first to avoid build errors.
I would suggest that patches 1-20 can just get merged through the respective maintainer trees independently when they are deemed ready, and the final patch can wait another merge window.
Arnd
Arnd Bergmann (21):
ARM: select legacy gpiolib interfaces where used
m68k: coldfire: select legacy gpiolib interface for mcfqspi
mips: select legacy gpiolib interfaces where used
sh: select legacy gpiolib interface
x86/platform: select legacy gpiolib interfaces where used x86/olpc: select GPIOLIB_LEGACY
mfd: wm8994: remove dead legacy-gpio code
ASoC: add GPIOLIB_LEGACY dependency where needed
input: gpio-keys: make legacy gpiolib optional
leds: gpio: make legacy gpiolib interface optional
media: em28xx: add special case for legacy gpiolib interface
mfd: arizona: make legacy gpiolib interface optional
mfd: si476x: add GPIOLIB_LEGACY dependency
mfd: aat2870: add GPIOLIB_LEGACY dependency
dsa: b53: hide legacy gpiolib usage on non-mips
ath10k: remove gpio number assignment
nfc: marvell: convert to gpio descriptors
nfc: s3fwrn5: convert to gpio descriptors
usb: udc: pxa: remove unused platform_data
ASoC: pxa: add GPIOLIB_LEGACY dependency
gpiolib: turn off legacy interface by default
arch/arm/mach-mv78xx0/Kconfig | 1 + arch/arm/mach-orion5x/Kconfig | 1 + arch/arm/mach-pxa/Kconfig | 1 + arch/arm/mach-pxa/devices.c | 7 -- arch/arm/mach-pxa/gumstix.c | 1 - arch/arm/mach-pxa/udc.h | 8 -- arch/arm/mach-s3c/Kconfig.s3c64xx | 1 + arch/arm/mach-sa1100/Kconfig | 1 + arch/m68k/Kconfig.cpu | 1 + 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 | 11 ++- drivers/input/keyboard/gpio_keys.c | 5 +- drivers/input/keyboard/gpio_keys_polled.c | 2 + drivers/input/misc/Kconfig | 3 + drivers/leds/leds-gpio.c | 8 +- drivers/media/usb/em28xx/Kconfig | 1 + drivers/media/usb/em28xx/em28xx-dvb.c | 4 +- drivers/mfd/Kconfig | 2 + drivers/mfd/arizona-irq.c | 5 +- drivers/mfd/rohm-bd71828.c | 2 + drivers/mfd/rohm-bd718x7.c | 2 + drivers/mfd/wm8994-irq.c | 94 +------------------ drivers/net/dsa/b53/b53_common.c | 17 +--- drivers/net/dsa/b53/b53_priv.h | 24 +++-- drivers/net/wireless/ath/ath10k/leds.c | 3 +- drivers/nfc/nfcmrvl/main.c | 47 +++------- drivers/nfc/nfcmrvl/nfcmrvl.h | 5 +- drivers/nfc/nfcmrvl/uart.c | 5 - drivers/nfc/nfcmrvl/usb.c | 1 - drivers/nfc/s3fwrn5/i2c.c | 42 +++------ drivers/nfc/s3fwrn5/phy_common.c | 12 +-- drivers/nfc/s3fwrn5/phy_common.h | 4 +- drivers/nfc/s3fwrn5/uart.c | 30 ++---- drivers/platform/x86/Kconfig | 3 + .../platform/x86/x86-android-tablets/Kconfig | 1 + drivers/usb/gadget/udc/pxa25x_udc.c | 41 +++----- drivers/usb/gadget/udc/pxa25x_udc.h | 2 +- drivers/usb/gadget/udc/pxa27x_udc.c | 35 +------ drivers/usb/gadget/udc/pxa27x_udc.h | 2 - include/linux/gpio_keys.h | 2 + include/linux/leds.h | 2 + include/linux/mfd/arizona/pdata.h | 6 ++ include/linux/mfd/wm8994/pdata.h | 5 - include/linux/platform_data/pxa2xx_udc.h | 15 --- sound/pci/Kconfig | 1 + sound/soc/codecs/Kconfig | 4 + sound/soc/codecs/arizona-jack.c | 17 +++- sound/soc/pxa/Kconfig | 4 +- 55 files changed, 192 insertions(+), 320 deletions(-) delete mode 100644 arch/arm/mach-pxa/udc.h
Signature · 58 lines
2.39.5 Cc: Linus Walleij <[email protected]> (maintainer:GPIO SUBSYSTEM,commit_signer:1/2=50%) Cc: Bartosz Golaszewski <[email protected]> (maintainer:GPIO SUBSYSTEM,commit_signer:1/7=14%,commit_signer:1/2=50%) Cc: [email protected] (open list:GPIO SUBSYSTEM) Cc: Andrew Lunn <[email protected]> (maintainer:ARM/Marvell Dove/MV78xx0/Orion SOC support) Cc: Sebastian Hesselbarth <[email protected]> (maintainer:ARM/Marvell Dove/MV78xx0/Orion SOC support) Cc: Gregory Clement <[email protected]> (maintainer:ARM/Marvell Dove/MV78xx0/Orion SOC support) Cc: Russell King <[email protected]> (maintainer:ARM PORT) Cc: Daniel Mack <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT) Cc: Haojian Zhuang <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT) Cc: Robert Jarzmik <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT) Cc: Krzysztof Kozlowski <[email protected]> (maintainer:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES,commit_signer:1/2=50%) Cc: Alim Akhtar <[email protected]> (reviewer:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES) Cc: Geert Uytterhoeven <[email protected]> (maintainer:M68K ARCHITECTURE,commit_signer:1/4=25%,authored:1/4=25%,added_lines:2/13=15%,removed_lines:2/6=33%) Cc: Thomas Bogendoerfer <[email protected]> (maintainer:MIPS) Cc: Yoshinori Sato <[email protected]> (maintainer:SUPERH) Cc: Rich Felker <[email protected]> (maintainer:SUPERH) Cc: John Paul Adrian Glaubitz <[email protected]> (maintainer:SUPERH,commit_signer:2/4=50%) Cc: Thomas Gleixner <[email protected]> (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),added_lines:4/36=11%,removed_lines:6/49=12%) Cc: Ingo Molnar <[email protected]> (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)) Cc: Borislav Petkov <[email protected]> (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)) Cc: Dave Hansen <[email protected]> (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)) Cc: [email protected] (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)) Cc: "H. Peter Anvin" <[email protected]> (reviewer:X86 ARCHITECTURE (32-BIT AND 64-BIT)) Cc: Dmitry Torokhov <[email protected]> (maintainer:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...,commit_signer:5/7=71%,authored:1/7=14%,added_lines:17/36=47%,removed_lines:27/49=55%,commit_signer:1/2=50%,commit_signer:3/5=60%) Cc: Lee Jones <[email protected]> (maintainer:LED SUBSYSTEM,commit_signer:2/5=40%) Cc: Pavel Machek <[email protected]> (maintainer:LED SUBSYSTEM) Cc: Mauro Carvalho Chehab <[email protected]> (maintainer:EM28XX VIDEO4LINUX DRIVER) Cc: Matti Vaittinen <[email protected]> (maintainer:ROHM POWER MANAGEMENT IC DEVICE DRIVERS) Cc: Florian Fainelli <[email protected]> (maintainer:BROADCOM B53/SF2 ETHERNET SWITCH DRIVER) Cc: Jeff Johnson <[email protected]> (maintainer:QUALCOMM ATHEROS ATH10K WIRELESS DRIVER) Cc: Hans de Goede <[email protected]> (maintainer:X86 PLATFORM DRIVERS,commit_signer:1/7=14%) Cc: "Ilpo Järvinen" <[email protected]> (maintainer:X86 PLATFORM DRIVERS) Cc: Greg Kroah-Hartman <[email protected]> (maintainer:USB SUBSYSTEM) Cc: Jaroslav Kysela <[email protected]> (maintainer:SOUND) Cc: Takashi Iwai <[email protected]> (maintainer:SOUND,commit_signer:1/3=33%,authored:1/3=33%,removed_lines:2/2=100%) Cc: Liam Girdwood <[email protected]> (maintainer:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...) Cc: Mark Brown <[email protected]> (maintainer:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,commit_signer:26/29=90%,commit_signer:1/3=33%) Cc: Andy Shevchenko <[email protected]> (authored:1/7=14%,added_lines:4/36=11%,removed_lines:6/49=12%,commit_signer:1/2=50%,authored:1/2=50%,added_lines:5/7=71%,removed_lines:7/7=100%,added_lines:7/7=100%,removed_lines:2/7=29%) Cc: "Dr. David Alan Gilbert" <[email protected]> (commit_signer:1/5=20%,authored:1/5=20%,removed_lines:7/10=70%) Cc: [email protected] (moderated list:ARM/Marvell Dove/MV78xx0/Orion SOC support) Cc: [email protected] (open list) Cc: [email protected] (open list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES) Cc: [email protected] (open list:M68K ARCHITECTURE) Cc: [email protected] (open list:MIPS) Cc: [email protected] (open list:SUPERH) Cc: [email protected] (open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...) Cc: [email protected] (open list:LED SUBSYSTEM) Cc: [email protected] (open list:EM28XX VIDEO4LINUX DRIVER) Cc: [email protected] (open list:WOLFSON MICROELECTRONICS DRIVERS) Cc: [email protected] (open list:BROADCOM B53/SF2 ETHERNET SWITCH DRIVER) Cc: [email protected] (open list:QUALCOMM ATHEROS ATH10K WIRELESS DRIVER) Cc: [email protected] (open list:QUALCOMM ATHEROS ATH10K WIRELESS DRIVER) Cc: [email protected] (open list:X86 PLATFORM DRIVERS) Cc: [email protected] (open list:USB SUBSYSTEM) Cc: [email protected] (open list:SOUND)
PATCH 1/21 ARM: select legacy gpiolib interfaces where used
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.
--- arch/arm/mach-mv78xx0/Kconfig | 1 + arch/arm/mach-orion5x/Kconfig | 1 + arch/arm/mach-pxa/Kconfig | 1 + arch/arm/mach-s3c/Kconfig.s3c64xx | 1 + arch/arm/mach-sa1100/Kconfig | 1 + 5 files changed, 5 insertions(+)
arch/arm/mach-mv78xx0/Kconfig +1 -0
@@ -6,6 +6,7 @@ menuconfig ARCH_MV78XX0 depends on ATAGS select CPU_FEROCEON select GPIOLIB + select GPIOLIB_LEGACY select MVEBU_MBUS select FORCE_PCI select PLAT_ORION_LEGACY
arch/arm/mach-orion5x/Kconfig +1 -0
@@ -5,6 +5,7 @@ menuconfig ARCH_ORION5X depends on CPU_LITTLE_ENDIAN select CPU_FEROCEON select GPIOLIB + select GPIOLIB_LEGACY select MVEBU_MBUS select FORCE_PCI select PCI_QUIRKS
arch/arm/mach-pxa/Kconfig +1 -0
@@ -10,6 +10,7 @@ menuconfig ARCH_PXA select CPU_XSCALE if !CPU_XSC3 select GPIO_PXA select GPIOLIB + select GPIOLIB_LEGACY select PLAT_PXA help Support for Intel/Marvell's PXA2xx/PXA3xx processor line.
arch/arm/mach-s3c/Kconfig.s3c64xx +1 -0
@@ -101,6 +101,7 @@ config MACH_WLF_CRAGG_6410 depends on ATAGS depends on I2C=y select CPU_S3C6410 + select GPIOLIB_LEGACY select LEDS_GPIO_REGISTER select S3C64XX_DEV_SPI0 select S3C64XX_SETUP_FB_24BPP
arch/arm/mach-sa1100/Kconfig +1 -0
@@ -13,6 +13,7 @@ menuconfig ARCH_SA1100 select CPU_FREQ select CPU_SA1100 select GPIOLIB + select GPIOLIB_LEGACY select IRQ_DOMAIN select ISA select NEED_MACH_MEMORY_H
Signature · 1 line
2.39.5
PATCH 2/21 m68k: coldfire: select legacy gpiolib interface for mcfqspi
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
The common coldfire code uses the old GPIO number based interfaces for at least the QSPI chipselect lines. Select the required Kconfig symbol to keep it building when that becomes optional.
Apparently there are no devices attached to a QSPI controller in any of the coldfire boards, so this is not actually used in upstream kernels.
--- arch/m68k/Kconfig.cpu | 1 + 1 file changed, 1 insertion(+)
arch/m68k/Kconfig.cpu +1 -0
@@ -30,6 +30,7 @@ config COLDFIRE select CPU_HAS_NO_MULDIV64 select GENERIC_CSUM select GPIOLIB + select GPIOLIB_LEGACY if SPI_COLDFIRE_QSPI select HAVE_LEGACY_CLK select HAVE_PAGE_SIZE_8KB if !MMU
Signature · 1 line
2.39.5
PATCH 3/21 mips: select legacy gpiolib interfaces where used
In reply to Arnd BergmannFrom: 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/board-mtx1.c: rc = gpio_request(mtx1_gpio_button[0].gpio, 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.
--- 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
@@ -205,6 +205,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
@@ -306,6 +308,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
@@ -329,6 +332,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
@@ -981,6 +985,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
@@ -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
@@ -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
PATCH 4/21 sh: select legacy gpiolib interface
In reply to Arnd BergmannFrom: 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.
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 5/21 x86/platform: select legacy gpiolib interfaces where used
In reply to Arnd BergmannFrom: 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.
--- drivers/input/misc/Kconfig | 3 +++ drivers/platform/x86/Kconfig | 3 +++ drivers/platform/x86/x86-android-tablets/Kconfig | 1 + 3 files changed, 7 insertions(+)
drivers/input/misc/Kconfig +3 -0
@@ -860,6 +860,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.
drivers/platform/x86/Kconfig +3 -0
@@ -309,6 +309,7 @@ config MERAKI_MX100 depends on GPIOLIB depends on GPIO_ICH depends on LEDS_CLASS + select GPIOLIB_LEGACY select LEDS_GPIO help This driver provides support for the front button and LEDs on
@@ -564,6 +565,7 @@ config PCENGINES_APU2 depends on INPUT && INPUT_KEYBOARD && GPIOLIB depends on LEDS_CLASS select GPIO_AMD_FCH + select GPIOLIB_LEGACY select KEYBOARD_GPIO_POLLED select LEDS_GPIO help
@@ -591,6 +593,7 @@ config PORTWELL_EC config BARCO_P50_GPIO tristate "Barco P50 GPIO driver for identify LED/button" depends on GPIOLIB + select GPIOLIB_LEGACY help This driver provides access to the GPIOs for the identify button and led present on Barco P50 board.
drivers/platform/x86/x86-android-tablets/Kconfig +1 -0
@@ -8,6 +8,7 @@ config X86_ANDROID_TABLETS depends on I2C && SPI && SERIAL_DEV_BUS depends on GPIOLIB && PMIC_OPREGION depends on ACPI && EFI && PCI + select GPIOLIB_LEGACY select NEW_LEDS select LEDS_CLASS select POWER_SUPPLY
Signature · 1 line
2.39.5
PATCH 6/21 x86/olpc: select GPIOLIB_LEGACY
In reply to Arnd BergmannFrom: 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);
Select CONFIG_GPIOLIB_LEGACY for this platform and make sure the sound driver portion cannot be compiled without this.
--- arch/x86/Kconfig | 1 + sound/pci/Kconfig | 1 + 2 files changed, 2 insertions(+)
arch/x86/Kconfig +1 -0
@@ -3006,6 +3006,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
@@ -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
PATCH 7/21 mfd: wm8994: remove dead legacy-gpio code
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
The old-style gpio handling in wm8994 came from a commit 7c8844481a1c ("mfd: wm8994: Emulate level triggered interrupts if required") in linux-3.11, but nothing in the kernel ever set the 'irq_gpio' member in the wm8994_pdata structure, so this was always dead code.
Remove it now to reduce the dependency on the legacy gpio interfaces.
--- drivers/mfd/wm8994-irq.c | 94 ++------------------------------ include/linux/mfd/wm8994/pdata.h | 5 -- 2 files changed, 4 insertions(+), 95 deletions(-)
drivers/mfd/wm8994-irq.c +4 -90
@@ -135,53 +135,9 @@ static const struct regmap_irq_chip wm8994_irq_chip = { .runtime_pm = true, }; -static void wm8994_edge_irq_enable (struct irq_data *data) -{ -} - -static void wm8994_edge_irq_disable (struct irq_data *data) -{ -} - -static struct irq_chip wm8994_edge_irq_chip = { - .name ="wm8994_edge" , - .irq_disable = wm8994_edge_irq_disable, - .irq_enable = wm8994_edge_irq_enable, -}; - -static irqreturn_t wm8994_edge_irq (int irq,void *data) -{ -struct wm8994 *wm8994 = data; - -while (gpio_get_value_cansleep (wm8994->pdata.irq_gpio)) -handle_nested_irq (irq_find_mapping (wm8994->edge_irq,0 )); - -return IRQ_HANDLED ; -} - -static int wm8994_edge_irq_map (struct irq_domain *h,unsigned int virq, -irq_hw_number_t hw) -{ -struct wm8994 *wm8994 = h->host_data; - -irq_set_chip_data (virq, wm8994); -irq_set_chip_and_handler (virq, &wm8994_edge_irq_chip, handle_edge_irq); -irq_set_nested_thread (virq,1 ); -irq_set_noprobe (virq); - -return 0 ; -} - -static const struct irq_domain_ops wm8994_edge_irq_ops = { - .map = wm8994_edge_irq_map, - .xlate = irq_domain_xlate_twocell, -}; -int wm8994_irq_init (struct wm8994 *wm8994) {int ret; -unsigned long irqflags; -struct wm8994_pdata *pdata = &wm8994->pdata;if (!wm8994->irq) { dev_warn(wm8994->dev,
@@ -190,53 +146,11 @@ int wm8994_irq_init(struct wm8994 *wm8994)return 0 ; } -/* select user or default irq flags */ - irqflags =IRQF_TRIGGER_HIGH |IRQF_ONESHOT ; -if (pdata->irq_flags) - irqflags = pdata->irq_flags; -/* use a GPIO for edge triggered controllers */ -if (irqflags & (IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING )) { -if (gpio_to_irq (pdata->irq_gpio) != wm8994->irq) { -dev_warn (wm8994->dev,"IRQ %d is not GPIO %d (%d)\n" , - wm8994->irq, pdata->irq_gpio, -gpio_to_irq (pdata->irq_gpio)); - wm8994->irq =gpio_to_irq (pdata->irq_gpio); - } - - ret =devm_gpio_request_one (wm8994->dev, pdata->irq_gpio, -GPIOF_IN ,"WM8994 IRQ" ); - -if (ret !=0 ) { -dev_err (wm8994->dev,"Failed to get IRQ GPIO: %d\n" , - ret); -return ret; - } - - wm8994->edge_irq =irq_domain_create_linear (NULL ,1 , &wm8994_edge_irq_ops, wm8994); - - ret =regmap_add_irq_chip (wm8994->regmap, -irq_create_mapping (wm8994->edge_irq, -0 ), -IRQF_ONESHOT , - wm8994->irq_base, &wm8994_irq_chip, - &wm8994->irq_data); -if (ret !=0 ) { -dev_err (wm8994->dev,"Failed to get IRQ: %d\n" , - ret); -return ret; - } - - ret =request_threaded_irq (wm8994->irq, -NULL , wm8994_edge_irq, - irqflags, -"WM8994 edge" , wm8994); - }else { - ret =regmap_add_irq_chip (wm8994->regmap, wm8994->irq, - irqflags, - wm8994->irq_base, &wm8994_irq_chip, - &wm8994->irq_data); - } + ret =regmap_add_irq_chip (wm8994->regmap, wm8994->irq, +IRQF_TRIGGER_HIGH |IRQF_ONESHOT , + wm8994->irq_base, &wm8994_irq_chip, + &wm8994->irq_data);if (ret !=0 ) {dev_err (wm8994->dev,"Failed to register IRQ chip: %d\n" , ret);
include/linux/mfd/wm8994/pdata.h +0 -5
@@ -226,11 +226,6 @@ struct wm8994_pdata {* lines is mastered. */ int max_channels_clocked[WM8994_NUM_AIF]; - -/** -* GPIO for the IRQ pin if host only supports edge triggering -*/ - int irq_gpio; };#endif
Signature · 1 line
2.39.5
PATCH 8/21 ASoC: add GPIOLIB_LEGACY dependency where needed
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
In order to make the legacy gpiolib interfaces such as gpio_request() optional, mark the three ASoC driver that rely on it today with a dependency on the new Kconfig symbol.
The tlv320dac33 and ak4641 drivers have no in-tree users, while the uda1380 driver is theoretically referened by two lpc3250 based boards, but neither of them work because of the legacy gpiolib dependency.
--- sound/soc/codecs/Kconfig | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/codecs/Kconfig +3 -0
@@ -622,6 +622,7 @@ config SND_SOC_AK4619 config SND_SOC_AK4641 tristate depends on I2C + depends on GPIOLIB_LEGACY config SND_SOC_AK4642 tristate "AKM AK4642 CODEC"
@@ -2175,6 +2176,7 @@ config SND_SOC_TLV320AIC3X_SPI config SND_SOC_TLV320DAC33 tristate depends on I2C + depends on GPIOLIB_LEGACY config SND_SOC_TLV320ADCX140 tristate "Texas Instruments TLV320ADCX140 CODEC family"
@@ -2229,6 +2231,7 @@ config SND_SOC_UDA1342 config SND_SOC_UDA1380 tristate depends on I2C + depends on GPIOLIB_LEGACY config SND_SOC_WCD_CLASSH tristate
Signature · 1 line
2.39.5
PATCH 9/21 input: gpio-keys: make legacy gpiolib optional
In reply to Arnd BergmannFrom: 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.
--- drivers/input/keyboard/gpio_keys.c | 5 +++-- drivers/input/keyboard/gpio_keys_polled.c | 2 ++ drivers/mfd/rohm-bd71828.c | 2 ++ drivers/mfd/rohm-bd718x7.c | 2 ++ include/linux/gpio_keys.h | 2 ++ 5 files changed, 11 insertions(+), 2 deletions(-)
drivers/input/keyboard/gpio_keys.c +3 -2
@@ -528,6 +528,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,*/ bdata->gpiod =NULL ; } +#ifdef CONFIG_GPIOLIB_LEGACY }else if (gpio_is_valid (button->gpio)) {/* * Legacy GPIO number, so request the GPIO here and
@@ -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
@@ -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 +2 -0
@@ -21,7 +21,9 @@static struct gpio_keys_button button = { .code =KEY_POWER , +#ifdef CONFIG_GPIOLIB_LEGACY .gpio =-1 , +#endif .type =EV_KEY , };
drivers/mfd/rohm-bd718x7.c +2 -0
@@ -20,7 +20,9 @@static struct gpio_keys_button button = { .code =KEY_POWER , +#ifdef CONFIG_GPIOLIB_LEGACY .gpio =-1 , +#endif .type =EV_KEY , };
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;const char *desc;unsigned int type;
Signature · 1 line
2.39.5
PATCH 10/21 leds: gpio: make legacy gpiolib interface optional
In reply to Arnd BergmannFrom: 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.
Make the code that deals with this optional so the legacy interfaces can be left out for all normal builds.
--- drivers/leds/leds-gpio.c | 8 ++++++-- include/linux/leds.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/leds/leds-gpio.c +6 -2
@@ -212,7 +212,9 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx, const struct gpio_led *template) {struct gpio_desc *gpiod; +#ifdef CONFIG_GPIOLIB_LEGACY int ret; +#endif /* * This means the LED does not come from the device tree
@@ -228,6 +230,7 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,return gpiod; } +#ifdef CONFIG_GPIOLIB_LEGACY /* * This is the legacy code path for platform code that * still uses GPIO numbers. Ultimately we would like to get
@@ -244,6 +247,7 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,return ERR_PTR (ret); gpiod =gpio_to_desc (template->gpio); +#endif if (!gpiod)return ERR_PTR (-EINVAL );
@@ -276,8 +280,8 @@ static int gpio_led_probe(struct platform_device *pdev) led_dat->gpiod =gpio_led_get_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
@@ -676,7 +676,9 @@ 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; +#endif unsigned active_low :1 ;unsigned retain_state_suspended :1 ;unsigned panic_indicator :1 ;
Signature · 1 line
2.39.5
PATCH 11/21 media: em28xx: add special case for legacy gpiolib interface
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
The em28xx driver uses the old-style gpio_request_one() inteface to switch the lna on the PCTV 290E card.
This interface is becoming optional and should no longer be called by portable drivers. As I could not figure out an obvious replacement, select the new GPIOLIB_LEGACY symbol as a workaround.
--- drivers/media/usb/em28xx/Kconfig | 1 + drivers/media/usb/em28xx/em28xx-dvb.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/media/usb/em28xx/Kconfig +1 -0
@@ -68,6 +68,7 @@ config VIDEO_EM28XX_DVB select MEDIA_TUNER_XC5000 if MEDIA_SUBDRV_AUTOSELECT select MEDIA_TUNER_MT2060 if MEDIA_SUBDRV_AUTOSELECT select DVB_MXL692 if MEDIA_SUBDRV_AUTOSELECT + select GPIOLIB_LEGACY if GPIOLIB && DVB_CXD2820R help This adds support for DVB cards based on the Empiatech em28xx chips.
drivers/media/usb/em28xx/em28xx-dvb.c +2 -2
@@ -727,7 +727,7 @@ static int em28xx_pctv_290e_set_lna(struct dvb_frontend *fe)struct dtv_frontend_properties *c = &fe->dtv_property_cache;struct em28xx_i2c_bus *i2c_bus = fe->dvb->priv;struct em28xx *dev = i2c_bus->dev; -#ifdef CONFIG_GPIOLIB +#ifdef CONFIG_GPIOLIB_LEGACY struct em28xx_dvb *dvb = dev->dvb;int ret;unsigned long flags;
@@ -1705,7 +1705,7 @@ static int em28xx_dvb_init(struct em28xx *dev) goto out_free; } -#ifdef CONFIG_GPIOLIB +#ifdef CONFIG_GPIOLIB_LEGACY /* enable LNA for DVB-T, DVB-T2 and DVB-C */ result =gpio_request_one (dvb->lna_gpio,GPIOF_OUT_INIT_LOW ,NULL );
Signature · 1 line
2.39.5
PATCH 12/21 mfd: arizona: make legacy gpiolib interface optional
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
The only machine that still uses the old gpio number based interface is the wlf_cragg_6410 board file. In order to remove the dependency on the interfaces, add #ifdef blocks here.
--- drivers/mfd/arizona-irq.c | 5 ++++- include/linux/mfd/arizona/pdata.h | 6 ++++++ sound/soc/codecs/arizona-jack.c | 17 ++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-)
drivers/mfd/arizona-irq.c +4 -1
@@ -136,7 +136,7 @@ static irqreturn_t arizona_irq_thread(int irq, void *data)dev_err (arizona->dev,"Failed to read main IRQ status: %d\n" , ret); } - +#ifdef CONFIG_GPIOLIB_LEGACY /* * Poll the IRQ pin status to see if we're really done * if the interrupt controller can't do it for us.
@@ -150,6 +150,7 @@ static irqreturn_t arizona_irq_thread(int irq, void *data) !gpio_get_value_cansleep(arizona->pdata.irq_gpio)) { poll = true; } +#endif }while (poll);pm_runtime_put_autosuspend (arizona->dev);
@@ -349,6 +350,7 @@ int arizona_irq_init(struct arizona *arizona) goto err_map_main_irq; } +#ifdef CONFIG_GPIOLIB_LEGACY /* Used to emulate edge trigger and to work around broken pinmux */ if (arizona->pdata.irq_gpio) {if (gpio_to_irq (arizona->pdata.irq_gpio) != arizona->irq) {
@@ -368,6 +370,7 @@ int arizona_irq_init(struct arizona *arizona) arizona->pdata.irq_gpio = 0; } } +#endif ret =request_threaded_irq (arizona->irq,NULL , arizona_irq_thread, flags,"arizona" , arizona);
include/linux/mfd/arizona/pdata.h +6 -0
@@ -117,8 +117,10 @@ struct arizona_pdata {/** Check for line output with HPDET method */ bool hpdet_acc_id_line; +#ifdef CONFIG_GPIOLIB_LEGACY /** GPIO used for mic isolation with HPDET */ int hpdet_id_gpio; +#endif /** Channel to use for headphone detection */ unsigned int hpdet_channel;
@@ -129,8 +131,10 @@ struct arizona_pdata {/** Extra debounce timeout used during initial mic detection (ms) */ unsigned int micd_detect_debounce; +#ifdef CONFIG_GPIOLIB_LEGACY /** GPIO for mic detection polarity */ int micd_pol_gpio; +#endif /** Mic detect ramp rate */ unsigned int micd_bias_start_time;
@@ -184,8 +188,10 @@ struct arizona_pdata {/** Haptic actuator type */ unsigned int hap_act; +#ifdef CONFIG_GPIOLIB_LEGACY /** GPIO for primary IRQ (used for edge triggered emulation) */ int irq_gpio; +#endif /** General purpose switch control */ unsigned int gpsw;
sound/soc/codecs/arizona-jack.c +16 -1
@@ -461,7 +461,11 @@ static int arizona_hpdet_do_id(struct arizona_priv *info, int *reading, bool *mic) {struct arizona *arizona = info->arizona; +#ifdef CONFIG_GPIOLIB_LEGACY int id_gpio = arizona->pdata.hpdet_id_gpio; +#else +int id_gpio =0 ; +#endif if (!arizona->pdata.hpdet_acc_id)return 0 ;
@@ -472,6 +476,7 @@ static int arizona_hpdet_do_id(struct arizona_priv *info, int *reading,*/ info->hpdet_res[info->num_hpdet_res++] = *reading; +#ifdef CONFIG_GPIOLIB_LEGACY /* Only check the mic directly if we didn't already ID it */ if (id_gpio && info->num_hpdet_res ==1 ) {dev_dbg (arizona->dev,"Measuring mic\n" );
@@ -489,6 +494,7 @@ static int arizona_hpdet_do_id(struct arizona_priv *info, int *reading, ARIZONA_HP_POLL, ARIZONA_HP_POLL);return -EAGAIN ; } +#endif /* OK, got both. Now, compare... */ dev_dbg(arizona->dev, "HPDET measured %d %d\n",
@@ -529,7 +535,9 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data) {struct arizona_priv *info = data;struct arizona *arizona = info->arizona; +#ifdef CONFIG_GPIOLIB_LEGACY int id_gpio = arizona->pdata.hpdet_id_gpio; +#endif int ret, reading, state, report;bool mic = false;
@@ -585,8 +593,10 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)arizona_extcon_hp_clamp (info, false); +#ifdef CONFIG_GPIOLIB_LEGACY if (id_gpio)gpio_set_value_cansleep (id_gpio,0 ); +#endif /* If we have a mic then reenable MICDET */ if (state && (mic || info->mic))
@@ -1317,6 +1327,7 @@ int arizona_jack_codec_dev_probe(struct arizona_priv *info, struct device *dev)regmap_update_bits (arizona->regmap,ARIZONA_GP_SWITCH_1 ,ARIZONA_SW1_MODE_MASK , arizona->pdata.gpsw); +#ifdef CONFIG_GPIOLIB_LEGACY if (pdata->micd_pol_gpio >0 ) {if (info->micd_modes[0 ].gpio) mode =GPIOF_OUT_INIT_HIGH ;
@@ -1332,7 +1343,9 @@ int arizona_jack_codec_dev_probe(struct arizona_priv *info, struct device *dev) } info->micd_pol_gpio =gpio_to_desc (pdata->micd_pol_gpio); - }else { + } else +#endif + {if (info->micd_modes[0 ].gpio) mode =GPIOD_OUT_HIGH ;else
@@ -1353,6 +1366,7 @@ int arizona_jack_codec_dev_probe(struct arizona_priv *info, struct device *dev) } } +#ifdef CONFIG_GPIOLIB_LEGACY if (arizona->pdata.hpdet_id_gpio >0 ) { ret = devm_gpio_request_one(dev, arizona->pdata.hpdet_id_gpio, GPIOF_OUT_INIT_LOW,
@@ -1364,6 +1378,7 @@ int arizona_jack_codec_dev_probe(struct arizona_priv *info, struct device *dev) return ret; } } +#endif return 0 ; }
Signature · 1 line
2.39.5
PATCH 13/21 mfd: si476x: add GPIOLIB_LEGACY dependency
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
This driver uses the legacy gpiolib interfaces to get gpio numbers from platform data:
drivers/mfd/si476x-i2c.c: In function 'si476x_core_start':
drivers/mfd/si476x-i2c.c:133:21: error: implicit declaration of function 'gpio_is_valid'; did you mean 'uuid_is_valid'? [-Werror=implicit-function-declaration]
133 | if (gpio_is_valid(core->gpio_reset))
There are no in-tree users of this driver, so nothing defines the platform data.
Add a dependency on GPIOLIB_LEGACY for the moment to avoid the build failure, and make sure the sound driver does not get built without the mfd portion either pass that dependency along.
Alternatively, we could remove the mfd driver along with the radio and sound portions.
--- drivers/mfd/Kconfig | 1 + sound/soc/codecs/Kconfig | 1 + 2 files changed, 2 insertions(+)
drivers/mfd/Kconfig +1 -0
@@ -1411,6 +1411,7 @@ config MFD_SEC_I2C config MFD_SI476X_CORE tristate "Silicon Laboratories 4761/64/68 AM/FM radio." depends on I2C + depends on GPIOLIB_LEGACY select MFD_CORE select REGMAP_I2C help
sound/soc/codecs/Kconfig +1 -0
@@ -1903,6 +1903,7 @@ config SND_SOC_SGTL5000 config SND_SOC_SI476X tristate + depends on MFD_SI476X_CORE config SND_SOC_SIGMADSP tristate
Signature · 1 line
2.39.5
PATCH 14/21 mfd: aat2870: add GPIOLIB_LEGACY dependency
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
This driver uses the legacy gpiolib interfaces to get gpio numbers from platform data. There are no in-tree users of this driver, so nothing defines the platform data.
Add a dependency on GPIOLIB_LEGACY for the moment to avoid the build failure, and make sure the sound driver does not get built without the mfd portion either pass that dependency along.
Alternatively, we could remove the mfd driver along with the backlight and regulator portions.
--- drivers/mfd/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/Kconfig +1 -0
@@ -129,6 +129,7 @@ config MFD_AAT2870_CORE select MFD_CORE depends on I2C=y depends on GPIOLIB || COMPILE_TEST + depends on GPIOLIB_LEGACY help If you say yes here you get support for the AAT2870. This driver provides common support for accessing the device,
Signature · 1 line
2.39.5
PATCH 15/21 dsa: b53: hide legacy gpiolib usage on non-mips
In reply to Arnd BergmannFrom: 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 | 24 ++++++++++++++++++------ 2 files changed, 23 insertions(+), 18 deletions(-)
drivers/net/dsa/b53/b53_common.c +5 -12
@@ -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>
@@ -948,17 +948,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 ;
@@ -2925,7 +2925,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 ;
@@ -3005,12 +3004,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 +18 -6
@@ -136,7 +136,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;
@@ -375,22 +375,34 @@ static inline void b53_arl_from_entry_25(u64 *mac_vid,#include <linux/bcm47xx_nvram.h> #include <bcm47xx_board.h> -static inline int b53_switch_get_reset_gpio (struct b53_device *dev) +static inline 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_gpiod_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
PATCH 16/21 ath10k: remove gpio number assignment
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
The leds-gpio traditionally takes a global gpio number in its platform data, but the number assigned here is not actually such a number but only meant to be used internally to this driver.
As part of the kernel-wide cleanup of the old gpiolib interfaces, the 'gpio' number field is going away, so to keep ath10k building, move the assignment into a private structure instead.
--- drivers/net/wireless/ath/ath10k/leds.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/leds.c +1 -2
@@ -27,7 +27,7 @@ static int ath10k_leds_set_brightness_blocking(struct led_classdev *led_cdev, goto out; ar->leds.gpio_state_pin = (brightness !=LED_OFF ) ^ led->active_low; -ath10k_wmi_gpio_output (ar, led->gpio, ar->leds.gpio_state_pin); +ath10k_wmi_gpio_output (ar, ar->hw_params.led_pin, ar->leds.gpio_state_pin); out:mutex_unlock (&ar->conf_mutex);
@@ -64,7 +64,6 @@ int ath10k_leds_register(struct ath10k *ar)snprintf (ar->leds.label,sizeof (ar->leds.label),"ath10k-%s" ,wiphy_name (ar->hw->wiphy)); ar->leds.wifi_led.active_low =1 ; - ar->leds.wifi_led.gpio = ar->hw_params.led_pin; ar->leds.wifi_led.name = ar->leds.label; ar->leds.wifi_led.default_state =LEDS_GPIO_DEFSTATE_KEEP ;
Signature · 1 line
2.39.5
PATCH 17/21 nfc: marvell: convert to gpio descriptors
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
The only reason this driver seems to still use the legacy gpio numbers is for the module parameter that lets users pass a different reset gpio.
Since the fixed numbers are on their way out, and none of the platforms this driver is used on would have them any more, remove the module parameter and instead just use the reset information from firmware.
--- drivers/nfc/nfcmrvl/main.c | 47 +++++++++++------------------------ drivers/nfc/nfcmrvl/nfcmrvl.h | 5 ++-- drivers/nfc/nfcmrvl/uart.c | 5 ---- drivers/nfc/nfcmrvl/usb.c | 1 - 4 files changed, 18 insertions(+), 40 deletions(-)
drivers/nfc/nfcmrvl/main.c +15 -32
@@ -6,7 +6,7 @@*/ #include <linux/module.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/delay.h> #include <linux/of_gpio.h> #include <linux/nfc.h>
@@ -112,14 +112,10 @@ struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy,memcpy (&priv->config, pdata,sizeof (*pdata)); -if (gpio_is_valid (priv->config.reset_n_io)) { - rc =gpio_request_one (priv->config.reset_n_io, -GPIOF_OUT_INIT_LOW , -"nfcmrvl_reset_n" ); -if (rc <0 ) { - priv->config.reset_n_io = -EINVAL ; -nfc_err (dev,"failed to request reset_n io\n" ); - } + priv->reset_n_io =gpiod_get_optional (dev,"reset-n-io" ,GPIOD_OUT_LOW ); +if (IS_ERR (priv->reset_n_io)) { +nfc_err (dev,"failed to get reset_n gpio\n" ); +return ERR_CAST (priv->reset_n_io); }if (phy ==NFCMRVL_PHY_SPI ) {
@@ -172,8 +168,7 @@ struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy, error_free_dev:nci_free_device (priv->ndev); error_free_gpio: -if (gpio_is_valid (priv->config.reset_n_io)) -gpio_free (priv->config.reset_n_io); +gpiod_put (priv->reset_n_io);kfree (priv);return ERR_PTR (rc); }
@@ -189,8 +184,7 @@ void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv)nfcmrvl_fw_dnld_deinit (priv); -if (gpio_is_valid (priv->config.reset_n_io)) -gpio_free (priv->config.reset_n_io); +gpiod_put (priv->reset_n_io);nci_free_device (ndev);kfree (priv);
@@ -232,35 +226,24 @@ void nfcmrvl_chip_reset(struct nfcmrvl_private *priv) {/* Reset possible fault of previous session */ clear_bit (NFCMRVL_PHY_ERROR , &priv->flags); +if (!priv->reset_n_io) +return ; -if (gpio_is_valid (priv->config.reset_n_io)) { -nfc_info (priv->dev,"reset the chip\n" ); -gpio_set_value (priv->config.reset_n_io,0 ); -usleep_range (5000 ,10000 ); -gpio_set_value (priv->config.reset_n_io,1 ); - }else -nfc_info (priv->dev,"no reset available on this interface\n" ); +nfc_info (priv->dev,"reset the chip\n" ); +gpiod_set_value (priv->reset_n_io,0 ); +usleep_range (5000 ,10000 ); +gpiod_set_value (priv->reset_n_io,1 ); }void nfcmrvl_chip_halt (struct nfcmrvl_private *priv) { -if (gpio_is_valid (priv->config.reset_n_io)) -gpio_set_value (priv->config.reset_n_io,0 ); +if (priv->reset_n_io) +gpiod_set_value (priv->reset_n_io,0 ); }int nfcmrvl_parse_dt (struct device_node *node,struct nfcmrvl_platform_data *pdata) { -int reset_n_io; - - reset_n_io =of_get_named_gpio (node,"reset-n-io" ,0 ); -if (reset_n_io <0 ) { -pr_info ("no reset-n-io config\n" ); - }else if (!gpio_is_valid (reset_n_io)) { -pr_err ("invalid reset-n-io GPIO\n" ); -return reset_n_io; - } - pdata->reset_n_io = reset_n_io; pdata->hci_muxed =of_property_read_bool (node,"hci-muxed" );return 0 ;
drivers/nfc/nfcmrvl/nfcmrvl.h +3 -2
@@ -53,8 +53,6 @@ struct nfcmrvl_platform_data {* Generic */ -/* GPIO that is wired to RESET_N signal */ -int reset_n_io;/* Tell if transport is muxed in HCI one */ bool hci_muxed;
@@ -83,6 +81,9 @@ struct nfcmrvl_private {/* Platform configuration */ struct nfcmrvl_platform_data config; +/* RESET_N GPIO line */ +struct gpio_desc *reset_n_io; +/* Parent dev */ struct nci_dev *ndev;
drivers/nfc/nfcmrvl/uart.c +0 -5
@@ -20,7 +20,6 @@static unsigned int hci_muxed;static unsigned int flow_control;static unsigned int break_control; -static int reset_n_io = -EINVAL ;/* * NFCMRVL NCI OPS
@@ -113,7 +112,6 @@ static int nfcmrvl_nci_uart_open(struct nci_uart *nu)if (!pdata) {pr_info ("No platform data / DT -> fallback to module params\n" ); config.hci_muxed = hci_muxed; - config.reset_n_io = reset_n_io; config.flow_control = flow_control; config.break_control = break_control; pdata = &config;
@@ -201,6 +199,3 @@ MODULE_PARM_DESC(break_control, "Tell if UART driver must drive break signal.");module_param (hci_muxed, uint,0 );MODULE_PARM_DESC (hci_muxed,"Tell if transport is muxed in HCI one." ); - -module_param (reset_n_io, int,0 ); -MODULE_PARM_DESC (reset_n_io,"GPIO that is wired to RESET_N signal." );
drivers/nfc/nfcmrvl/usb.c +0 -1
@@ -294,7 +294,6 @@ static int nfcmrvl_probe(struct usb_interface *intf,/* No configuration for USB */ memset (&config,0 ,sizeof (config)); - config.reset_n_io = -EINVAL ;nfc_info (&udev->dev,"intf %p id %p\n" , intf, id);
Signature · 1 line
2.39.5
PATCH 18/21 nfc: s3fwrn5: convert to gpio descriptors
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
There is no need for this driver to still use the legacy interfaces, so convert all the legacy calls into their modern equivalents.
--- drivers/nfc/s3fwrn5/i2c.c | 42 +++++++++----------------------- drivers/nfc/s3fwrn5/phy_common.c | 12 ++++----- drivers/nfc/s3fwrn5/phy_common.h | 4 +-- drivers/nfc/s3fwrn5/uart.c | 30 ++++++----------------- 4 files changed, 28 insertions(+), 60 deletions(-)
drivers/nfc/s3fwrn5/i2c.c +12 -30
@@ -8,7 +8,7 @@#include <linux/clk.h> #include <linux/i2c.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/delay.h> #include <linux/of_gpio.h> #include <linux/of_irq.h>
@@ -149,29 +149,22 @@ static irqreturn_t s3fwrn5_i2c_irq_thread_fn(int irq, void *phy_id)static int s3fwrn5_i2c_parse_dt (struct i2c_client *client) {struct s3fwrn5_i2c_phy *phy =i2c_get_clientdata (client); -struct device_node *np = client->dev.of_node; +struct device *dev = &client->dev; -if (!np) -return -ENODEV ; - - phy->common.gpio_en =of_get_named_gpio (np,"en-gpios" ,0 ); -if (!gpio_is_valid (phy->common.gpio_en)) { + phy->common.gpio_en =devm_gpiod_get (dev,"en" ,GPIOD_OUT_HIGH ); +if (IS_ERR (phy->common.gpio_en)) {/* Support also deprecated property */ - phy->common.gpio_en =of_get_named_gpio (np, -"s3fwrn5,en-gpios" , -0 ); -if (!gpio_is_valid (phy->common.gpio_en)) -return -ENODEV ; + phy->common.gpio_en =devm_gpiod_get (dev,"s3fwrn5,en" ,GPIOD_OUT_HIGH ); +if (IS_ERR (phy->common.gpio_en)) +return PTR_ERR (phy->common.gpio_en); } - phy->common.gpio_fw_wake =of_get_named_gpio (np,"wake-gpios" ,0 ); -if (!gpio_is_valid (phy->common.gpio_fw_wake)) { + phy->common.gpio_fw_wake =devm_gpiod_get (dev,"wake" ,GPIOD_OUT_LOW ); +if (IS_ERR (phy->common.gpio_fw_wake)) {/* Support also deprecated property */ - phy->common.gpio_fw_wake =of_get_named_gpio (np, -"s3fwrn5,fw-gpios" , -0 ); -if (!gpio_is_valid (phy->common.gpio_fw_wake)) -return -ENODEV ; + phy->common.gpio_fw_wake =devm_gpiod_get (dev,"s3fwrn5,fw" ,GPIOD_OUT_LOW ); +if (IS_ERR (phy->common.gpio_fw_wake)) +return PTR_ERR (phy->common.gpio_en); }return 0 ;
@@ -197,17 +190,6 @@ static int s3fwrn5_i2c_probe(struct i2c_client *client)if (ret <0 )return ret; - ret =devm_gpio_request_one (&phy->i2c_dev->dev, phy->common.gpio_en, -GPIOF_OUT_INIT_HIGH ,"s3fwrn5_en" ); -if (ret <0 ) -return ret; - - ret =devm_gpio_request_one (&phy->i2c_dev->dev, - phy->common.gpio_fw_wake, -GPIOF_OUT_INIT_LOW ,"s3fwrn5_fw_wake" ); -if (ret <0 ) -return ret; -/* * S3FWRN5 depends on a clock input ("XI" pin) to function properly. * Depending on the hardware configuration this could be an always-on
drivers/nfc/s3fwrn5/phy_common.c +6 -6
@@ -8,7 +8,7 @@* Bongsu Jeon <[email protected]> */ -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/delay.h> #include <linux/module.h>
@@ -19,7 +19,7 @@ void s3fwrn5_phy_set_wake(void *phy_id, bool wake)struct phy_common *phy = phy_id;mutex_lock (&phy->mutex); -gpio_set_value (phy->gpio_fw_wake, wake); +gpiod_set_value (phy->gpio_fw_wake, wake);if (wake)msleep (S3FWRN5_EN_WAIT_TIME );mutex_unlock (&phy->mutex);
@@ -33,14 +33,14 @@ bool s3fwrn5_phy_power_ctrl(struct phy_common *phy, enum s3fwrn5_mode mode) phy->mode = mode; -gpio_set_value (phy->gpio_en,1 ); -gpio_set_value (phy->gpio_fw_wake,0 ); +gpiod_set_value (phy->gpio_en,1 ); +gpiod_set_value (phy->gpio_fw_wake,0 );if (mode ==S3FWRN5_MODE_FW ) -gpio_set_value (phy->gpio_fw_wake,1 ); +gpiod_set_value (phy->gpio_fw_wake,1 );if (mode !=S3FWRN5_MODE_COLD ) {msleep (S3FWRN5_EN_WAIT_TIME ); -gpio_set_value (phy->gpio_en,0 ); +gpiod_set_value (phy->gpio_en,0 );msleep (S3FWRN5_EN_WAIT_TIME ); }
drivers/nfc/s3fwrn5/phy_common.h +2 -2
@@ -21,8 +21,8 @@struct phy_common {struct nci_dev *ndev; -int gpio_en; -int gpio_fw_wake; +struct gpio_desc *gpio_en; +struct gpio_desc *gpio_fw_wake;struct mutex mutex;
drivers/nfc/s3fwrn5/uart.c +8 -22
@@ -15,7 +15,7 @@#include <linux/netdevice.h> #include <linux/of.h> #include <linux/serdev.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/of_gpio.h> #include "phy_common.h"
@@ -91,18 +91,15 @@ MODULE_DEVICE_TABLE(of, s3fwrn82_uart_of_match);static int s3fwrn82_uart_parse_dt (struct serdev_device *serdev) {struct s3fwrn82_uart_phy *phy =serdev_device_get_drvdata (serdev); -struct device_node *np = serdev->dev.of_node; +struct device *dev = &serdev->dev; -if (!np) -return -ENODEV ; + phy->common.gpio_en =devm_gpiod_get (dev,"en" ,GPIOD_OUT_HIGH ); +if (IS_ERR (phy->common.gpio_en)) +return PTR_ERR (phy->common.gpio_en); - phy->common.gpio_en =of_get_named_gpio (np,"en-gpios" ,0 ); -if (!gpio_is_valid (phy->common.gpio_en)) -return -ENODEV ; - - phy->common.gpio_fw_wake =of_get_named_gpio (np,"wake-gpios" ,0 ); -if (!gpio_is_valid (phy->common.gpio_fw_wake)) -return -ENODEV ; + phy->common.gpio_fw_wake =devm_gpiod_get (dev,"wake" ,GPIOD_OUT_LOW ); +if (IS_ERR (phy->common.gpio_fw_wake)) +return PTR_ERR (phy->common.gpio_fw_wake);return 0 ; }
@@ -144,17 +141,6 @@ static int s3fwrn82_uart_probe(struct serdev_device *serdev)if (ret <0 ) goto err_serdev; - ret =devm_gpio_request_one (&phy->ser_dev->dev, phy->common.gpio_en, -GPIOF_OUT_INIT_HIGH ,"s3fwrn82_en" ); -if (ret <0 ) - goto err_serdev; - - ret =devm_gpio_request_one (&phy->ser_dev->dev, - phy->common.gpio_fw_wake, -GPIOF_OUT_INIT_LOW ,"s3fwrn82_fw_wake" ); -if (ret <0 ) - goto err_serdev; - ret =s3fwrn5_probe (&phy->common.ndev, phy, &phy->ser_dev->dev, &uart_phy_ops);if (ret <0 )
Signature · 1 line
2.39.5
PATCH 19/21 usb: udc: pxa: remove unused platform_data
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
None of the remaining boards put useful data into the platform_data structures, so effectively this only works with DT based probing.
Remove all code that references this data, to stop using the legacy gpiolib interfaces. The pxa27x version already supports gpio descriptors, while the pxa25x version now does it the same way.
--- arch/arm/mach-pxa/devices.c | 7 ---- arch/arm/mach-pxa/gumstix.c | 1 - arch/arm/mach-pxa/udc.h | 8 ----- drivers/usb/gadget/udc/pxa25x_udc.c | 41 ++++++++---------------- drivers/usb/gadget/udc/pxa25x_udc.h | 2 +- drivers/usb/gadget/udc/pxa27x_udc.c | 35 +++----------------- drivers/usb/gadget/udc/pxa27x_udc.h | 2 -- include/linux/platform_data/pxa2xx_udc.h | 15 --------- 8 files changed, 19 insertions(+), 92 deletions(-) delete mode 100644 arch/arm/mach-pxa/udc.h
arch/arm/mach-pxa/devices.c +0 -7
@@ -11,7 +11,6 @@#include <linux/platform_data/i2c-pxa.h> #include <linux/soc/pxa/cpu.h> -#include "udc.h" #include <linux/platform_data/video-pxafb.h> #include <linux/platform_data/mmc-pxamci.h> #include "irqs.h"
@@ -83,10 +82,6 @@ void __init pxa_set_mci_info(const struct pxamci_platform_data *info,pr_err ("Unable to create mci device: %d\n" , err); } -static struct pxa2xx_udc_mach_info pxa_udc_info = { - .gpio_pullup =-1 , -}; -static struct resource pxa2xx_udc_resources[] = { [0 ] = { .start =0x40600000 ,
@@ -108,7 +103,6 @@ struct platform_device pxa25x_device_udc = { .resource = pxa2xx_udc_resources, .num_resources = ARRAY_SIZE(pxa2xx_udc_resources), .dev = { - .platform_data = &pxa_udc_info, .dma_mask = &udc_dma_mask, } };
@@ -119,7 +113,6 @@ struct platform_device pxa27x_device_udc = { .resource = pxa2xx_udc_resources, .num_resources = ARRAY_SIZE(pxa2xx_udc_resources), .dev = { - .platform_data = &pxa_udc_info, .dma_mask = &udc_dma_mask, } };
arch/arm/mach-pxa/gumstix.c +0 -1
@@ -39,7 +39,6 @@#include "pxa25x.h" #include <linux/platform_data/mmc-pxamci.h> -#include "udc.h" #include "gumstix.h" #include "devices.h"
arch/arm/mach-pxa/udc.h deleted +0 -8
@@ -1,8 +0,0 @@ -/* -* arch/arm/mach-pxa/include/mach/udc.h -* -*/ -#include <linux/platform_data/pxa2xx_udc.h> - -extern void pxa_set_udc_info (struct pxa2xx_udc_mach_info *info); -
drivers/usb/gadget/udc/pxa25x_udc.c +13 -28
78 lines not on this page · raw message
drivers/usb/gadget/udc/pxa25x_udc.h +1 -1
@@ -112,7 +112,7 @@ struct pxa25x_udc {struct device *dev;struct clk *clk; -struct pxa2xx_udc_mach_info *mach; +struct gpio_desc *pullup_gpio;struct usb_phy *transceiver;u64 dma_mask;struct pxa25x_ep ep [PXA_UDC_NUM_ENDPOINTS ];
drivers/usb/gadget/udc/pxa27x_udc.c +5 -30
@@ -17,7 +17,6 @@#include <linux/proc_fs.h> #include <linux/clk.h> #include <linux/irq.h> -#include <linux/gpio.h> #include <linux/gpio/consumer.h> #include <linux/slab.h> #include <linux/string_choices.h>
@@ -1423,14 +1422,7 @@ static const struct usb_ep_ops pxa_ep_ops = {*/ static void dplus_pullup (struct pxa_udc *udc,int on) { -if (udc->gpiod) { -gpiod_set_value (udc->gpiod, on); - }else if (udc->udc_command) { -if (on) - udc->udc_command (PXA2XX_UDC_CMD_CONNECT ); -else - udc->udc_command (PXA2XX_UDC_CMD_DISCONNECT ); - } +gpiod_set_value (udc->gpiod, on); udc->pullup_on = on; }
@@ -1520,7 +1512,7 @@ static int pxa_udc_pullup(struct usb_gadget *_gadget, int is_active) {struct pxa_udc *udc =to_gadget_udc (_gadget); -if (!udc->gpiod && !udc->udc_command) +if (!udc->gpiod)return -EOPNOTSUPP ;dplus_pullup (udc, is_active);
@@ -2354,26 +2346,9 @@ MODULE_DEVICE_TABLE(of, udc_pxa_dt_ids);static int pxa_udc_probe (struct platform_device *pdev) {struct pxa_udc *udc = &memory; -int retval =0 , gpio; -struct pxa2xx_udc_mach_info *mach =dev_get_platdata (&pdev->dev); - -if (mach) { - gpio = mach->gpio_pullup; -if (gpio_is_valid (gpio)) { - retval =devm_gpio_request_one (&pdev->dev, gpio, -GPIOF_OUT_INIT_LOW , -"USB D+ pullup" ); -if (retval) -return retval; - udc->gpiod =gpio_to_desc (mach->gpio_pullup); - -if (mach->gpio_pullup_inverted ^gpiod_is_active_low (udc->gpiod)) -gpiod_toggle_active_low (udc->gpiod); - } - udc->udc_command = mach->udc_command; - }else { - udc->gpiod =devm_gpiod_get (&pdev->dev,NULL ,GPIOD_ASIS ); - } +int retval =0 ; + + udc->gpiod =devm_gpiod_get (&pdev->dev,NULL ,GPIOD_ASIS ); udc->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (udc->regs))
drivers/usb/gadget/udc/pxa27x_udc.h +0 -2
@@ -426,7 +426,6 @@ struct udc_stats {* @usb_gadget: udc gadget structure * @driver: bound gadget (zero, g_ether, g_mass_storage, ...) * @dev: device -* @udc_command: machine specific function to activate D+ pullup * @gpiod: gpio descriptor of gpio for D+ pullup (or NULL if none) * @transceiver: external transceiver to handle vbus sense and D+ pullup * @ep0state: control endpoint state machine state
@@ -452,7 +451,6 @@ struct pxa_udc {struct usb_gadget gadget;struct usb_gadget_driver *driver;struct device *dev; -void (*udc_command)(int );struct gpio_desc *gpiod;struct usb_phy *transceiver;
include/linux/platform_data/pxa2xx_udc.h +0 -15
@@ -10,21 +10,6 @@#ifndef PXA2XX_UDC_H #define PXA2XX_UDC_H -struct pxa2xx_udc_mach_info { -int (*udc_is_connected)(void );/* do we see host? */ -void (*udc_command)(int cmd); -#define PXA2XX_UDC_CMD_CONNECT 0/* let host see us */ -#define PXA2XX_UDC_CMD_DISCONNECT 1/* so host won't see us */ - -/* Boards following the design guidelines in the developer's manual, -* with on-chip GPIOs not Lubbock's weird hardware, can have a sane -* VBUS IRQ and omit the methods above. Store the GPIO number -* here. Note that sometimes the signals go through inverters... -*/ -bool gpio_pullup_inverted; -int gpio_pullup;/* high == pullup activated */ -}; -#ifdef CONFIG_PXA27xextern void pxa27x_clear_otgph (void );#else
Signature · 1 line
2.39.5
PATCH 20/21 ASoC: pxa: add GPIOLIB_LEGACY dependency
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
The pxa27x platform uses the legacy gpiolib interfaces, including in its sound drivers:
sound/arm/pxa2xx-ac97-lib.c: In function 'pxa2xx_ac97_hw_probe':sound/arm/pxa2xx-ac97-lib.c:374:23: error: implicit declaration of function 'gpio_request_one' [-Wimplicit-function-declaration]
374 | ret = gpio_request_one(reset_gpio, GPIOF_OUT_INIT_HIGH,
Make sure we don't select those drivers for compile-testing unless we are building for a pxa27x system, or CONFIG_GPIOLIB_LEGACY is already enabled.
The SND_PXA_SOC_SSP driver accidentally used a dependency on PLAT_PXA, which includes both ARCH_PXA and ARCH_MMP, but it is only used on the former.
--- sound/soc/pxa/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/pxa/Kconfig +2 -2
@@ -3,7 +3,7 @@ menu "PXA" config SND_PXA2XX_SOC tristate "SoC Audio for the Intel PXA2xx chip" - depends on ARCH_PXA || COMPILE_TEST + depends on ARCH_PXA || (COMPILE_TEST && GPIOLIB_LEGACY) select SND_PXA2XX_LIB help Say Y or M if you want to add support for codecs attached to
@@ -26,7 +26,7 @@ config SND_PXA2XX_SOC_I2S config SND_PXA_SOC_SSP tristate "Soc Audio via PXA2xx/PXA3xx SSP ports" - depends on PLAT_PXA + depends on ARCH_PXA select PXA_SSP select SND_PXA2XX_LIB
Signature · 1 line
2.39.5
PATCH 21/21 gpiolib: turn off legacy interface by default
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
All users of the legacy interface now select CONFIG_GPIOLIB_LEGACY, so it can be turned off by default.
Allow turning it on manually for compile testing, in order to keep the build coverage of the legacy drivers.
--- drivers/gpio/Kconfig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpio/Kconfig +9 -2
@@ -12,10 +12,17 @@ menuconfig GPIOLIB If unsure, say N. +if GPIOLIB + 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 GPIOLIB + If unsure, say N. config GPIOLIB_FASTPATH_LIMIT int "Maximum number of GPIOs for fast path"
Signature · 1 line
2.39.5
Re: [PATCH 05/21] x86/platform: select legacy gpiolib interfaces where used
In reply to Arnd BergmannQuoted 6 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_LEGACYsymbol so the code still works where it is needed but can be left out otherwise.
...
drivers/platform/x86/x86-android-tablets/Kconfig config X86_ANDROID_TABLETS · line 14
Quoted 10 lines
drivers/platform/x86/x86-android-tablets/Kconfig +1
-0@@ -8,6 +8,7 @@ config X86_ANDROID_TABLETS depends on I2C && SPI && SERIAL_DEV_BUS depends on GPIOLIB && PMIC_OPREGION depends on ACPI && EFI && PCI + select GPIOLIB_LEGACY select NEW_LEDS select LEDS_CLASS select POWER_SUPPLY
Hmm... This is a surprising change. But I leave it to Hans.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 15/21] dsa: b53: hide legacy gpiolib usage on non-mips
In reply to Arnd BergmannHi,
Quoted 9 lines · Arnd Bergmann
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.
Looks reasonable, but doesn't compile:
CC drivers/net/dsa/b53/b53_spi.o
In file included from drivers/net/dsa/b53/b53_spi.c:27:drivers/net/dsa/b53/b53_priv.h:378:15: error: unknown type name 'gpio_desc'
378 | static inline gpio_desc *b53_switch_get_reset_gpio(structb53_device *dev)
| ^~~~~~~~~
drivers/net/dsa/b53/b53_priv.h: In function 'b53_switch_get_reset_gpio':drivers/net/dsa/b53/b53_priv.h:392:14: error: implicit declaration of function 'gpio_is_valid'; did you mean 'uuid_is_valid'? [-Wimplicit-function-declaration]
392 | if (!gpio_is_valid(gpio))
| ^~~~~~~~~~~~~
| uuid_is_valid
drivers/net/dsa/b53/b53_priv.h:395:15: error: implicit declaration of
function 'devm_gpiod_request_one' [-Wimplicit-function-declaration]
395 | ret = devm_gpiod_request_one(dev->dev, gpio,
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/b53/b53_priv.h:396:38: error: 'GPIOF_OUT_INIT_HIGH'
undeclared (first use in this function); did you mean
'GPIOD_OUT_HIGH'?
396 | GPIOF_OUT_INIT_HIGH, "robo_reset");
| ^~~~~~~~~~~~~~~~~~~
| GPIOD_OUT_HIGHdrivers/net/dsa/b53/b53_priv.h:396:38: note: each undeclared identifier is reported only once for each function it appears in drivers/net/dsa/b53/b53_priv.h:400:16: error: returning 'struct gpio_desc *' from a function with incompatible return type 'int *' [-Wincompatible-pointer-types]
400 | return gpio_to_desc(gpio);
| ^~~~~~~~~~~~~~~~~~Quoted 12 lines
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/net/dsa/b53/b53_common.c | 17 +++++------------ drivers/net/dsa/b53/b53_priv.h | 24 ++++++++++++++++++------ 2 files changed, 23 insertions(+), 18 deletions(-)drivers/net/dsa/b53/b53_common.c +0
-0
drivers/net/dsa/b53/b53_common.c line 22
Quoted 4 lines
drivers/net/dsa/b53/b53_common.c +0
-1@@ -19,7 +19,7 @@#include <linux/delay.h> #include <linux/export.h> -#include <linux/gpio.h>
this include is now needed for b53_priv.h.
Quoted 61 lines
drivers/net/dsa/b53/b53_common.c +5
-11+#include <linux/gpio/consumer.h> #include <linux/kernel.h> #include <linux/math.h> #include <linux/minmax.h> @@ -948,17 +948,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 ;@@ -2925,7 +2925,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 ;@@ -3005,12 +3004,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 +1
-1@@ -136,7 +136,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;
drivers/net/dsa/b53/b53_priv.h static inline void b53_arl_from_entry_25(u64 *mac_vid, · line 378
Quoted 5 lines
drivers/net/dsa/b53/b53_priv.h +1
-1@@ -375,22 +375,34 @@ static inline void b53_arl_from_entry_25(u64 *mac_vid,#include <linux/bcm47xx_nvram.h> #include <bcm47xx_board.h> -static inline int b53_switch_get_reset_gpio (struct b53_device *dev) +static inline gpio_desc *b53_switch_get_reset_gpio (struct b53_device *dev)
s/gpio_desc/struct gpio_desc/
Quoted 9 lines
drivers/net/dsa/b53/b53_priv.h +2
-1{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 ;
drivers/net/dsa/b53/b53_priv.h static inline void b53_arl_from_entry_25(u64 *mac_vid, · line 395
Quoted 10 lines
drivers/net/dsa/b53/b53_priv.h +7
-1+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_gpiod_request_one(dev->dev, gpio,
s/devm_gpiod_request_one/devm_gpio_request_one/
Quoted 4 lines
drivers/net/dsa/b53/b53_priv.h +4
-0+ GPIOF_OUT_INIT_HIGH, "robo_reset"); +if (ret) +return ERR_PTR (ret); +
drivers/net/dsa/b53/b53_priv.h static inline void b53_arl_from_entry_25(u64 *mac_vid, · line 407
Quoted 10 lines
drivers/net/dsa/b53/b53_priv.h +3
-2+ 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
Can't really test this (no matching hardware), but with the code issues fixed
Best regards,
Jonas
Re: [PATCH 17/21] nfc: marvell: convert to gpio descriptors
In reply to Arnd BergmannQuoted 9 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The only reason this driver seems to still use the legacy gpio numbers is for the module parameter that lets users pass a different reset gpio.
Since the fixed numbers are on their way out, and none of the platforms this driver is used on would have them any more, remove the module parameter and instead just use the reset information from firmware.
This patch is my love in the series, thanks for doing it!
But note some comments below.
...
drivers/nfc/nfcmrvl/main.c struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy, · line 119
Quoted 13 lines
drivers/nfc/nfcmrvl/main.c +4
-8-if (gpio_is_valid (priv->config.reset_n_io)) { - rc =gpio_request_one (priv->config.reset_n_io, -GPIOF_OUT_INIT_LOW , -"nfcmrvl_reset_n" ); -if (rc <0 ) { - priv->config.reset_n_io = -EINVAL ; -nfc_err (dev,"failed to request reset_n io\n" ); - } + priv->reset_n_io =gpiod_get_optional (dev,"reset-n-io" ,GPIOD_OUT_LOW ); +if (IS_ERR (priv->reset_n_io)) { +nfc_err (dev,"failed to get reset_n gpio\n" ); +return ERR_CAST (priv->reset_n_io); }
This also needs a call to gpiod_set_consumer_name(), IIRC the API name.
...
drivers/nfc/nfcmrvl/main.c void nfcmrvl_chip_reset(struct nfcmrvl_private *priv) · line 234
Quoted 10 lines
drivers/nfc/nfcmrvl/main.c +3
-7-if (gpio_is_valid (priv->config.reset_n_io)) { -nfc_info (priv->dev,"reset the chip\n" ); -gpio_set_value (priv->config.reset_n_io,0 ); -usleep_range (5000 ,10000 ); -gpio_set_value (priv->config.reset_n_io,1 ); - }else -nfc_info (priv->dev,"no reset available on this interface\n" ); +nfc_info (priv->dev,"reset the chip\n" ); +gpiod_set_value (priv->reset_n_io,0 ); +usleep_range (5000 ,10000 );
Side note, this would be nice to use fsleep(), but I see that's just a copy'n'paste of the original piece.
Quoted 1 line
drivers/nfc/nfcmrvl/main.c +1
-0+gpiod_set_value (priv->reset_n_io,1 );
...
drivers/nfc/nfcmrvl/main.c void nfcmrvl_chip_reset(struct nfcmrvl_private *priv) · line 240
Quoted 5 lines
void
nfcmrvl_chip_halt(struct nfcmrvl_private *priv){drivers/nfc/nfcmrvl/main.c +1
-2-if (gpio_is_valid (priv->config.reset_n_io)) -gpio_set_value (priv->config.reset_n_io,0 ); +if (priv->reset_n_io)
Not sure why we need this dup check.
Quoted 2 lines
(quoted diff) +1
-0+ gpiod_set_value(priv->reset_n_io, 0); }
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 19/21] usb: udc: pxa: remove unused platform_data
In reply to Arnd BergmannQuoted 7 lines · Arnd Bergmann
None of the remaining boards put useful data into the
platform_datastructures, so effectively this only works with DT based probing.Remove all code that references this data, to stop using the legacy gpiolib interfaces. The pxa27x version already supports gpio descriptors, while the pxa25x version now does it the same way.
See a comment below.
...
Quoted 16 lines
static int
pxa_udc_probe(struct platform_device *pdev){drivers/usb/gadget/udc/pxa27x_udc.c +0
-13struct pxa_udc *udc = &memory; -int retval =0 , gpio; -struct pxa2xx_udc_mach_info *mach =dev_get_platdata (&pdev->dev); - -if (mach) { - gpio = mach->gpio_pullup; -if (gpio_is_valid (gpio)) { - retval =devm_gpio_request_one (&pdev->dev, gpio, -GPIOF_OUT_INIT_LOW , -"USB D+ pullup" ); -if (retval) -return retval; - udc->gpiod =gpio_to_desc (mach->gpio_pullup); -
drivers/usb/gadget/udc/pxa27x_udc.c MODULE_DEVICE_TABLE(of, udc_pxa_dt_ids); · line 2351
Quoted 10 lines
drivers/usb/gadget/udc/pxa27x_udc.c +3
-7-if (mach->gpio_pullup_inverted ^gpiod_is_active_low (udc->gpiod)) -gpiod_toggle_active_low (udc->gpiod); - } - udc->udc_command = mach->udc_command; - }else { - udc->gpiod =devm_gpiod_get (&pdev->dev,NULL ,GPIOD_ASIS ); - } +int retval =0 ; + + udc->gpiod =devm_gpiod_get (&pdev->dev,NULL ,GPIOD_ASIS );
Missed error check, in particular it will ignore deferred probe case.
Quoted 1 line
udc->regs=devm_platform_ioremap_resource(pdev, 0);
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 21/21] gpiolib: turn off legacy interface by default
In reply to Arnd BergmannQuoted 5 lines · Arnd Bergmann
All users of the legacy interface now select
CONFIG_GPIOLIB_LEGACY, so it can be turned off by default.Allow turning it on manually for compile testing, in order to keep the build coverage of the legacy drivers.
...
drivers/gpio/Kconfig menuconfig GPIOLIB · line 18
Quoted 3 lines
config
GPIOLIB_LEGACYdrivers/gpio/Kconfig +1
-1- def_bool y + bool "Legacy GPIO interfaces" if COMPILE_TEST
Maybe I'm missing something, but how does it supposed to be compiled for old platforms? (No, COMPILE_TEST is not a correct option for that) Perhaps you meant EXPERT ?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 05/21] x86/platform: select legacy gpiolib interfaces where used
In reply to Andy ShevchenkoQuoted 8 lines · Andy Shevchenko
Quoted 6 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_LEGACYsymbol so the code still works where it is needed but can be left out otherwise.
Quoted 12 lines
drivers/platform/x86/x86-android-tablets/Kconfig config X86_ANDROID_TABLETS · line 14
Quoted 10 lines
drivers/platform/x86/x86-android-tablets/Kconfig +1
-0@@ -8,6 +8,7 @@ config X86_ANDROID_TABLETS depends on I2C && SPI && SERIAL_DEV_BUS depends on GPIOLIB && PMIC_OPREGION depends on ACPI && EFI && PCI + select GPIOLIB_LEGACY select NEW_LEDS select LEDS_CLASS select POWER_SUPPLYHmm... This is a surprising change. But I leave it to Hans.
I think the only function that still needs it isx86_android_tablet_probe() doing
static struct gpio_keys_button *buttons;
for (i = 0; i < dev_info->gpio_button_count; i++) {
ret = x86_android_tablet_get_gpiod(dev_info->gpio_button[i].chip,
dev_info->gpio_button[i].pin,
dev_info->gpio_button[i].button.desc,
false, GPIOD_IN, &gpiod);
buttons[i] = dev_info->gpio_button[i].button;
buttons[i].gpio = desc_to_gpio(gpiod);
/* Release GPIO descriptor so that gpio-keys can request it */
devm_gpiod_put(&x86_android_tablet_device->dev, gpiod);
}So the driver itself uses gpio descriptors, but it passes some of them into another driver by number. There is probably an easy workaround that I did not see.
Arnd
Re: [PATCH 21/21] gpiolib: turn off legacy interface by default
In reply to Andy ShevchenkoQuoted 8 lines · Andy Shevchenko
Quoted 5 lines · Arnd Bergmann
All users of the legacy interface now select
CONFIG_GPIOLIB_LEGACY, so it can be turned off by default.Allow turning it on manually for compile testing, in order to keep the build coverage of the legacy drivers.
Quoted 7 lines
drivers/gpio/Kconfig menuconfig GPIOLIB · line 18
Quoted 3 lines
config
GPIOLIB_LEGACYdrivers/gpio/Kconfig +1
-1- def_bool y + bool "Legacy GPIO interfaces" if COMPILE_TESTMaybe I'm missing something, but how does it supposed to be compiled for old platforms? (No,
COMPILE_TESTis not a correct option for that) Perhaps you meant EXPERT ?
The COMPILE_TEST is really just meant for enabling some drivers that would otherwise be skipped in allmodconfig builds.
All the old platforms that use one of the GPIOLIB_LEGACY drivers select that symbol once the first six patches are merged.
Arnd
Re: [PATCH 15/21] dsa: b53: hide legacy gpiolib usage on non-mips
In reply to Jonas GorskiQuoted 5 lines · Jonas Gorski
On Fri, Aug 8, 2025 at 5:23 PM Arnd Bergmann <[email protected]> wrote:
Can't really test this (no matching hardware), but with the code issues fixed
Reviewed-by Jonas Gorski <[email protected]>
Thanks! I've added the fixes you suggested and made sure it actually builds on mips. I had done lots of randconfig tested on arm and x86, but since that code block is only built on mips, I missed my mistakes.
Arnd
Hans de Goede
maintainerRe: [PATCH 05/21] x86/platform: select legacy gpiolib interfaces where used
In reply to Arnd BergmannHi Arnd, Andy,
Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · Andy Shevchenko
Quoted 6 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_LEGACYsymbol so the code still works where it is needed but can be left out otherwise.
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
drivers/platform/x86/x86-android-tablets/Kconfig +0
-0@@ -8,6 +8,7 @@ config X86_ANDROID_TABLETS depends on I2C && SPI && SERIAL_DEV_BUSQuoted 8 lines
drivers/platform/x86/x86-android-tablets/Kconfig config X86_ANDROID_TABLETS · line 14
Quoted 6 lines
drivers/platform/x86/x86-android-tablets/Kconfig +1
-0depends on GPIOLIB && PMIC_OPREGION depends on ACPI && EFI && PCI + select GPIOLIB_LEGACY select NEW_LEDS select LEDS_CLASS select POWER_SUPPLYHmm... This is a surprising change. But I leave it to Hans.
Yes I was surprised by this myself since I explicitly removed all legacy GPIO use from the x86-android-tablets code a while ago (or so I thought).
Quoted 17 lines
I think the only function that still needs it is
x86_android_tablet_probe()doingstatic struct
gpio_keys_button*buttons;for (i = 0; i < dev_info->gpio_button_count; i++) { ret = x86_android_tablet_get_gpiod(dev_info->gpio_button[i].chip, dev_info->gpio_button[i].pin, dev_info->gpio_button[i].button.desc, false, GPIOD_IN, &gpiod); buttons[i] = dev_info->gpio_button[i].button; buttons[i].gpio = desc_to_gpio(gpiod); /* Release GPIO descriptor so that gpio-keys can request it */ devm_gpiod_put(&x86_android_tablet_device->dev, gpiod); }
Quoted 3 lines
So the driver itself uses gpio descriptors, but it passes some of them into another driver by number. There is probably an easy workaround that I did not see.
Ah I see, so this is basically in the same boat as drivers/input/misc/soc_button_array.c which also first gets a gpio_desc and then calls desc_to_gpio() to store the GPIO number in struct gpio_keys_button which is passed as platform_data to drivers/input/keyboard/gpio_keys.c
The gpio_keys driver then converts things back
into a gpio_desc in gpio_keys_setup_key()
using devm_gpio_request_one() + gpio_to_desc()
So it looks like we need to add a gpiod member to struct gpio_keys_button (include/linux/gpio_keys.h) and modify gpio_keys.c to prefer that over using button->gpio, something like the attached patch basically.
I won't have time to work on this until September, so if someone wants to take the attached patch and run with it go for it.
Note the x86-android-tablets / soc_button_array code will become responsible for requesting / releasing the gpiod when using the new gpio_keys_button.gpiod member.
For the x86-android-tablets code this is easy, just drop these 2 lines:
/* Release GPIO descriptor so that gpio-keys can request it */
devm_gpiod_put(&x86_android_tablet_device->dev, gpiod);And for soc_button_array.c it is _probably_ just a matter of switching to devm_gpiod_get_index() and drop the gpiod_put().
I have hardware to test both the x86-android-tablets code as well as the soc_button_array code. I might be able to do a quick test on August 22nd or 29th.
Regards,
Hans
p.s.
It looks like this will also help with:
drivers/platform/x86/meraki-mx100.cdrivers/platform/x86/pcengines-apuv2.cdrivers/platform/x86/barco-p50-gpio.c
I do not have hardware to test these, but if the changes work for x86-android-tablets + soc_button_array then hopefully they will be fine here too.
From 6fe4bd731db59bb01cc0ce3cbd2412434ea053c6 Mon Sep 17 00:00:00 2001
From: Hans de Goede <[email protected]>
Date: Sun, 10 Aug 2025 16:58:01 +0200
Subject: [PATCH] Input: gpio-keys - Allow directly passing a gpio_desc instead
of a GPIO number
Using GPIO numbers is deprecated. Allow code passing GPIO-keys info through platform-data (struct gpio_keys_button) to directly pass a gpio_desc instead of a GPIO number.
Note requesting / releasing the gpio_desc will be the responsibility of the code passing in the platform-data.
--- drivers/input/keyboard/gpio_keys.c | 2 ++ include/linux/gpio_keys.h | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/input/keyboard/gpio_keys.c +2 -0
@@ -528,6 +528,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,*/ bdata->gpiod =NULL ; } + }else if (button->gpiod) { + bdata->gpiod = button->gpiod; }else if (gpio_is_valid (button->gpio)) {/* * Legacy GPIO number, so request the GPIO here and
include/linux/gpio_keys.h +4 -1
@@ -5,11 +5,13 @@#include <linux/types.h> struct device ; +struct gpio_desc ;/** * struct gpio_keys_button - configuration parameters * @code: input event code (KEY_*, SW_*) -* @gpio: %-1 if this key does not support gpio +* @gpio: %-1 if this key does not support gpio (deprecated use gpiod) +* @gpiod: gpio_desc for the GPIO, NULL if this key does not support gpio * @active_low: %true indicates that button is considered * depressed when gpio is low * @desc: label that will be attached to button's gpio
@@ -26,6 +28,7 @@ struct device;struct gpio_keys_button {unsigned int code;int gpio; +struct gpio_desc *gpiod;int active_low;const char *desc;unsigned int type;
Signature · 1 line
2.49.0
Dmitry Torokhov
maintainerRe: [PATCH 05/21] x86/platform: select legacy gpiolib interfaces where used
Hi Hans,
Quoted 81 lines · Hans de Goede
Hi Arnd, Andy,
Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · Andy Shevchenko
Quoted 6 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_LEGACYsymbol so the code still works where it is needed but can be left out otherwise.Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
drivers/platform/x86/x86-android-tablets/Kconfig +0
-0@@ -8,6 +8,7 @@ config X86_ANDROID_TABLETS depends on I2C && SPI && SERIAL_DEV_BUSQuoted 8 lines
drivers/platform/x86/x86-android-tablets/Kconfig config X86_ANDROID_TABLETS · line 14
Quoted 6 lines
drivers/platform/x86/x86-android-tablets/Kconfig +1
-0depends on GPIOLIB && PMIC_OPREGION depends on ACPI && EFI && PCI + select GPIOLIB_LEGACY select NEW_LEDS select LEDS_CLASS select POWER_SUPPLYHmm... This is a surprising change. But I leave it to Hans.
Yes I was surprised by this myself since I explicitly removed all legacy GPIO use from the x86-android-tablets code a while ago (or so I thought).
Quoted 17 lines
I think the only function that still needs it is
x86_android_tablet_probe()doingstatic struct
gpio_keys_button*buttons;for (i = 0; i < dev_info->gpio_button_count; i++) { ret = x86_android_tablet_get_gpiod(dev_info->gpio_button[i].chip, dev_info->gpio_button[i].pin, dev_info->gpio_button[i].button.desc, false, GPIOD_IN, &gpiod); buttons[i] = dev_info->gpio_button[i].button; buttons[i].gpio = desc_to_gpio(gpiod); /* Release GPIO descriptor so that gpio-keys can request it */ devm_gpiod_put(&x86_android_tablet_device->dev, gpiod); }Quoted 3 lines
So the driver itself uses gpio descriptors, but it passes some of them into another driver by number. There is probably an easy workaround that I did not see.
Ah I see, so this is basically in the same boat as
drivers/input/misc/soc_button_array.cwhich also first gets agpio_descand then callsdesc_to_gpio()to store the GPIO number in structgpio_keys_buttonwhich is passed asplatform_datatodrivers/input/keyboard/gpio_keys.cThe
gpio_keysdriver then converts things back
into agpio_descingpio_keys_setup_key()
usingdevm_gpio_request_one()+gpio_to_desc()So it looks like we need to add a gpiod member to struct
gpio_keys_button(include/linux/gpio_keys.h) and modifygpio_keys.cto prefer that over usingbutton->gpio, something like the attached patch basically.I won't have time to work on this until September, so if someone wants to take the attached patch and run with it go for it.
Note the x86-android-tablets /
soc_button_arraycode will become responsible for requesting / releasing the gpiod when using the new gpio_keys_button.gpiod member.For the x86-android-tablets code this is easy, just drop these 2 lines:
/* Release GPIO descriptor so that gpio-keys can request it */ devm_gpiod_put(&x86_android_tablet_device->dev, gpiod);
Quoted 7 lines
And for
soc_button_array.cit is _probably_ just a matter of switching todevm_gpiod_get_index()and drop thegpiod_put().I have hardware to test both the x86-android-tablets code as well as the
soc_button_arraycode. I might be able to do a quick test on August 22nd or 29th.
I just sent out a v2 of my series from '23 converting x86-android-tablets to use PROPERTY_ENTRY_GPIO(), including converting buttons and switches:
https://lore.kernel.org/all/[email protected]/
I do not have hardware so it probably is busted but if you could make it work that would be great.
Thanks.
Signature · 1 line
Dmitry
Re: [PATCH 17/21] nfc: marvell: convert to gpio descriptors
In reply to Arnd BergmannQuoted 7 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The only reason this driver seems to still use the legacy gpio numbers is for the module parameter that lets users pass a different reset gpio.
Quoted 6 lines
Since the fixed numbers are on their way out, and none of the platforms this driver is used on would have them any more, remove the module parameter and instead just use the reset information from firmware.
Signed-off-by Arnd Bergmann <[email protected]>---
Yes, please!
Re: [PATCH 01/21] ARM: select legacy gpiolib interfaces where used
In reply to Arnd BergmannQuoted 9 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_LEGACYsymbol so the code still works where it is needed but can be left out otherwise.Signed-off-by Arnd Bergmann <[email protected]>---
Best regards,
Krzysztof
Matti Vaittinen
maintainerRe: [PATCH 09/21] input: gpio-keys: make legacy gpiolib optional
In reply to Arnd BergmannHi dee Ho peeps,
Quoted 101 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.
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/input/keyboard/gpio_keys.c | 5 +++-- drivers/input/keyboard/gpio_keys_polled.c | 2 ++ drivers/mfd/rohm-bd71828.c | 2 ++ drivers/mfd/rohm-bd718x7.c | 2 ++ include/linux/gpio_keys.h | 2 ++ 5 files changed, 11 insertions(+), 2 deletions(-)drivers/input/keyboard/gpio_keys.c +3
-2@@ -528,6 +528,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,*/ bdata->gpiod =NULL ; } +#ifdef CONFIG_GPIOLIB_LEGACY }else if (gpio_is_valid (button->gpio)) {/* * Legacy GPIO number, so request the GPIO here and @@ -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@@ -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 +2
-0@@ -21,7 +21,9 @@static struct gpio_keys_button button = { .code =KEY_POWER , +#ifdef CONFIG_GPIOLIB_LEGACY .gpio =-1 , +#endif .type =EV_KEY , };drivers/mfd/rohm-bd718x7.c +2
-0@@ -20,7 +20,9 @@static struct gpio_keys_button button = { .code =KEY_POWER , +#ifdef CONFIG_GPIOLIB_LEGACY .gpio =-1 , +#endif .type =EV_KEY , };include/linux/gpio_keys.h +0
-0
include/linux/gpio_keys.h struct device; · line 33
Quoted 9 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;const char *desc;unsigned int type;
AFAIR, these ROHM PMICs (bd718[15, 27, 28, 37, 47, 50, 78, 85]) all provide a 'button IRQ', from a power button. (Or, couple of IRQs but let's skip the details) The gpio-keys is used to send the KEY_POWER event when IRQ is detected.
The IRQ comes from the PMIC, and the regmap_irq chip provided by the MFD provides it. This IRQ information is delivered to the gpio-keys from the MFD driver via platform data. That's basically what these "button" structs are here for. No GPIO line information (only the IRQ number) is needed to be delivered to the gpio-keys. This problematic assignment:
include/linux/gpio_keys.h
Quoted 3 lines
include/linux/gpio_keys.h +2
-0+#ifdef CONFIG_GPIOLIB_LEGACY .gpio = -1, +#endif
is only needed to invalidate the gpio information so that the gpio-keys wont use it, only the IRQ.
As such, this patch seems Ok to me, you can treat this as an ack :) This, however made me ponder following - is this the tight way to handle the power-button IRQ? I don't see any other MFD devices doing this in same way, although I am pretty sure there are other PMICs with similar power-button IRQ...
I see for example the "drivers/mfd/rt5120.c" to invoke "drivers/input/misc/rt5120-pwrkey.c" instead of using the gpio-keys. This, however, feels like code duplication to me. I'd rather kept using the gpio-keys, but seeing:
git grep KEY_POWER drivers/mfd/
drivers/mfd/rohm-bd71828.c: .code = KEY_POWER, drivers/mfd/rohm-bd718x7.c: .code = KEY_POWER,
makes me wonder if there is more widely used (better) way?
Yours,
-- Matti
Re: [PATCH 21/21] gpiolib: turn off legacy interface by default
In reply to Arnd BergmannQuoted 17 lines · Arnd Bergmann
Quoted 8 lines · Andy Shevchenko
Quoted 5 lines · Arnd Bergmann
All users of the legacy interface now select
CONFIG_GPIOLIB_LEGACY, so it can be turned off by default.Allow turning it on manually for compile testing, in order to keep the build coverage of the legacy drivers.
Quoted 7 lines
drivers/gpio/Kconfig menuconfig GPIOLIB · line 18
Quoted 3 lines
config
GPIOLIB_LEGACYdrivers/gpio/Kconfig +1
-1- def_bool y + bool "Legacy GPIO interfaces" if COMPILE_TESTMaybe I'm missing something, but how does it supposed to be compiled for old platforms? (No,
COMPILE_TESTis not a correct option for that) Perhaps you meant EXPERT ?
Quoted 5 lines
The
COMPILE_TESTis really just meant for enabling some drivers that would otherwise be skipped in allmodconfig builds.All the old platforms that use one of the
GPIOLIB_LEGACYdrivers select that symbol once the first six patches are merged.
Ah, that makes sense. Perhaps a word to be added into commit message?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 09/21] input: gpio-keys: make legacy gpiolib optional
In reply to Matti VaittinenQuoted 1 line · Matti Vaittinen
On 08/08/2025 18:17, Arnd Bergmann wrote:
...
Quoted 11 lines
As such, this patch seems Ok to me, you can treat this as an ack :) This, however made me ponder following - is this the tight way to handle the power-button IRQ? I don't see any other MFD devices doing this in same way, although I am pretty sure there are other PMICs with similar power-button IRQ...
I see for example the "
drivers/mfd/rt5120.c" to invoke "drivers/input/misc/rt5120-pwrkey.c" instead of using the gpio-keys. This, however, feels like code duplication to me. I'd rather kept using the gpio-keys, but seeing:
Quoted 5 lines
git grep
KEY_POWERdrivers/mfd/drivers/mfd/rohm-bd71828.c: .code = KEY_POWER, drivers/mfd/rohm-bd718x7.c: .code = KEY_POWER,makes me wonder if there is more widely used (better) way?
FWIW, on Intel platforms that use power button by PMIC we add a special driver for each of such cases.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 13 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Commit
678bae2eaa81("gpiolib: make legacy interfaces optional") was merged for linux-6.17, so now it is possible to use the legacy interfaces conditionally and eventually have the support left out of the kernel whenever it is not needed.I created six patches to force-enable
CONFIG_GPIOLIB_LEGACYon the few (mostly ancient) platforms that still require this, plus a set of patches to either add the correspondingKconfigdependencies that make the device drivers conditional on that symbol, or change them to no longer require it.
Quoted 8 lines
The final patch ends up turning the
Kconfigsymbol off by default, which of course depends on everything else getting merged first to avoid build errors.I would suggest that patches 1-20 can just get merged through the respective maintainer trees independently when they are deemed ready, and the final patch can wait another merge window.
Oh, not at all, I'm fine sending a second PR late into the merge window to get that done in a single cycle.
Thanks for doing this, awesome work!
Bartosz
Re: [PATCH 07/21] mfd: wm8994: remove dead legacy-gpio code
In reply to Arnd BergmannQuoted 7 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The old-style gpio handling in wm8994 came from a commit
7c8844481a1c("mfd: wm8994: Emulate level triggered interrupts if required") in linux-3.11, but nothing in the kernel ever set the 'irq_gpio' member in thewm8994_pdatastructure, so this was always dead code.
Quoted 5 lines
Remove it now to reduce the dependency on the legacy gpio interfaces.
Signed-off-by Arnd Bergmann <[email protected]>---
Dmitry Torokhov
maintainerRe: [PATCH 09/21] input: gpio-keys: make legacy gpiolib optional
In reply to Andy ShevchenkoQuoted 16 lines · Andy Shevchenko
Quoted 1 line · Matti Vaittinen
On 08/08/2025 18:17, Arnd Bergmann wrote:
...
Quoted 11 lines
As such, this patch seems Ok to me, you can treat this as an ack :) This, however made me ponder following - is this the tight way to handle the power-button IRQ? I don't see any other MFD devices doing this in same way, although I am pretty sure there are other PMICs with similar power-button IRQ...
I see for example the "
drivers/mfd/rt5120.c" to invoke "drivers/input/misc/rt5120-pwrkey.c" instead of using the gpio-keys. This, however, feels like code duplication to me. I'd rather kept using the gpio-keys, but seeing:
Quoted 8 lines
Quoted 5 lines
git grep
KEY_POWERdrivers/mfd/drivers/mfd/rohm-bd71828.c: .code = KEY_POWER, drivers/mfd/rohm-bd718x7.c: .code = KEY_POWER,makes me wonder if there is more widely used (better) way?
FWIW, on Intel platforms that use power button by PMIC we add a special driver for each of such cases.
If we can make gpio-keys work for various power buttons that would be great IMO. The MFD drivers in question already are using device tree, but they do not define/expect nodes for the power buttons. If the nodes were there then I think gpio-keys would work out of the box?
Thanks.
Signature · 1 line
Dmitry
Re: [PATCH 09/21] input: gpio-keys: make legacy gpiolib optional
Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Matti Vaittinen
On 08/08/2025 18:17, Arnd Bergmann wrote:
...
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
As such, this patch seems Ok to me, you can treat this as an ack :) This, however made me ponder following - is this the tight way to handle the power-button IRQ? I don't see any other MFD devices doing this in same way, although I am pretty sure there are other PMICs with similar power-button IRQ...
I see for example the "
drivers/mfd/rt5120.c" to invoke "drivers/input/misc/rt5120-pwrkey.c" instead of using the gpio-keys. This, however, feels like code duplication to me. I'd rather kept using the gpio-keys, but seeing:git grep
KEY_POWERdrivers/mfd/drivers/mfd/rohm-bd71828.c: .code = KEY_POWER, drivers/mfd/rohm-bd718x7.c: .code = KEY_POWER,makes me wonder if there is more widely used (better) way?
Quoted 7 lines
Quoted 2 lines
FWIW, on Intel platforms that use power button by PMIC we add a special driver for each of such cases.
If we can make gpio-keys work for various power buttons that would be great IMO. The MFD drivers in question already are using device tree, but they do not define/expect nodes for the power buttons. If the nodes were there then I think gpio-keys would work out of the box?
Looking at the, e.g., https://elixir.bootlin.com/linux/v6.16/source/drivers/platform/x86/intel/mrfld_pwrbtn.c,
I am not sure it's as simply as it sounds. Basically it's an IRQ, which
requires IRQ handling and proper acking/masking/etc.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Dmitry Torokhov
maintainerRe: [PATCH 17/21] nfc: marvell: convert to gpio descriptors
In reply to Andy ShevchenkoQuoted 18 lines · Andy Shevchenko
Quoted 9 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The only reason this driver seems to still use the legacy gpio numbers is for the module parameter that lets users pass a different reset gpio.
Since the fixed numbers are on their way out, and none of the platforms this driver is used on would have them any more, remove the module parameter and instead just use the reset information from firmware.
This patch is my love in the series, thanks for doing it!
Reviewed-by Andy Shevchenko <[email protected]>But note some comments below.
...
Quoted 9 lines
drivers/nfc/nfcmrvl/main.c struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy, · line 115
Quoted 9 lines
drivers/nfc/nfcmrvl/main.c +1
-8-if (gpio_is_valid (priv->config.reset_n_io)) { - rc =gpio_request_one (priv->config.reset_n_io, -GPIOF_OUT_INIT_LOW , -"nfcmrvl_reset_n" ); -if (rc <0 ) { - priv->config.reset_n_io = -EINVAL ; -nfc_err (dev,"failed to request reset_n io\n" ); - } + priv->reset_n_io =gpiod_get_optional (dev,"reset-n-io" ,GPIOD_OUT_LOW );
No, this should be "reset". gpiolib-of.c has a quirk to resolve to naked "reset-n-io", otherwise this will resolve to "reset-n-io-gpios" in the bowels of gpiolib.
Quoted 6 lines
drivers/nfc/nfcmrvl/main.c struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy, · line 119
Quoted 4 lines
drivers/nfc/nfcmrvl/main.c +3
-0+if (IS_ERR (priv->reset_n_io)) { +nfc_err (dev,"failed to get reset_n gpio\n" ); +return ERR_CAST (priv->reset_n_io); }This also needs a call to
gpiod_set_consumer_name(), IIRC the API name.
It does not have to... I am not sure who pays attention to names.
Quoted 17 lines
...
drivers/nfc/nfcmrvl/main.c void nfcmrvl_chip_reset(struct nfcmrvl_private *priv) · line 234
Quoted 10 lines
drivers/nfc/nfcmrvl/main.c +3
-7-if (gpio_is_valid (priv->config.reset_n_io)) { -nfc_info (priv->dev,"reset the chip\n" ); -gpio_set_value (priv->config.reset_n_io,0 ); -usleep_range (5000 ,10000 ); -gpio_set_value (priv->config.reset_n_io,1 ); - }else -nfc_info (priv->dev,"no reset available on this interface\n" ); +nfc_info (priv->dev,"reset the chip\n" ); +gpiod_set_value (priv->reset_n_io,0 ); +usleep_range (5000 ,10000 );Side note, this would be nice to use
fsleep(), but I see that's just a copy'n'paste of the original piece.
Quoted 1 line
drivers/nfc/nfcmrvl/main.c void nfcmrvl_chip_reset(struct nfcmrvl_private *priv) · line 235
Quoted 1 line
drivers/nfc/nfcmrvl/main.c +1
-0+gpiod_set_value (priv->reset_n_io,1 );
Nope, this is not going to work. See Documentation/devicetree/bindings/net/nfc/marvell,nci.yaml, this GPIO is active low. We do not have any "live" DTS examples so I am not sure what polarity is used in the wild. So either use logical level (my preference) or switch to "_raw()" variant.
Quoted 10 lines
...
drivers/nfc/nfcmrvl/main.c void nfcmrvl_chip_reset(struct nfcmrvl_private *priv) · line 240
Quoted 5 lines
void
nfcmrvl_chip_halt(struct nfcmrvl_private *priv){drivers/nfc/nfcmrvl/main.c +1
-2-if (gpio_is_valid (priv->config.reset_n_io)) -gpio_set_value (priv->config.reset_n_io,0 ); +if (priv->reset_n_io)Not sure why we need this dup check.
I personally feel very uneasy when dealing with optional GPIO and not checking if it exists or not, even though gpiod_set_value() handles this. I think check makes logic clearer.
Quoted 4 lines
Review
Quoted 3 lines
(quoted diff) +1
-0+ gpiod_set_value(priv->reset_n_io, 0); }
Thanks.
Signature · 1 line
Dmitry
Dmitry Torokhov
maintainerRe: [PATCH 18/21] nfc: s3fwrn5: convert to gpio descriptors
In reply to Arnd BergmannHi Arnd,
Quoted 40 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
There is no need for this driver to still use the legacy interfaces, so convert all the legacy calls into their modern equivalents.
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/nfc/s3fwrn5/i2c.c | 42 +++++++++----------------------- drivers/nfc/s3fwrn5/phy_common.c | 12 ++++----- drivers/nfc/s3fwrn5/phy_common.h | 4 +-- drivers/nfc/s3fwrn5/uart.c | 30 ++++++----------------- 4 files changed, 28 insertions(+), 60 deletions(-)drivers/nfc/s3fwrn5/i2c.c +4
-7@@ -8,7 +8,7 @@#include <linux/clk.h> #include <linux/i2c.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/delay.h> #include <linux/of_gpio.h> #include <linux/of_irq.h> @@ -149,29 +149,22 @@ static irqreturn_t s3fwrn5_i2c_irq_thread_fn(int irq, void *phy_id)static int s3fwrn5_i2c_parse_dt (struct i2c_client *client) {struct s3fwrn5_i2c_phy *phy =i2c_get_clientdata (client); -struct device_node *np = client->dev.of_node; +struct device *dev = &client->dev; -if (!np) -return -ENODEV ; - - phy->common.gpio_en =of_get_named_gpio (np,"en-gpios" ,0 ); -if (!gpio_is_valid (phy->common.gpio_en)) { + phy->common.gpio_en =devm_gpiod_get (dev,"en" ,GPIOD_OUT_HIGH ); +if (IS_ERR (phy->common.gpio_en)) {
drivers/nfc/s3fwrn5/i2c.c static irqreturn_t s3fwrn5_i2c_irq_thread_fn(int irq, void *phy_id) · line 160
Quoted 10 lines
drivers/nfc/s3fwrn5/i2c.c +3
-5/* Support also deprecated property */ - phy->common.gpio_en =of_get_named_gpio (np, -"s3fwrn5,en-gpios" , -0 ); -if (!gpio_is_valid (phy->common.gpio_en)) -return -ENODEV ; + phy->common.gpio_en =devm_gpiod_get (dev,"s3fwrn5,en" ,GPIOD_OUT_HIGH ); +if (IS_ERR (phy->common.gpio_en)) +return PTR_ERR (phy->common.gpio_en); }
Should be GPIOD_OUT_LOW or ASIS.
Quoted 64 lines
drivers/nfc/s3fwrn5/i2c.c +5
-18- phy->common.gpio_fw_wake =of_get_named_gpio (np,"wake-gpios" ,0 ); -if (!gpio_is_valid (phy->common.gpio_fw_wake)) { + phy->common.gpio_fw_wake =devm_gpiod_get (dev,"wake" ,GPIOD_OUT_LOW ); +if (IS_ERR (phy->common.gpio_fw_wake)) {/* Support also deprecated property */ - phy->common.gpio_fw_wake =of_get_named_gpio (np, -"s3fwrn5,fw-gpios" , -0 ); -if (!gpio_is_valid (phy->common.gpio_fw_wake)) -return -ENODEV ; + phy->common.gpio_fw_wake =devm_gpiod_get (dev,"s3fwrn5,fw" ,GPIOD_OUT_LOW ); +if (IS_ERR (phy->common.gpio_fw_wake)) +return PTR_ERR (phy->common.gpio_en); }return 0 ;@@ -197,17 +190,6 @@ static int s3fwrn5_i2c_probe(struct i2c_client *client)if (ret <0 )return ret; - ret =devm_gpio_request_one (&phy->i2c_dev->dev, phy->common.gpio_en, -GPIOF_OUT_INIT_HIGH ,"s3fwrn5_en" ); -if (ret <0 ) -return ret; - - ret =devm_gpio_request_one (&phy->i2c_dev->dev, - phy->common.gpio_fw_wake, -GPIOF_OUT_INIT_LOW ,"s3fwrn5_fw_wake" ); -if (ret <0 ) -return ret; -/* * S3FWRN5 depends on a clock input ("XI" pin) to function properly. * Depending on the hardware configuration this could be an always-on drivers/nfc/s3fwrn5/phy_common.c +3
-4@@ -8,7 +8,7 @@* Bongsu Jeon <[email protected]> */ -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/delay.h> #include <linux/module.h> @@ -19,7 +19,7 @@ void s3fwrn5_phy_set_wake(void *phy_id, bool wake)struct phy_common *phy = phy_id;mutex_lock (&phy->mutex); -gpio_set_value (phy->gpio_fw_wake, wake); +gpiod_set_value (phy->gpio_fw_wake, wake);if (wake)msleep (S3FWRN5_EN_WAIT_TIME );mutex_unlock (&phy->mutex);@@ -33,14 +33,14 @@ bool s3fwrn5_phy_power_ctrl(struct phy_common *phy, enum s3fwrn5_mode mode) phy->mode = mode; -gpio_set_value (phy->gpio_en,1 ); -gpio_set_value (phy->gpio_fw_wake,0 ); +gpiod_set_value (phy->gpio_en,1 );
drivers/nfc/s3fwrn5/phy_common.c bool s3fwrn5_phy_power_ctrl(struct phy_common *phy, enum s3fwrn5_mode mode) · line 44
Quoted 10 lines
drivers/nfc/s3fwrn5/phy_common.c +3
-2+gpiod_set_value (phy->gpio_fw_wake,0 );if (mode ==S3FWRN5_MODE_FW ) -gpio_set_value (phy->gpio_fw_wake,1 ); +gpiod_set_value (phy->gpio_fw_wake,1 );if (mode !=S3FWRN5_MODE_COLD ) {msleep (S3FWRN5_EN_WAIT_TIME ); -gpio_set_value (phy->gpio_en,0 ); +gpiod_set_value (phy->gpio_en,0 );msleep (S3FWRN5_EN_WAIT_TIME );
The GPIO is describe as "active low" in DTS:
arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
So here you are leaving the chip disabled. You need to use logical polarity.
Thanks.
Signature · 1 line
Dmitry
Dmitry Torokhov
maintainerRe: [PATCH 19/21] usb: udc: pxa: remove unused platform_data
In reply to Arnd BergmannQuoted 146 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
None of the remaining boards put useful data into the
platform_datastructures, so effectively this only works with DT based probing.Remove all code that references this data, to stop using the legacy gpiolib interfaces. The pxa27x version already supports gpio descriptors, while the pxa25x version now does it the same way.
Signed-off-by Arnd Bergmann <[email protected]>--- arch/arm/mach-pxa/devices.c | 7 ---- arch/arm/mach-pxa/gumstix.c | 1 - arch/arm/mach-pxa/udc.h | 8 ----- drivers/usb/gadget/udc/pxa25x_udc.c | 41 ++++++++---------------- drivers/usb/gadget/udc/pxa25x_udc.h | 2 +- drivers/usb/gadget/udc/pxa27x_udc.c | 35 +++----------------- drivers/usb/gadget/udc/pxa27x_udc.h | 2 -- include/linux/platform_data/pxa2xx_udc.h | 15 --------- 8 files changed, 19 insertions(+), 92 deletions(-) delete mode 100644 arch/arm/mach-pxa/udc.harch/arm/mach-pxa/devices.c +0
-7@@ -11,7 +11,6 @@#include <linux/platform_data/i2c-pxa.h> #include <linux/soc/pxa/cpu.h> -#include "udc.h" #include <linux/platform_data/video-pxafb.h> #include <linux/platform_data/mmc-pxamci.h> #include "irqs.h" @@ -83,10 +82,6 @@ void __init pxa_set_mci_info(const struct pxamci_platform_data *info,pr_err ("Unable to create mci device: %d\n" , err); } -static struct pxa2xx_udc_mach_info pxa_udc_info = { - .gpio_pullup =-1 , -}; -static struct resource pxa2xx_udc_resources[] = { [0 ] = { .start =0x40600000 ,@@ -108,7 +103,6 @@ struct platform_device pxa25x_device_udc = { .resource = pxa2xx_udc_resources, .num_resources = ARRAY_SIZE(pxa2xx_udc_resources), .dev = { - .platform_data = &pxa_udc_info, .dma_mask = &udc_dma_mask, } };@@ -119,7 +113,6 @@ struct platform_device pxa27x_device_udc = { .resource = pxa2xx_udc_resources, .num_resources = ARRAY_SIZE(pxa2xx_udc_resources), .dev = { - .platform_data = &pxa_udc_info, .dma_mask = &udc_dma_mask, } };arch/arm/mach-pxa/gumstix.c +0
-1@@ -39,7 +39,6 @@#include "pxa25x.h" #include <linux/platform_data/mmc-pxamci.h> -#include "udc.h" #include "gumstix.h" #include "devices.h" arch/arm/mach-pxa/udc.h deleted +0
-8@@ -1,8 +0,0 @@ -/* -* arch/arm/mach-pxa/include/mach/udc.h -* -*/ -#include <linux/platform_data/pxa2xx_udc.h> - -extern void pxa_set_udc_info (struct pxa2xx_udc_mach_info *info); -drivers/usb/gadget/udc/pxa25x_udc.c +4
-19@@ -12,7 +12,7 @@/* #define VERBOSE_DEBUG */ #include <linux/device.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/ioport.h> @@ -261,24 +261,12 @@ static void nuke (struct pxa25x_ep *, int status);/* one GPIO should control a D+ pullup, so host sees this device (or not) */ static void pullup_off (void ) { -struct pxa2xx_udc_mach_info *mach = the_controller->mach; -int off_level = mach->gpio_pullup_inverted; - -if (gpio_is_valid (mach->gpio_pullup)) -gpio_set_value (mach->gpio_pullup, off_level); -else if (mach->udc_command) - mach->udc_command (PXA2XX_UDC_CMD_DISCONNECT ); +gpiod_set_value (the_controller->pullup_gpio,0 ); }static void pullup_on (void ) { -struct pxa2xx_udc_mach_info *mach = the_controller->mach; -int on_level = !mach->gpio_pullup_inverted; - -if (gpio_is_valid (mach->gpio_pullup)) -gpio_set_value (mach->gpio_pullup, on_level); -else if (mach->udc_command) - mach->udc_command (PXA2XX_UDC_CMD_CONNECT ); +gpiod_set_value (the_controller->pullup_gpio,1 ); }#if defined(CONFIG_CPU_BIG_ENDIAN )@@ -1190,8 +1178,7 @@ static int pxa25x_udc_pullup(struct usb_gadget *_gadget, int is_active) udc = container_of(_gadget, struct pxa25x_udc, gadget); -/* not all boards support pullup control */ -if (!gpio_is_valid (udc->mach->gpio_pullup) && !udc->mach->udc_command) +if (!udc->pullup_gpio)return -EOPNOTSUPP ; udc->pullup = (is_active !=0 );@@ -2343,19 +2330,17 @@ static int pxa25x_udc_probe(struct platform_device *pdev)/* other non-static parts of init */ dev->dev = &pdev->dev; - dev->mach =dev_get_platdata (&pdev->dev); dev->transceiver =devm_usb_get_phy (&pdev->dev,USB_PHY_TYPE_USB2 ); -if (gpio_is_valid (dev->mach->gpio_pullup)) {
drivers/usb/gadget/udc/pxa25x_udc.c static int pxa25x_udc_probe(struct platform_device *pdev) · line 2337
Quoted 10 lines
drivers/usb/gadget/udc/pxa25x_udc.c +2
-8- retval =devm_gpio_request_one (&pdev->dev, dev->mach->gpio_pullup, -GPIOF_OUT_INIT_LOW ,"pca25x_udc GPIO PULLUP" ); -if (retval) { -dev_dbg (&pdev->dev, -"can't get pullup gpio %d, err: %d\n" , - dev->mach->gpio_pullup, retval); - goto err; - } + dev->pullup_gpio =devm_gpiod_get_index_optional (&pdev->dev,"pullup" ,0 , +GPIOD_OUT_LOW );
I think this should be GPIOD_OUT_HIGH: you want this to be active and GPIO is likely "active low".
Thanks.
Signature · 1 line
Dmitry
Matti Vaittinen
maintainerRe: [PATCH 09/21] input: gpio-keys: make legacy gpiolib optional
In reply to Andy ShevchenkoQuoted 27 lines · Andy Shevchenko
Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Matti Vaittinen
On 08/08/2025 18:17, Arnd Bergmann wrote:
...
Quoted 20 lines
Quoted 19 lines
Quoted 11 lines
As such, this patch seems Ok to me, you can treat this as an ack :) This, however made me ponder following - is this the tight way to handle the power-button IRQ? I don't see any other MFD devices doing this in same way, although I am pretty sure there are other PMICs with similar power-button IRQ...
I see for example the "
drivers/mfd/rt5120.c" to invoke "drivers/input/misc/rt5120-pwrkey.c" instead of using the gpio-keys. This, however, feels like code duplication to me. I'd rather kept using the gpio-keys, but seeing:Quoted 5 lines
git grep
KEY_POWERdrivers/mfd/drivers/mfd/rohm-bd71828.c: .code = KEY_POWER, drivers/mfd/rohm-bd718x7.c: .code = KEY_POWER,makes me wonder if there is more widely used (better) way?
FWIW, on Intel platforms that use power button by PMIC we add a special driver for each of such cases.
Quoted 8 lines
Quoted 4 lines
If we can make gpio-keys work for various power buttons that would be great IMO. The MFD drivers in question already are using device tree, but they do not define/expect nodes for the power buttons. If the nodes were there then I think gpio-keys would work out of the box?
Looking at the, e.g., https://elixir.bootlin.com/linux/v6.16/source/drivers/platform/x86/intel/mrfld_pwrbtn.c,
I am not sure it's as simply as it sounds. Basically it's an IRQ, which
requires IRQ handling and proper acking/masking/etc.
In some (many?) cases the interrupts (acking/masking) are handled by an irqchip code. When this is the case, the gpio-keys (or any other power-button code) does not need to care about IRQ-specifics. (I don't know about the Intel driver though.)
Problem with many of the bd718* (and probably some other MFD drivers) is, that the interrupts are really relevant only for the drivers specific to this one device (like PMIC in ROHM case). When this is the case, the device is not really (from the HW perspective) an interrupt-controller, which means it shouldn't probably be marked as one in the device-tree either. It will then also mean that there can't be meaningful interrupt specification for the button IRQ in the device-tree, right?
Additionally, we have devices where most of the interrupts are internal to the PMIC, but then the PMIC also has some pins usable as GPIO, which can be used as interrupt sources. Eg, someone can connect another device to these pins - which makes the PMIC an interrupt-controller. For these PMICs the power-button IRQ can be provided via device-tree node (but the IRQ spec may become a bit hairy, since most of the IRQs are meant to be internal).
Hence, for me, providing the IRQ number in platform data seems still to be the right thing to do :)
TLDR; I agree with Dmitry. It's nice to have an easily re-usable power-button handler, which requires no IC-specific code. Gpio-keys works for simple IRQ based power-buttons where IRQ controller takes care of the acks/masks. I just wanted to know if it is for some reason discouraged, or if I've used it in a wrong way (because the grep resulted so few results).
Yours,
-- Matti
Mark Brown
maintainerRe: (subset) [PATCH 00/21] gpiolib: fence off legacy interfaces
In reply to Arnd BergmannQuoted 5 lines · Arnd Bergmann
Commit
678bae2eaa81("gpiolib: make legacy interfaces optional") was merged for linux-6.17, so now it is possible to use the legacy interfaces conditionally and eventually have the support left out of the kernel whenever it is not needed.
Quoted 7 lines
I created six patches to force-enable
CONFIG_GPIOLIB_LEGACYon the few (mostly ancient) platforms that still require this, plus a set of patches to either add the correspondingKconfigdependencies that make the device drivers conditional on that symbol, or change them to no longer require it.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[08/21] ASoC: add GPIOLIB_LEGACY dependency where needed
commit: 5383d67e2430822fa7bd20dcbbebbd8ae808e386
[20/21] ASoC: pxa: add GPIOLIB_LEGACY dependency
commit: 2d86d2585ab929a143d1e6f8963da1499e33bf13All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Re: [PATCH 06/21] x86/olpc: select GPIOLIB_LEGACY
In reply to Arnd BergmannQuoted 40 lines · 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);Select
CONFIG_GPIOLIB_LEGACYfor this platform and make sure the sound driver portion cannot be compiled without this.Signed-off-by Arnd Bergmann <[email protected]>--- arch/x86/Kconfig | 1 + sound/pci/Kconfig | 1 + 2 files changed, 2 insertions(+)arch/x86/Kconfig +1
-0@@ -3006,6 +3006,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_DOMAINsound/pci/Kconfig +0
-0
sound/pci/Kconfig config SND_CS5535AUDIO · line 306
Quoted 7 lines
sound/pci/Kconfig +1
-0@@ -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 · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH 04/21] sh: select legacy gpiolib interface
In reply to Arnd Bergmannarch/sh/Kconfig config CPU_SUBTYPE_SHX3 · line 466
Quoted 10 lines · Arnd Bergmann
arch/sh/Kconfig +1
-0@@ -462,6 +462,7 @@ config CPU_SUBTYPE_SHX3 select CPU_SHX3 select GENERIC_CLOCKEVENTS_BROADCAST if SMP select GPIOLIB + select GPIOLIB_LEGACY select PINCTRL
Is there a reason to have both rather than having GPIOLIB_LEGACY select GPIOLIB? (Does the legacy one ever NOT use the new one?)
Rob
Re: [PATCH 04/21] sh: select legacy gpiolib interface
Quoted 14 lines · Rob Landley
arch/sh/Kconfig config CPU_SUBTYPE_SHX3 · line 466
Quoted 10 lines · Arnd Bergmann
arch/sh/Kconfig +1
-0@@ -462,6 +462,7 @@ config CPU_SUBTYPE_SHX3 select CPU_SHX3 select GENERIC_CLOCKEVENTS_BROADCAST if SMP select GPIOLIB + select GPIOLIB_LEGACY select PINCTRLIs there a reason to have both rather than having
GPIOLIB_LEGACYselect GPIOLIB? (Does the legacy one ever NOT use the new one?)
The way I've staged the series was
1. add GPIOLIB_LEGACY as an always-enabled symbol in 6.17
2. add the 'select' and 'depends on' for that symbol in 6.18
3. turn it off for all configs that don't select it already
Having GPIOLIB_LEGACY select GPIOLIB does sound like a nice idea in stage 3, but that doesn't work with the first step that's already merged now.
Arnd
Re: [PATCH 17/21] nfc: marvell: convert to gpio descriptors
In reply to Arnd BergmannQuoted 10 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The only reason this driver seems to still use the legacy gpio numbers is for the module parameter that lets users pass a different reset gpio.
Since the fixed numbers are on their way out, and none of the platforms this driver is used on would have them any more, remove the module parameter and instead just use the reset information from firmware.
Quoted 8 lines
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/nfc/nfcmrvl/main.c | 47 +++++++++++------------------------ drivers/nfc/nfcmrvl/nfcmrvl.h | 5 ++-- drivers/nfc/nfcmrvl/uart.c | 5 ---- drivers/nfc/nfcmrvl/usb.c | 1 - 4 files changed, 18 insertions(+), 40 deletions(-)
Best regards,
Krzysztof
Re: [PATCH 17/21] nfc: marvell: convert to gpio descriptors
In reply to Dmitry TorokhovQuoted 2 lines · Dmitry Torokhov
Quoted 1 line · Andy Shevchenko
On Fri, Aug 08, 2025 at 05:18:01PM +0200, Arnd Bergmann wrote:
...
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/nfc/nfcmrvl/main.c +0
-5-if (gpio_is_valid (priv->config.reset_n_io)) { - rc =gpio_request_one (priv->config.reset_n_io, -GPIOF_OUT_INIT_LOW , -"nfcmrvl_reset_n" ); -if (rc <0 ) {
Quoted 8 lines
Quoted 4 lines
drivers/nfc/nfcmrvl/main.c struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy, · line 115
Quoted 4 lines
drivers/nfc/nfcmrvl/main.c +1
-3- priv->config.reset_n_io = -EINVAL ; -nfc_err (dev,"failed to request reset_n io\n" ); - } + priv->reset_n_io =gpiod_get_optional (dev,"reset-n-io" ,GPIOD_OUT_LOW );No, this should be "reset".
gpiolib-of.chas a quirk to resolve to naked "reset-n-io", otherwise this will resolve to "reset-n-io-gpios" in the bowels of gpiolib.
Good point.
Quoted 8 lines
Quoted 6 lines
drivers/nfc/nfcmrvl/main.c struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy, · line 119
Quoted 4 lines
drivers/nfc/nfcmrvl/main.c +3
-0+if (IS_ERR (priv->reset_n_io)) { +nfc_err (dev,"failed to get reset_n gpio\n" ); +return ERR_CAST (priv->reset_n_io); }This also needs a call to
gpiod_set_consumer_name(), IIRC the API name.It does not have to... I am not sure who pays attention to names.
It goes to user space, isn't it?
In any case it will give 1:1 transition from the look&fell perspective.
...
Quoted 11 lines
Quoted 7 lines
drivers/nfc/nfcmrvl/main.c void nfcmrvl_chip_reset(struct nfcmrvl_private *priv) · line 240
Quoted 5 lines
void
nfcmrvl_chip_halt(struct nfcmrvl_private *priv){drivers/nfc/nfcmrvl/main.c +1
-2-if (gpio_is_valid (priv->config.reset_n_io)) -gpio_set_value (priv->config.reset_n_io,0 ); +if (priv->reset_n_io)Not sure why we need this dup check.
I personally feel very uneasy when dealing with optional GPIO and not checking if it exists or not, even though
gpiod_set_value()handles this. I think check makes logic clearer.
I disagree with the duplicate. It doesn't make any additional clearness as I read it. When one reads the code the "here we set GPIO to the X state" without any conditional is fine as one may check later in DT schema if the GPIO is optional or not.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
(quoted diff) +1
-0+ gpiod_set_value(priv->reset_n_io, 0); }
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 10/21] leds: gpio: make legacy gpiolib interface optional
In reply to Arnd BergmannQuoted 10 lines · 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.
Make the code that deals with this optional so the legacy interfaces can be left out for all normal builds.
Signed-off-by Arnd Bergmann <[email protected]>
I like this, it cleans up things for current systems so they do not need to carry around so much legacy.
Yours,
Linus Walleij
Lee Jones
maintainerRe: [PATCH 10/21] leds: gpio: make legacy gpiolib interface optional
In reply to Arnd BergmannQuoted 20 lines · 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.
Make the code that deals with this optional so the legacy interfaces can be left out for all normal builds.
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/leds/leds-gpio.c | 8 ++++++-- include/linux/leds.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-)drivers/leds/leds-gpio.c +0
-0
drivers/leds/leds-gpio.c static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx, · line 217
Quoted 6 lines
drivers/leds/leds-gpio.c +2
-0@@ -212,7 +212,9 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx, const struct gpio_led *template) {struct gpio_desc *gpiod; +#ifdef CONFIG_GPIOLIB_LEGACY int ret; +#endif
Isn't there another way to do his that doesn't entail sprinkling #ifery around C-files?
Quoted 46 lines
drivers/leds/leds-gpio.c +4
-2/* * This means the LED does not come from the device tree @@ -228,6 +230,7 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,return gpiod; } +#ifdef CONFIG_GPIOLIB_LEGACY /* * This is the legacy code path for platform code that * still uses GPIO numbers. Ultimately we would like to get @@ -244,6 +247,7 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,return ERR_PTR (ret); gpiod =gpio_to_desc (template->gpio); +#endif if (!gpiod)return ERR_PTR (-EINVAL );@@ -276,8 +280,8 @@ static int gpio_led_probe(struct platform_device *pdev) led_dat->gpiod =gpio_led_get_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@@ -676,7 +676,9 @@ 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; +#endif unsigned active_low :1 ;unsigned retain_state_suspended :1 ;unsigned panic_indicator :1 ;Signature · 1 line
2.39.5
Signature · 1 line
Lee Jones [李琼斯]
Re: [PATCH 10/21] leds: gpio: make legacy gpiolib interface optional
Quoted 10 lines · Lee Jones
drivers/leds/leds-gpio.c static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx, · line 217
Quoted 5 lines · Arnd Bergmann
{
drivers/leds/leds-gpio.c +2
-0struct gpio_desc *gpiod; +#ifdef CONFIG_GPIOLIB_LEGACY int ret; +#endif Isn't there another way to do his that doesn't entail sprinkling #ifery around C-files?
An alternativew would be to duplicate the driver and have
one modern variant and an additional legacy variant that
is only used on the few remaining platforms that select CONFIG_GPIOLIB_LEGACY and define platform data. See below for the list of files that reference struct gpio_led.
There are already patches to convert some of those to software nodes, and a lot of the others can probably be removed, in particular the orion5x ones.
The leds-gpio driver with just the legacy interfaces left would be a really small driver, and removing those bits from the normal one would make that a bit simpler as well, but there would be some amount of duplication.
Arnd
$ git grep -wl struct.gpio_led arch/arm/mach-omap1/board-ams-delta.c arch/arm/mach-omap1/board-osk.c arch/arm/mach-orion5x/board-d2net.c arch/arm/mach-orion5x/dns323-setup.c arch/arm/mach-orion5x/mv2120-setup.c arch/arm/mach-orion5x/net2big-setup.c arch/arm/mach-orion5x/ts409-setup.c arch/arm/mach-s3c/mach-crag6410.c arch/arm/mach-sa1100/assabet.c arch/mips/alchemy/board-gpr.c arch/mips/alchemy/board-mtx1.c arch/mips/bcm47xx/leds.c arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h arch/mips/loongson32/ls1b/board.c arch/mips/txx9/generic/setup.c arch/mips/txx9/rbtx4927/setup.c arch/powerpc/platforms/44x/warp.c arch/sh/boards/mach-rsk/devices-rsk7203.c drivers/leds/leds-gpio.c drivers/leds/simatic/simatic-ipc-leds-gpio-core.c drivers/net/wireless/ath/ath10k/core.h drivers/net/wireless/ath/ath10k/leds.c drivers/platform/x86/barco-p50-gpio.c drivers/platform/x86/intel/atomisp2/led.c drivers/platform/x86/meraki-mx100.c drivers/platform/x86/pcengines-apuv2.c drivers/platform/x86/sel3350-platform.c
Lee Jones
maintainerRe: [PATCH 10/21] leds: gpio: make legacy gpiolib interface optional
Quoted 17 lines · Arnd Bergmann
Quoted 10 lines · Lee Jones
drivers/leds/leds-gpio.c static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx, · line 217
Quoted 5 lines · Arnd Bergmann
{
drivers/leds/leds-gpio.c +2
-0struct gpio_desc *gpiod; +#ifdef CONFIG_GPIOLIB_LEGACY int ret; +#endif Isn't there another way to do his that doesn't entail sprinkling #ifery around C-files?
An alternativew would be to duplicate the driver and have
one modern variant and an additional legacy variant that
is only used on the few remaining platforms that selectCONFIG_GPIOLIB_LEGACYand define platform data. See below for the list of files that reference structgpio_led.
Quoted 8 lines
There are already patches to convert some of those to software nodes, and a lot of the others can probably be removed, in particular the orion5x ones.
The leds-gpio driver with just the legacy interfaces left would be a really small driver, and removing those bits from the normal one would make that a bit simpler as well, but there would be some amount of duplication.
Sounds like we're between a rock and a hard place with this.
Will the legacy parts be removed at some point or do you foresee us supporting this forever?
Signature · 1 line
Lee Jones [李琼斯]
Re: [PATCH 10/21] leds: gpio: make legacy gpiolib interface optional
Quoted 3 lines · Lee Jones
On Tue, 19 Aug 2025, Arnd Bergmann wrote:
Sounds like we're between a rock and a hard place with this.
I don't think either variant is that bad to be honest, as it gets us a long way towards removing the legacy interface from default builds without having to update or remove the holdouts immediately. It's mainly led-gpio and gpio-keys that need a change like this.
Splitting out the entire gpio_led_platform_data handling into a single #ifdef function block would be a little cleaner, but that would in turn require changing over a couple of files that got converted from legacy gpio numbers to passing gpio descriptors or lookup tables (ppc44x/warp, x86/sel3350, arm/omap1), making them use device properties instead.
Quoted 2 lines
Will the legacy parts be removed at some point or do you foresee us supporting this forever?
It's hard to predict an timeline here, there is certainly a lot of interest in minimizing the legacy users as much as possible and patches are getting written for x86 and arm, but I don't see much movement on the mips and sh platforms. These are also the ones that have been holdouts for CONFIG_LEGACY_CLK for years, and I hope we can eventually drop support for those boards.
That said, I first need to get my own act together and refresh my patches to drop the old arm board files so we can merge that.
Arnd
Re: [PATCH 10/21] leds: gpio: make legacy gpiolib interface optional
Quoted 10 lines · Arnd Bergmann
Quoted 3 lines · Lee Jones
On Tue, 19 Aug 2025, Arnd Bergmann wrote:
Sounds like we're between a rock and a hard place with this.
I don't think either variant is that bad to be honest, as it gets us a long way towards removing the legacy interface from default builds without having to update or remove the holdouts immediately. It's mainly led-gpio and gpio-keys that need a change like this.
And I believe Dmitry is working on gpio-keys this cycle to get rid of legacy GPIO APIs.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 10/21] leds: gpio: make legacy gpiolib interface optional
Quoted 6 lines · Andy Shevchenko
Quoted 5 lines · Arnd Bergmann
Quoted 3 lines · Lee Jones
On Tue, 19 Aug 2025, Arnd Bergmann wrote:
Sounds like we're between a rock and a hard place with this.
Quoted 8 lines
Quoted 5 lines
I don't think either variant is that bad to be honest, as it gets us a long way towards removing the legacy interface from default builds without having to update or remove the holdouts immediately. It's mainly led-gpio and gpio-keys that need a change like this.
And I believe Dmitry is working on gpio-keys this cycle to get rid of legacy GPIO APIs.
I just realize that this might be odd, I meant Dmitry Torokhov in this context.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Lee Jones
maintainerRe: [PATCH 12/21] mfd: arizona: make legacy gpiolib interface optional
In reply to Arnd BergmannQuoted 6 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The only machine that still uses the old gpio number based interface is the
wlf_cragg_6410board file. In order to remove the dependency on the interfaces, add #ifdef blocks here.
Quoted 6 lines
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/mfd/arizona-irq.c | 5 ++++- include/linux/mfd/arizona/pdata.h | 6 ++++++ sound/soc/codecs/arizona-jack.c | 17 ++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-)
Just FTR, I hate this! =:-D
Signature · 1 line
Lee Jones [李琼斯]
Re: (subset) [PATCH 00/21] gpiolib: fence off legacy interfaces
In reply to Arnd BergmannQuoted 8 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Commit
678bae2eaa81("gpiolib: make legacy interfaces optional") was merged for linux-6.17, so now it is possible to use the legacy interfaces conditionally and eventually have the support left out of the kernel whenever it is not needed.[...]
Applied, thanks!
[12/21] mfd: arizona: make legacy gpiolib interface optional
commit: 12f6c0afc8987d72017a3ecf7c1183cb951b0d24
[13/21] mfd: si476x: add GPIOLIB_LEGACY dependency
commit: 1ae250257e43b3fba225e4f8ea7d87125dc861ae
[14/21] mfd: aat2870: add GPIOLIB_LEGACY dependency
commit: 3144986f37911f131f373743f294b2941a8ef37c--
Lee Jones [李琼斯]
Re: [PATCH 12/21] mfd: arizona: make legacy gpiolib interface optional
In reply to Lee JonesQuoted 8 lines · Lee Jones
Quoted 6 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The only machine that still uses the old gpio number based interface is the
wlf_cragg_6410board file. In order to remove the dependency on the interfaces, add #ifdef blocks here.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/mfd/arizona-irq.c | 5 ++++- include/linux/mfd/arizona/pdata.h | 6 ++++++ sound/soc/codecs/arizona-jack.c | 17 ++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-)Just FTR, I hate this! =:-D
Any alternative suggestions?
Would you be happier with a hard "depends on GPIOLIB_LEGACY"?
I see only two in-tree users other than the old 6410 board that use the modern path: exynos5433-tm2-common.dtsi and drivers/platform/x86/x86-android-tablets/lenovo.c.
Making those platforms 'select GPIOLIB_LEGACY' is technically incorrect since they don't need the legayc interfaces, but it would be a temporary workaround until wlf_cragg_6410 is gone.
Arnd
Lee Jones
maintainerRe: [PATCH 12/21] mfd: arizona: make legacy gpiolib interface optional
Quoted 22 lines · Arnd Bergmann
Quoted 8 lines · Lee Jones
Quoted 6 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The only machine that still uses the old gpio number based interface is the
wlf_cragg_6410board file. In order to remove the dependency on the interfaces, add #ifdef blocks here.Quoted 8 lines
Quoted 6 lines
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/mfd/arizona-irq.c | 5 ++++- include/linux/mfd/arizona/pdata.h | 6 ++++++ sound/soc/codecs/arizona-jack.c | 17 ++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-)Just FTR, I hate this! =:-D
Any alternative suggestions?
Would you be happier with a hard "depends on
GPIOLIB_LEGACY"?
Quoted 8 lines
I see only two in-tree users other than the old 6410 board that use the modern path:
exynos5433-tm2-common.dtsianddrivers/platform/x86/x86-android-tablets/lenovo.c.Making those platforms 'select
GPIOLIB_LEGACY' is technically incorrect since they don't need the legayc interfaces, but it would be a temporary workaround untilwlf_cragg_6410is gone.
I've applied the patches for now in the hope that these can get cleaned away at one point.
Signature · 1 line
Lee Jones [李琼斯]
Re: [PATCH 12/21] mfd: arizona: make legacy gpiolib interface optional
Quoted 9 lines · Lee Jones
Quoted 4 lines · Arnd Bergmann
Making those platforms 'select
GPIOLIB_LEGACY' is technically incorrect since they don't need the legayc interfaces, but it would be a temporary workaround untilwlf_cragg_6410is gone.I've applied the patches for now in the hope that these can get cleaned away at one point.
Thanks a lot!
Cleaning these up eventually is definition the idea here, hiding the interfaces in an #ifdef block should both help catch any remaining accidental users, and make it trivial to remove the remnants when they are no longer needed.
Arnd
Re: [PATCH 16/21] ath10k: remove gpio number assignment
In reply to Arnd BergmannQuoted 6 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The leds-gpio traditionally takes a global gpio number in its platform data, but the number assigned here is not actually such a number but only meant to be used internally to this driver.
Quoted 8 lines
As part of the kernel-wide cleanup of the old gpiolib interfaces, the 'gpio' number field is going away, so to keep ath10k building, move the assignment into a private structure instead.
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/net/wireless/ath/ath10k/leds.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
wifi tag is missing in the patch title.
Re: [PATCH 16/21] ath10k: remove gpio number assignment
In reply to Arnd BergmannQuoted 29 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The leds-gpio traditionally takes a global gpio number in its platform data, but the number assigned here is not actually such a number but only meant to be used internally to this driver.
As part of the kernel-wide cleanup of the old gpiolib interfaces, the 'gpio' number field is going away, so to keep ath10k building, move the assignment into a private structure instead.
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/net/wireless/ath/ath10k/leds.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/wireless/ath/ath10k/leds.c +1
-1@@ -27,7 +27,7 @@ static int ath10k_leds_set_brightness_blocking(struct led_classdev *led_cdev, goto out; ar->leds.gpio_state_pin = (brightness !=LED_OFF ) ^ led->active_low; -ath10k_wmi_gpio_output (ar, led->gpio, ar->leds.gpio_state_pin); +ath10k_wmi_gpio_output (ar, ar->hw_params.led_pin, ar->leds.gpio_state_pin); out:mutex_unlock (&ar->conf_mutex);
drivers/net/wireless/ath/ath10k/leds.c int ath10k_leds_register(struct ath10k *ar) · line 69
Quoted 7 lines
drivers/net/wireless/ath/ath10k/leds.c +0
-1@@ -64,7 +64,6 @@ int ath10k_leds_register(struct ath10k *ar)snprintf (ar->leds.label,sizeof (ar->leds.label),"ath10k-%s" ,wiphy_name (ar->hw->wiphy)); ar->leds.wifi_led.active_low =1 ; - ar->leds.wifi_led.gpio = ar->hw_params.led_pin; ar->leds.wifi_led.name = ar->leds.label; ar->leds.wifi_led.default_state =LEDS_GPIO_DEFSTATE_KEEP ;
With 'wifi:' tag added ...
Re: [PATCH 16/21] ath10k: remove gpio number assignment
In reply to Vasanthakumar ThiagarajanQuoted 13 lines · Vasanthakumar Thiagarajan
Quoted 10 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The leds-gpio traditionally takes a global gpio number in its platform data, but the number assigned here is not actually such a number but only meant to be used internally to this driver.
As part of the kernel-wide cleanup of the old gpiolib interfaces, the 'gpio' number field is going away, so to keep ath10k building, move the assignment into a private structure instead.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/net/wireless/ath/ath10k/leds.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)wifi tag is missing in the patch title.
I'll fix this when I apply the patch
Jeff Johnson
AppliedRe: [PATCH 16/21] ath10k: remove gpio number assignment
In reply to Arnd BergmannQuoted 9 lines · Arnd Bergmann
The leds-gpio traditionally takes a global gpio number in its platform data, but the number assigned here is not actually such a number but only meant to be used internally to this driver.
As part of the kernel-wide cleanup of the old gpiolib interfaces, the 'gpio' number field is going away, so to keep ath10k building, move the assignment into a private structure instead.
[...]
Applied, thanks!
[16/21] ath10k: remove gpio number assignment
commit: 5b345471752701ccfcfa6e86e15d2cebc6e17343
Best regards,
Signature · 1 line
Jeff Johnson <[email protected]>