GPIO interface uses deprecated GPIO sysfs interface and should use the GPIO character device

Bug #1916244 reported by Siggi Skulason
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
Confirmed
High
Samuele Pedroni

Bug Description

The snapd builtin gpio interface provides access to the GPIO sysfs Interface for userspace at sys/class/gpio/gpio

https://github.com/snapcore/snapd/blob/45d65822c95b7f7f4120ec4a9723f2af0bb5b4b8/interfaces/builtin/gpio.go#L44

The GPIO sysfs interface has however been deprecated since version 4.8 of the kernel and the snapd GPIO interface should provide access to /sys/bus/gpiochipN (or /dev/gpiochipN) as well.

Reference:

1) https://www.kernel.org/doc/html/latest/admin-guide/gpio/sysfs.html

"Warning
THIS ABI IS DEPRECATED, THE ABI DOCUMENTATION HAS BEEN MOVED TO Documentation/ABI/obsolete/sysfs-gpio AND NEW USERSPACE CONSUMERS ARE SUPPOSED TO USE THE CHARACTER DEVICE ABI. THIS OLD SYSFS ABI WILL NOT BE DEVELOPED (NO NEW FEATURES), IT WILL JUST BE MAINTAINED."

2)https://www.kernel.org/doc/Documentation/ABI/obsolete/sysfs-gpio

"This ABI is deprecated and will be removed after 2020. It is
replaced with the GPIO character device."

3) https://www.kernel.org/doc/html/latest/driver-api/gpio/intro.html

The descriptor-based interface is the preferred way to manipulate GPIOs, and is described by all the files in this directory excepted gpio-legacy.txt.
The legacy integer-based interface which is considered deprecated (but still usable for compatibility reasons) is documented in gpio-legacy.txt.

4) https://www.beyondlogic.org/an-introduction-to-chardev-gpio-and-libgpiod-on-the-raspberry-pi/

sysfs GPIO
User-mode GPIO (General Purpose Input/Output) has historically been performed via the legacy “integer-based”sysfs pseudo file system. For example, to set GPIO25, one would:

# echo out > /sys/class/gpio/gpio25/direction
# echo 1 > /sys/class/gpio/gpio25/value
GPIO access via this legacy sysfs interface has been deprecated since version 4.8 of the Linux kernel.

chardev GPIO
The new way of doing GPIO is via the “descriptor-based” character device ABI (Application Binary Interface). The interface is exposed at /dev/gpiochipN or /sys/bus/gpiochipN where N is the chip number.

description: updated
Changed in snapd:
assignee: nobody → Samuele Pedroni (pedronis)
Changed in snapd:
status: New → Confirmed
importance: Undecided → High
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.