gpiolib: fence off legacy interfaces
v6 cover gpiolib: fence off legacy interfaces
From: Arnd Bergmann <[email protected]>
This is the remainder of the series previously posted in [1] and [2].
I only made one trivial chance suggested by Andy Shevchenko and reordered the series to have the input patches first.
Dmitry Torokhov asked about having an immutable branch, so I would suggest sharing the two input patches between the mfd and gpio trees, and everything else go through the gpio tree only.
Arnd
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Arnd Bergmann (6):
[v6] Input: soc_button_array - select CONFIG_GPIOLIB_LEGACY [v6] Input: gpio-keys: make legacy gpiolib optional [v6] leds: gpio: make legacy gpiolib interface optional [v6] sh: select legacy gpiolib interface
[v6] x86/olpc: select GPIOLIB_LEGACY
[v6] gpiolib: turn off legacy interface by default
arch/sh/Kconfig | 1 + arch/sh/boards/Kconfig | 8 ++++ arch/sh/boards/mach-highlander/Kconfig | 1 + arch/sh/boards/mach-rsk/Kconfig | 3 ++ arch/x86/Kconfig | 1 + arch/x86/platform/olpc/olpc-xo1-sci.c | 2 +- drivers/gpio/Kconfig | 9 +++- drivers/input/keyboard/gpio_keys.c | 9 ++-- drivers/input/keyboard/gpio_keys_polled.c | 4 +- drivers/input/misc/Kconfig | 3 ++ drivers/input/misc/soc_button_array.c | 1 - drivers/leds/leds-gpio.c | 52 +++++++++++++++-------- drivers/mfd/rohm-bd71828.c | 1 - drivers/mfd/rohm-bd718x7.c | 1 - include/linux/gpio_keys.h | 2 + include/linux/leds.h | 2 + sound/pci/Kconfig | 1 + sound/pci/cs5535audio/cs5535audio_olpc.c | 2 +- 18 files changed, 75 insertions(+), 28 deletions(-)
Signature · 19 lines
2.39.5 Cc: John Paul Adrian Glaubitz <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: [email protected] Cc: "H. Peter Anvin" <[email protected]> Cc: Linus Walleij <[email protected]> Cc: Bartosz Golaszewski <[email protected]> Cc: Dmitry Torokhov <[email protected]> Cc: Lee Jones <[email protected]> Cc: Pavel Machek <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected]
PATCH v6 1/6 Input: soc_button_array - select CONFIG_GPIOLIB_LEGACY
From: Arnd Bergmann <[email protected]>
This driver converts information from ACPI in x86 based tablets and laptops into platform_data for the gpio_keys driver, using the obsolete gpio number based interfaces.
This should really be converted to some other method, but since the conversion is nontrivial, have this one select GPIOLIB_LEGACY for the time being.
This enables turning GPIOLIB_LEGACY off by default on most kernel builds. Since the driver is only used on x86 portables, add a CONFIG_X86 dependency, which means non-x86 allmodconfig builds usuallly build without the legacy gpio support.
---
v5: This was part of an earlier "x86/platform: select legacy
gpiolib interfaces where used" patch that covered several drivers. This is the only one left as of linux-7.2-rc1
--- drivers/input/misc/Kconfig | 3 +++ drivers/input/misc/soc_button_array.c | 1 - 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/input/misc/Kconfig +3 -0
@@ -892,6 +892,9 @@ config INPUT_IDEAPAD_SLIDEBAR config INPUT_SOC_BUTTON_ARRAY tristate "Windows-compatible SoC Button Array" depends on KEYBOARD_GPIO && ACPI + depends on X86 + depends on GPIOLIB + select GPIOLIB_LEGACY help Say Y here if you have a SoC-based tablet that originally runs Windows 8 or a Microsoft Surface Book 2, Pro 5, Laptop 1 or later.
drivers/input/misc/soc_button_array.c +0 -1
@@ -15,7 +15,6 @@#include <linux/dmi.h> #include <linux/gpio/consumer.h> #include <linux/gpio_keys.h> -#include <linux/gpio.h> #include <linux/platform_device.h> static bool use_low_level_irq;
Signature · 1 line
2.39.5
[email protected]
AI reviewRe: [PATCH 1/6] [v6] Input: soc_button_array - select CONFIG_GPIOLIB_LEGACY
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 15 lines
From: Arnd Bergmann <[email protected]>
This driver converts information from ACPI in x86 based tablets and laptops into
platform_datafor thegpio_keysdriver, using the obsolete gpio number based interfaces.This should really be converted to some other method, but since the conversion is nontrivial, have this one select
GPIOLIB_LEGACYfor the time being.This enables turning
GPIOLIB_LEGACYoff by default on most kernel builds. Since the driver is only used on x86 portables, add aCONFIG_X86dependency, which means non-x86 allmodconfig builds usuallly build without the legacy gpio support.
Quoted 4 lines
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v6 2/6 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.
The two Rohm PMIC drivers use a gpio-keys device without an actual GPIO, passing an IRQ number instead. In order to keep this working both with and with CONFIG_GPIOLIB_LEGACY, change the gpio-keys driver to ignore the gpio number if an IRQ is passed.
---
v3..v5: resend
v2: skip the fake GPIO number passing from mfd
This patch now has a small conflict with the rework of the rohm drivers to use software nodes. That patch is the one we want, and then the drivers/mfd changes here can get dropped, but the two need to get merged in the correct order.
--- drivers/input/keyboard/gpio_keys.c | 9 +++++---- drivers/input/keyboard/gpio_keys_polled.c | 4 +++- drivers/mfd/rohm-bd71828.c | 1 - drivers/mfd/rohm-bd718x7.c | 1 - include/linux/gpio_keys.h | 2 ++ 5 files changed, 10 insertions(+), 7 deletions(-)
drivers/input/keyboard/gpio_keys.c +5 -4
@@ -23,8 +23,8 @@#include <linux/input.h> #include <linux/gpio_keys.h> #include <linux/workqueue.h> -#include <linux/gpio.h> #include <linux/gpio/consumer.h> +#include <linux/gpio/legacy.h> #include <linux/of.h> #include <linux/of_irq.h> #include <linux/spinlock.h>
@@ -528,7 +528,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,*/ bdata->gpiod =NULL ; } - }else if (gpio_is_valid (button->gpio)) { +#ifdef CONFIG_GPIOLIB_LEGACY + }else if (!button->irq &&gpio_is_valid (button->gpio)) {/* * Legacy GPIO number, so request the GPIO here and * convert it to descriptor.
@@ -546,6 +547,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,if (button->active_low ^gpiod_is_active_low (bdata->gpiod))gpiod_toggle_active_low (bdata->gpiod); +#endif }if (bdata->gpiod) {
@@ -583,8 +585,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,if (irq <0 ) { error = irq;dev_err_probe (dev, error, -"Unable to get irq number for GPIO %d\n" , - button->gpio); +"Unable to get irq number for GPIO\n" );return error; } bdata->irq = irq;
drivers/input/keyboard/gpio_keys_polled.c +3 -1
@@ -18,8 +18,8 @@#include <linux/input.h> #include <linux/ioport.h> #include <linux/platform_device.h> -#include <linux/gpio.h> #include <linux/gpio/consumer.h> +#include <linux/gpio/legacy.h> #include <linux/gpio_keys.h> #include <linux/property.h>
@@ -301,6 +301,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (bdata->gpiod),"failed to get gpio\n" ); } +#ifdef CONFIG_GPIOLIB_LEGACY }else if (gpio_is_valid (button->gpio)) {/* * Legacy GPIO number so request the GPIO here and
@@ -323,6 +324,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)if (button->active_low ^gpiod_is_active_low (bdata->gpiod))gpiod_toggle_active_low (bdata->gpiod); +#endif } bdata->last_state =-1 ;
drivers/mfd/rohm-bd71828.c +0 -1
@@ -39,7 +39,6 @@static struct gpio_keys_button button = { .code =KEY_POWER , - .gpio =-1 , .type =EV_KEY , .wakeup =1 , };
drivers/mfd/rohm-bd718x7.c +0 -1
@@ -20,7 +20,6 @@static struct gpio_keys_button button = { .code =KEY_POWER , - .gpio =-1 , .type =EV_KEY , };
include/linux/gpio_keys.h +2 -0
@@ -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
[email protected]
AI reviewRe: [PATCH 2/6] [v6] Input: gpio-keys: make legacy gpiolib optional
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Legacy platforms that specify both a valid GPIO and an IRQ for a button are forced into purely interrupt-driven mode, degrading them to simulated pulse buttons.
- [Low] The patch includes a non-existent header file linux/gpio/legacy.h, unconditionally breaking the build.
Pre-existing issues:
- [High] The Rohm MFD drivers dynamically mutate a globally shared static struct during probe, breaking reentrancy and violating MFD guidelines. --
--- Patch [2]: [PATCH 2/6] [v6] Input: gpio-keys: make legacy gpiolib optional --- commit 1e2acc08348477940313314a2e3563828ed3ae8b
Author: Arnd Bergmann <[email protected]>
Input: gpio-keys: make legacy gpiolib optional
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 line 27
Quoted 10 lines
drivers/input/keyboard/gpio_keys.c +1
-1@@ -23,8 +23,8 @@#include <linux/input.h> #include <linux/gpio_keys.h> #include <linux/workqueue.h> -#include <linux/gpio.h> #include <linux/gpio/consumer.h> +#include <linux/gpio/legacy.h>
[Severity: Low]
Does this header file exist in the source tree? Because this include is outside of any #ifdef blocks, it looks like it will unconditionally break the build for anyone compiling with CONFIG_KEYBOARD_GPIO enabled.
Quoted 3 lines
drivers/input/keyboard/gpio_keys.c +0
-0#include <linux/of.h> #include <linux/of_irq.h> #include <linux/spinlock.h>
[ ... ]
drivers/input/keyboard/gpio_keys.c static int gpio_keys_setup_key(struct platform_device *pdev, · line 532
Quoted 7 lines
drivers/input/keyboard/gpio_keys.c +2
-1@@ -528,7 +528,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,*/ bdata->gpiod =NULL ; } - }else if (gpio_is_valid (button->gpio)) { +#ifdef CONFIG_GPIOLIB_LEGACY + }else if (!button->irq &&gpio_is_valid (button->gpio)) {
[Severity: High]
Does this new !button->irq condition inadvertently break legacy boards that legitimately supply both a valid .gpio and an .irq?
For example, in arch/arm/mach-sa1100/assabet.c, assabet_keys_buttons defines buttons with both .gpio = 0 and .irq = IRQ_GPIO0. Since the GPIO is no longer requested when an IRQ is present, wouldn't the driver fall back to purely interrupt-driven mode?
If so, this would lack a GPIO descriptor to read the physical button level, turning holdable physical buttons into simulated momentary pulses via the auto-release timer.
Quoted 3 lines
drivers/input/keyboard/gpio_keys.c +0
-0/* * Legacy GPIO number, so request the GPIO here and * convert it to descriptor.
[ ... ]
drivers/input/keyboard/gpio_keys_polled.c line 22
Quoted 10 lines
drivers/input/keyboard/gpio_keys_polled.c +1
-1@@ -18,8 +18,8 @@#include <linux/input.h> #include <linux/ioport.h> #include <linux/platform_device.h> -#include <linux/gpio.h> #include <linux/gpio/consumer.h> +#include <linux/gpio/legacy.h>
[Severity: Low]
Similar to gpio_keys.c, does this unconditionally break the build since linux/gpio/legacy.h is missing from the tree?
Quoted 2 lines
drivers/input/keyboard/gpio_keys_polled.c +0
-0#include <linux/gpio_keys.h> #include <linux/property.h>
[ ... ]
drivers/mfd/rohm-bd71828.c line 44
Quoted 11 lines
drivers/mfd/rohm-bd71828.c +0
-1@@ -39,7 +39,6 @@static struct gpio_keys_button button = { .code =KEY_POWER , - .gpio =-1 , .type =EV_KEY , .wakeup =1 , };
[Severity: High]
This isn't a bug introduced by this patch, but this static struct is modified dynamically during bd71828_i2c_probe() when assigning button.irq = ret.
Since mfd_add_devices() only shallow-copies the platform data, doesn't mutating a globally shared static struct during probe break reentrancy? Multiple instances of the PMIC or repeated probes due to unbind/deferral could clobber each other's IRQ number here.
drivers/mfd/rohm-bd718x7.c line 24
Quoted 10 lines
drivers/mfd/rohm-bd718x7.c +0
-1@@ -20,7 +20,6 @@static struct gpio_keys_button button = { .code =KEY_POWER , - .gpio =-1 , .type =EV_KEY , };
[Severity: High]
This is a pre-existing issue, but just like in rohm-bd71828.c, mutating this shared static struct during bd718xx_i2c_probe() violates MFD guidelines and could cause race conditions with concurrent or repeated probes.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH v6 3/6 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.
While the CONFIG_GPIOLIB_LEGACY option that guards devm_gpio_request_one() and related helpers is currently turned on in all kernel builds, the plan is to only enable it on the few platforms that actually pass gpio numbers in any platform_data.
Split out the legacy portion of the platform_data handling into a custom helper function that is guarded with in #ifdef block, to allow the the leds-gpio driver to compile cleanly when CONFIG_GPIOLIB_LEGACY gets turned off. Once the last user is converted, this function can be removed.
---
v5: no changes
v4: whitespace changes only
v3: simplify gpio_led_get_gpiod
v2: rework a little bit to keep the legacy code path more separate,
extend changelog description
--- drivers/leds/leds-gpio.c | 52 +++++++++++++++++++++++++++------------- include/linux/leds.h | 2 ++ 2 files changed, 37 insertions(+), 17 deletions(-)
drivers/leds/leds-gpio.c +35 -17
@@ -9,8 +9,8 @@#include <linux/container_of.h> #include <linux/device.h> #include <linux/err.h> -#include <linux/gpio.h> #include <linux/gpio/consumer.h> +#include <linux/gpio/legacy.h> #include <linux/leds.h> #include <linux/mod_devicetable.h> #include <linux/module.h>
@@ -212,7 +212,6 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx, const struct gpio_led *template) {struct gpio_desc *gpiod; -int ret;/* * This means the LED does not come from the device tree
@@ -223,16 +222,29 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx, gpiod =devm_gpiod_get_index_optional (dev,NULL , idx,GPIOD_OUT_LOW );if (IS_ERR (gpiod))return gpiod; -if (gpiod) { -gpiod_set_consumer_name (gpiod, template->name); -return gpiod; - } -/* -* This is the legacy code path for platform code that -* still uses GPIO numbers. Ultimately we would like to get -* rid of this block completely. -*/ +gpiod_set_consumer_name (gpiod, template->name); +return gpiod; +} + +#ifdef CONFIG_GPIOLIB_LEGACY +/* +* This is the legacy code path for platform code that still uses +* GPIO numbers, mainly MIPS and SuperH board files. +* Ultimately we would like to get rid of this block completely. +* +* ppc44x-warp sets the template->gpiod directly instead of +* adding a lookup table or device properties. This is not +* much better. +*/ +static struct gpio_desc *gpio_led_get_legacy_gpiod (struct device *dev,int idx, +const struct gpio_led *template) +{ +struct gpio_desc *gpiod; +int ret; + +if (template->gpiod) +return template->gpiod;/* skip leds that aren't available */ if (!gpio_is_valid (template->gpio))
@@ -252,6 +264,13 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx, return gpiod; } +#else +static struct gpio_desc *gpio_led_get_legacy_gpiod (struct device *dev,int idx, +const struct gpio_led *template) +{ +return template->gpiod ?:ERR_PTR (-ENOENT ); +} +#endif static int gpio_led_probe (struct platform_device *pdev) {
@@ -270,14 +289,13 @@ static int gpio_led_probe(struct platform_device *pdev)const struct gpio_led *template = &pdata->leds[i];struct gpio_led_data *led_dat = &priv->leds[i]; -if (template->gpiod) - led_dat->gpiod = template->gpiod; -else + led_dat->gpiod =gpio_led_get_gpiod (dev, i, template); +if (!led_dat->gpiod) led_dat->gpiod = -gpio_led_get_gpiod (dev, i, template); +gpio_led_get_legacy_gpiod (dev, i, template);if (IS_ERR (led_dat->gpiod)) { -dev_info (dev,"Skipping unavailable LED gpio %d (%s)\n" , - template->gpio, template->name); +dev_info (dev,"Skipping unavailable LED gpio %s\n" , + template->name);continue ; }
include/linux/leds.h +2 -0
@@ -676,8 +676,10 @@ typedef int (*gpio_blink_set_t)(struct gpio_desc *desc, int state,struct gpio_led {const char *name;const char *default_trigger; +#ifdef CONFIG_GPIOLIB_LEGACY unsigned gpio;unsigned active_low :1 ; +#endif unsigned retain_state_suspended :1 ;unsigned panic_indicator :1 ;unsigned default_state :2 ;
Signature · 1 line
2.39.5
[email protected]
AI reviewRe: [PATCH 3/6] [v6] leds: gpio: make legacy gpiolib interface optional
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] Disabling CONFIG_GPIOLIB_LEGACY breaks compilation for unrelated non-legacy drivers that set…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Disabling CONFIG_GPIOLIB_LEGACY breaks compilation for unrelated non-legacy drivers that set struct gpio_led::active_low.
- [Low] The commit message description is not capitalized, violating the LED subsystem guidelines.
--
--- Patch [3]: [PATCH 3/6] [v6] leds: gpio: make legacy gpiolib interface optional --- commit ad55bf4fa40ddbff55ee69fcb15b56da1f063668
Author: Arnd Bergmann <[email protected]>
Quoted 1 line
leds: gpio: make legacy gpiolib interface optional
[Severity: Low]
This isn't a bug, but should the commit description be capitalized after the subsystem prefix to match the LED subsystem guidelines? For example, "leds: gpio: Make legacy..."
This commit makes the legacy GPIO library interface optional in the leds-gpio driver by guarding the platform_data handling with CONFIG_GPIOLIB_LEGACY.
[ ... ]
include/linux/leds.h typedef int (*gpio_blink_set_t)(struct gpio_desc *desc, int state, · line 682
Quoted 12 lines
include/linux/leds.h +2
-0@@ -676,8 +676,10 @@ typedef int (*gpio_blink_set_t)(struct gpio_desc *desc, int state,struct gpio_led {const char *name;const char *default_trigger; +#ifdef CONFIG_GPIOLIB_LEGACY unsigned gpio;unsigned active_low :1 ; +#endif
[Severity: Low]
Does hiding active_low behind CONFIG_GPIOLIB_LEGACY break the build for unrelated non-legacy drivers (such as ath10k) that still rely on setting this field in struct gpio_led?
Quoted 3 lines
include/linux/leds.h +0
-0unsigned retain_state_suspended : 1; unsigned panic_indicator : 1; unsigned default_state : 2;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Lee Jones
maintainerRe: [PATCH 3/6] [v6] leds: gpio: make legacy gpiolib interface optional
In reply to Arnd BergmannQuoted 29 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.
While the
CONFIG_GPIOLIB_LEGACYoption that guardsdevm_gpio_request_one()and related helpers is currently turned on in all kernel builds, the plan is to only enable it on the few platforms that actually pass gpio numbers in anyplatform_data.Split out the legacy portion of the
platform_datahandling into a custom helper function that is guarded with in #ifdef block, to allow the the leds-gpio driver to compile cleanly whenCONFIG_GPIOLIB_LEGACYgets turned off. Once the last user is converted, this function can be removed.Reviewed-by Linus Walleij <[email protected]>Reviewed-by Bartosz Golaszewski <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>---
v5: no changes
v4: whitespace changes only
v3: simplifygpio_led_get_gpiod
v2: rework a little bit to keep the legacy code path more separate,
extend changelog description
Quoted 4 lines
--- drivers/leds/leds-gpio.c | 52 +++++++++++++++++++++++++++------------- include/linux/leds.h | 2 ++ 2 files changed, 37 insertions(+), 17 deletions(-)
Any deps?
Signature · 1 line
Lee Jones
Re: [PATCH 3/6] [v6] leds: gpio: make legacy gpiolib interface optional
Quoted 6 lines · Lee Jones
Quoted 4 lines
--- drivers/leds/leds-gpio.c | 52 +++++++++++++++++++++++++++------------- include/linux/leds.h | 2 ++ 2 files changed, 37 insertions(+), 17 deletions(-)Any deps?
No, linux-7.1 is enough as a base.
Arnd
Re: (subset) [PATCH 3/6] [v6] leds: gpio: make legacy gpiolib interface optional
In reply to Arnd BergmannQuoted 10 lines · Arnd Bergmann
There are still a handful of ancient mips/armv5/sh boards that use the gpio_led:gpio member to pass an old-style gpio number, but all modern users have been converted to gpio descriptors.
While the
CONFIG_GPIOLIB_LEGACYoption that guardsdevm_gpio_request_one()and related helpers is currently turned on in all kernel builds, the plan is to only enable it on the few platforms that actually pass gpio numbers in anyplatform_data.[...]
Applied, thanks!
[3/6] leds: gpio: make legacy gpiolib interface optional
commit: 98c5c7b0d4269ecabfc86b8b49ffcfa47979e99d
--
Lee Jones [李琼斯]
PATCH v6 4/6 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.
---
v2..v5: no changes. The patch did not make it into v7.2-rc1, so
I'm keeping it with the rest of the series
--- arch/sh/Kconfig | 1 + arch/sh/boards/Kconfig | 8 ++++++++ arch/sh/boards/mach-highlander/Kconfig | 1 + arch/sh/boards/mach-rsk/Kconfig | 3 +++ 4 files changed, 13 insertions(+)
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
[email protected]
AI reviewRe: [PATCH 4/6] [v6] sh: select legacy gpiolib interface
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 11 lines
From: Arnd Bergmann <[email protected]>
Many board files on sh reference the legacy gpiolib interfaces that are becoming optional. To ensure the boards can keep building, select
CONFIG_GPIOLIB_LEGACYon each of the boards that have one of the hardcoded calls.Cc John Paul Adrian Glaubitz <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
PATCH v6 5/6 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);
The AMD Geode platform that this is based on is now marked as 'Orphaned' in Kconfig, and it is likely that there are no XO1 users on modern kernels, but so far there is no consensus on removing it entirely.
Select CONFIG_GPIOLIB_LEGACY for this platform and make sure the sound driver portion cannot be compiled without this.
---
v3..v5: no changes
v2: update changelog text
--- arch/x86/Kconfig | 1 + arch/x86/platform/olpc/olpc-xo1-sci.c | 2 +- sound/pci/Kconfig | 1 + sound/pci/cs5535audio/cs5535audio_olpc.c | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-)
arch/x86/Kconfig +1 -0
@@ -2976,6 +2976,7 @@ config OLPC bool "One Laptop Per Child support" depends on !X86_PAE select GPIOLIB + select GPIOLIB_LEGACY select OF select OF_PROMTREE select IRQ_DOMAIN
arch/x86/platform/olpc/olpc-xo1-sci.c +1 -1
@@ -9,7 +9,7 @@#include <linux/cs5535.h> #include <linux/device.h> -#include <linux/gpio.h> +#include <linux/gpio/legacy.h> #include <linux/input.h> #include <linux/interrupt.h> #include <linux/platform_device.h>
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
sound/pci/cs5535audio/cs5535audio_olpc.c +1 -1
@@ -9,7 +9,7 @@#include <sound/info.h> #include <sound/control.h> #include <sound/ac97_codec.h> -#include <linux/gpio.h> +#include <linux/gpio/legacy.h> #include <asm/olpc.h> #include "cs5535audio.h"
Signature · 1 line
2.39.5
[email protected]
AI reviewRe: [PATCH 5/6] [v6] x86/olpc: select GPIOLIB_LEGACY
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Replacing `#include <linux/gpio.h>` with `#include <linux/gpio/legacy.h>` causes a fatal compile…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Replacing #include <linux/gpio.h> with #include <linux/gpio/legacy.h> causes a fatal compile error because the new header file does not exist in the kernel tree. --
--- Patch [5]: [PATCH 5/6] [v6] x86/olpc: select GPIOLIB_LEGACY --- commit dfd246b7263a8d5eeb27b20b07f4d9310db7a8d6
Author: Arnd Bergmann <[email protected]>
x86/olpc: select GPIOLIB_LEGACY
This commit selects CONFIG_GPIOLIB_LEGACY for the OLPC platform to resolve implicit function declaration errors for legacy GPIO functions. It also updates the audio driver Kconfig to depend on GPIOLIB_LEGACY or !OLPC.
arch/x86/platform/olpc/olpc-xo1-sci.c line 12
Quoted 10 lines
arch/x86/platform/olpc/olpc-xo1-sci.c +1
-1@@ -9,7 +9,7 @@#include <linux/cs5535.h> #include <linux/device.h> -#include <linux/gpio.h> +#include <linux/gpio/legacy.h>
[Severity: Low]
Does this header actually exist in the kernel tree? Compiling this file with CONFIG_OLPC enabled appears to result in a fatal No such file or directory error because include/linux/gpio/legacy.h is missing.
Quoted 2 lines
arch/x86/platform/olpc/olpc-xo1-sci.c +0
-0#include <linux/input.h> #include <linux/interrupt.h>
[ ... ]
sound/pci/cs5535audio/cs5535audio_olpc.c line 12
Quoted 10 lines
sound/pci/cs5535audio/cs5535audio_olpc.c +1
-1@@ -9,7 +9,7 @@#include <sound/info.h> #include <sound/control.h> #include <sound/ac97_codec.h> -#include <linux/gpio.h> +#include <linux/gpio/legacy.h>
[Severity: Low]
Similarly, will this cause a build failure here for the same missing header reason?
Quoted 2 lines
sound/pci/cs5535audio/cs5535audio_olpc.c +0
-0#include <asm/olpc.h>
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
PATCH v6 6/6 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 and only get built on platforms that still have one unconverted driver.
Allow turning it on manually for compile testing, in order to keep the build coverage of the legacy drivers in allmodconfig and randconfig.
---
v5: added patch, now that we are getting closer to completing
the series
--- drivers/gpio/Kconfig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpio/Kconfig +8 -1
@@ -4,7 +4,14 @@ # config GPIOLIB_LEGACY - def_bool y + bool "Legacy GPIO interfaces" if COMPILE_TEST + help + There are a few legacy platforms that use the traditional GPIO + number based interfaces instead of GPIO descriptors. + Say Y here to enable build testing drivers that are specific + to those platforms. + + If unsure, say N. config HAVE_SHARED_GPIOS bool
Signature · 1 line
2.39.5
[email protected]
AI reviewRe: [PATCH 6/6] [v6] gpiolib: turn off legacy interface by default
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Drivers MFD_AAT2870_CORE, MFD_SI476X_CORE, and SND_SOC_TLV320DAC33 become silently unselectable on…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Drivers MFD_AAT2870_CORE, MFD_SI476X_CORE, and SND_SOC_TLV320DAC33 become silently unselectable on standard kernels because they still use depends on GPIOLIB_LEGACY. --
--- Patch [6]: [PATCH 6/6] [v6] gpiolib: turn off legacy interface by default --- commit c81360523a83f6de8b9f91867c27fb9f36e0da52
Author: Arnd Bergmann <[email protected]>
gpiolib: turn off legacy interface by default
This commit turns off the legacy GPIO interface by default, allowing it to be enabled manually only for compile testing. It relies on the assumption that all legacy users now select CONFIG_GPIOLIB_LEGACY.
drivers/gpio/Kconfig line 7
Quoted 10 lines
drivers/gpio/Kconfig +1
-1@@ -4,7 +4,14 @@ # config GPIOLIB_LEGACY - def_bool y + bool "Legacy GPIO interfaces" if COMPILE_TEST
[Severity: High]
Does this change silently disable MFD_AAT2870_CORE, MFD_SI476X_CORE, and SND_SOC_TLV320DAC33 in production builds?
The commit message states that all users of the legacy interface now select CONFIG_GPIOLIB_LEGACY, but it appears these drivers still depend on it instead:
drivers/mfd/Kconfig:
config MFD_AAT2870_CORE
...
depends on GPIOLIB_LEGACY
drivers/mfd/Kconfig:
config MFD_SI476X_CORE
...
depends on GPIOLIB_LEGACY
sound/soc/codecs/Kconfig:
config SND_SOC_TLV320DAC33
...
depends on GPIOLIB_LEGACY
Since GPIOLIB_LEGACY now defaults to n and its prompt is hidden without COMPILE_TEST, won't these dependencies prevent the drivers from being selected on standard kernels, causing their hardware to stop functioning?
Quoted 7 lines
drivers/gpio/Kconfig +7
-0+ help + There are a few legacy platforms that use the traditional GPIO + number based interfaces instead of GPIO descriptors. + Say Y here to enable build testing drivers that are specific + to those platforms. + + If unsure, say N.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6