Skip to content

gpio: create the /sys/class/gpio mount point with GPIO_SYSFS disabled

Bartosz Golaszewski linux-gpio lkml 1 version In review

Get series with b4
b4 am [email protected] change-id 20241014-gpio-class-mountpoint-2da8c54fafbe

Versions newest first

  1. v2 Latest2 patches 10 repliesIn review

Changes in v2 from the cover letter

- Don't create an empty class but use sysfs_create_mount_point() instead
- Link to v1: https://lore.kernel.org/all/[email protected]/

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2driver core: class: expose the class kobjectdrivers/base/class.c include/linux/device/class.h+12 -01 reply
2/2gpio: create the /sys/class/gpio mount point with GPIO_SYSFS disableddrivers/gpio/Kconfig drivers/gpio/gpiolib.c+24 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] gpio: create the /sys/class/gpio mount point with GPIO_SYSFS disabled

Greg, Rafael,

The first patch in this series is small but may be seen as controversial so here's a little backstory.

We have two sets of GPIO APIs currently in the kernel: the legacy one based on numbers and the modern one using descriptors. Our goal is to remove the old one from the kernel to which there are two obstacles: the first one is easier and consists of converting all remaining in-kernel users to the preferred API. This is tedious but it's all within our control, just demands a lot of effort. The second obstacle is much harder as it involves removing an existing kernel uABI that is the GPIO sysfs interface at /sys/class/gpio.

Despite providing a number of user-space tools making using the GPIO character device easier, it's become clear that some users just prefer how the sysfs interface works and want to keep using it. Unless we can provide a drop-in replacement, they will protest any attempts at removing it from the kernel. As the GPIO sysfs module is the main user of the global GPIO numberspace, we will not be able to remove it from the kernel either.

I am working on a FUSE-based libgpiod-to-sysfs compatibility layer that could replace the in-kernel sysfs and keep all the user-space programs running but in order to keep it fully compatible, we need to be able to mount it at /sys/class/gpio. We can't create directories in sysfs from user-space and with GPIO_SYSFS disabled, the directory is simply not there.

I would like to do what we already do for /sys/kernel/debug, /sys/kernel/config, etc. and create an always-empty mount point at /sys/class/gpio. To that end, I need the address of the /sys/class kobject and the first patch in this series exports it.

The second adds a Kconfig switch in GPIOLIB and code that creates the mount point.

I proposed creating an empty class stub in v1 but figured that a proper mount point will work better.

If this is ok with you, please consider leaving your Ack or taking patch 1/2 through your tree and providing me with an immutable tag.

To: Greg Kroah-Hartman <[email protected]>
To: Rafael J. Wysocki <[email protected]>
To: Linus Walleij <[email protected]>
To: Bartosz Golaszewski <[email protected]>
To: Kent Gibson <[email protected]>

Changes in v2:
- Don't create an empty class but use sysfs_create_mount_point() instead
- Link to v1: https://lore.kernel.org/all/[email protected]/

---
Bartosz Golaszewski (2):
driver core: class: expose the class kobject
gpio: create the /sys/class/gpio mount point with GPIO_SYSFS disabled

 drivers/base/class.c         |  6 ++++++
 drivers/gpio/Kconfig         | 18 ++++++++++++++++++
 drivers/gpio/gpiolib.c       |  6 ++++++
 include/linux/device/class.h |  6 ++++++
 4 files changed, 36 insertions(+)

---
base-commit: b852e1e7a0389ed6168ef1d38eb0bad71a6b11e8
change-id: 20241014-gpio-class-mountpoint-2da8c54fafbe

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>