From: Jonas Gorski <jonas.gorski@gmail.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: "Bartosz Golaszewski" <brgl@bgdev.pl>,
"Linus Walleij" <linus.walleij@linaro.org>,
linux-gpio@vger.kernel.org,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Andrew Lunn" <andrew@lunn.ch>,
"Vladimir Oltean" <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Álvaro Fernández Rojas" <noltari@gmail.com>,
"Kyle Hendry" <kylehendrydev@gmail.com>,
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 15/21] dsa: b53: hide legacy gpiolib usage on non-mips
Date: Sat, 9 Aug 2025 12:01:54 +0200 [thread overview]
Message-ID: <CAOiHx=mW8B2vQ7UhauPJpJ9KmtxTZ2-1MC3Vf2uNF9RaJ4WQ5A@mail.gmail.com> (raw)
In-Reply-To: <20250808151822.536879-16-arnd@kernel.org>
Hi,
On Fri, Aug 8, 2025 at 5:23 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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(struct
b53_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_HIGH
drivers/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);
| ^~~~~~~~~~~~~~~~~~
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/net/dsa/b53/b53_common.c | 17 +++++------------
> drivers/net/dsa/b53/b53_priv.h | 24 ++++++++++++++++++------
> 2 files changed, 23 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
> index 9942fb6f7f4b..cb57bcc56c63 100644
> --- a/drivers/net/dsa/b53/b53_common.c
> +++ b/drivers/net/dsa/b53/b53_common.c
> @@ -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.
> +#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;
> }
> diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h
> index 458775f95164..16e82653a7c6 100644
> --- a/drivers/net/dsa/b53/b53_priv.h
> +++ b/drivers/net/dsa/b53/b53_priv.h
> @@ -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)
s/gpio_desc/struct gpio_desc/
> {
> 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,
s/devm_gpiod_request_one/devm_gpio_request_one/
> + 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
Can't really test this (no matching hardware), but with the code issues fixed
Reviewed-by: Jonas Gorski <jonas.gorski@gmail.com>
Best regards,
Jonas
next prev parent reply other threads:[~2025-08-09 10:02 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-08 15:17 [PATCH 00/21] gpiolib: fence off legacy interfaces Arnd Bergmann
2025-08-08 15:17 ` [PATCH 01/21] ARM: select legacy gpiolib interfaces where used Arnd Bergmann
2025-08-11 8:49 ` Krzysztof Kozlowski
2025-08-08 15:17 ` [PATCH 02/21] m68k: coldfire: select legacy gpiolib interface for mcfqspi Arnd Bergmann
2025-08-08 15:17 ` [PATCH 03/21] mips: select legacy gpiolib interfaces where used Arnd Bergmann
2025-08-08 15:17 ` [PATCH 04/21] sh: select legacy gpiolib interface Arnd Bergmann
2025-08-12 18:28 ` Rob Landley
2025-08-12 21:28 ` Arnd Bergmann
2025-08-08 15:17 ` [PATCH 05/21] x86/platform: select legacy gpiolib interfaces where used Arnd Bergmann
2025-08-09 10:00 ` Andy Shevchenko
2025-08-09 19:44 ` Arnd Bergmann
2025-08-10 15:12 ` Hans de Goede
2025-08-11 2:27 ` Dmitry Torokhov
2025-08-08 15:17 ` [PATCH 06/21] x86/olpc: select GPIOLIB_LEGACY Arnd Bergmann
2025-08-12 17:01 ` Borislav Petkov
2025-08-08 15:17 ` [PATCH 07/21] mfd: wm8994: remove dead legacy-gpio code Arnd Bergmann
2025-08-11 13:14 ` Bartosz Golaszewski
2025-08-08 15:17 ` [PATCH 08/21] ASoC: add GPIOLIB_LEGACY dependency where needed Arnd Bergmann
2025-08-08 15:17 ` [PATCH 09/21] input: gpio-keys: make legacy gpiolib optional Arnd Bergmann
2025-08-11 10:34 ` Matti Vaittinen
2025-08-11 12:52 ` Andy Shevchenko
2025-08-11 19:21 ` Dmitry Torokhov
2025-08-11 20:09 ` Andy Shevchenko
2025-08-12 5:11 ` Matti Vaittinen
2025-08-08 15:17 ` [PATCH 10/21] leds: gpio: make legacy gpiolib interface optional Arnd Bergmann
2025-08-18 15:37 ` Linus Walleij
2025-08-19 12:19 ` Lee Jones
2025-08-19 12:59 ` Arnd Bergmann
2025-08-20 7:16 ` Lee Jones
2025-08-20 12:00 ` Arnd Bergmann
2025-08-20 13:15 ` Andy Shevchenko
2025-08-20 13:15 ` Andy Shevchenko
2025-08-08 15:17 ` [PATCH 11/21] media: em28xx: add special case for legacy gpiolib interface Arnd Bergmann
2025-08-08 15:17 ` [PATCH 12/21] mfd: arizona: make legacy gpiolib interface optional Arnd Bergmann
2025-09-02 12:44 ` Lee Jones
2025-09-02 13:47 ` Arnd Bergmann
2025-09-03 8:05 ` Lee Jones
2025-09-03 9:26 ` Arnd Bergmann
2025-08-08 15:17 ` [PATCH 13/21] mfd: si476x: add GPIOLIB_LEGACY dependency Arnd Bergmann
2025-08-08 15:17 ` [PATCH 14/21] mfd: aat2870: " Arnd Bergmann
2025-08-08 15:17 ` [PATCH 15/21] dsa: b53: hide legacy gpiolib usage on non-mips Arnd Bergmann
2025-08-09 10:01 ` Jonas Gorski [this message]
2025-08-09 20:55 ` Arnd Bergmann
2025-08-08 15:18 ` [PATCH 16/21] ath10k: remove gpio number assignment Arnd Bergmann
2025-08-08 15:18 ` [PATCH 17/21] nfc: marvell: convert to gpio descriptors Arnd Bergmann
2025-08-09 10:09 ` Andy Shevchenko
2025-08-11 21:43 ` Dmitry Torokhov
2025-08-13 12:35 ` Andy Shevchenko
2025-08-11 7:49 ` Bartosz Golaszewski
2025-08-13 7:48 ` Krzysztof Kozlowski
2025-08-08 15:18 ` [PATCH 18/21] nfc: s3fwrn5: " Arnd Bergmann
2025-08-11 22:08 ` Dmitry Torokhov
2025-08-08 15:18 ` [PATCH 19/21] usb: udc: pxa: remove unused platform_data Arnd Bergmann
2025-08-09 10:15 ` Andy Shevchenko
2025-08-11 22:12 ` Dmitry Torokhov
2025-08-08 15:18 ` [PATCH 20/21] ASoC: pxa: add GPIOLIB_LEGACY dependency Arnd Bergmann
2025-08-08 15:18 ` [PATCH 21/21] gpiolib: turn off legacy interface by default Arnd Bergmann
2025-08-09 10:18 ` Andy Shevchenko
2025-08-09 19:47 ` Arnd Bergmann
2025-08-11 12:49 ` Andy Shevchenko
2025-08-11 13:10 ` [PATCH 00/21] gpiolib: fence off legacy interfaces Bartosz Golaszewski
2025-08-12 16:23 ` (subset) " Mark Brown
2025-09-02 12:56 ` Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAOiHx=mW8B2vQ7UhauPJpJ9KmtxTZ2-1MC3Vf2uNF9RaJ4WQ5A@mail.gmail.com' \
--to=jonas.gorski@gmail.com \
--cc=andrew@lunn.ch \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=brgl@bgdev.pl \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=kuba@kernel.org \
--cc=kylehendrydev@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=noltari@gmail.com \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=rmk+kernel@armlinux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).