Re: [PATCH v2 8/9] gpio: sysfs: allow disabling the legacy parts of the GPIO sysfs interface
From: Geert Uytterhoeven
Date: Tue Jun 24 2025 - 07:32:06 EST
Hi Bartosz,
On Mon, 23 Jun 2025 at 11:01, Bartosz Golaszewski <brgl@xxxxxxxx> wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
>
> Add a Kconfig switch allowing to disable the legacy parts of the GPIO
> sysfs interface. This means that even though we keep the
> /sys/class/gpio/ directory, it no longer contains the global
> export/unexport attribute pair (instead, the user should use the
> per-chip export/unpexport) nor the gpiochip$BASE entries. This option
> default to y if GPIO sysfs is enabled but we'll default it to n at some
> point in the future.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
Thanks for your patch!
> --- a/drivers/gpio/gpiolib-sysfs.c
> +++ b/drivers/gpio/gpiolib-sysfs.c
> @@ -968,6 +994,7 @@ int gpiochip_sysfs_register(struct gpio_device *gdev)
>
> guard(mutex)(&sysfs_lock);
>
> +#if IS_ENABLED(CONFIG_GPIO_SYSFS_LEGACY)
> /* use chip->base for the ID; it's already known to be unique */
> data->cdev_base = device_create_with_groups(&gpio_class, parent,
> MKDEV(0, 0), data,
> @@ -979,13 +1006,16 @@ int gpiochip_sysfs_register(struct gpio_device *gdev)
> kfree(data);
> return err;
> }
> +#endif /* CONFIG_GPIO_SYSFS_LEGACY */
"err" is always declared, but only used in this block.
Hence if CONFIG_GPIO_SYSFS_LEGACY=n:
drivers/gpio/gpiolib-sysfs.c: In function ‘gpiochip_sysfs_register’:
drivers/gpio/gpiolib-sysfs.c:962:13: error: unused variable ‘err’
[-Werror=unused-variable]
962 | int err;
| ^~~
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds