linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Replacing global GPIO numbers in sysfs with hardware offsets
@ 2025-02-02 12:45 Bartosz Golaszewski
  2025-02-03 14:23 ` Geert Uytterhoeven
                   ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Bartosz Golaszewski @ 2025-02-02 12:45 UTC (permalink / raw)
  To: Linus Walleij, Ahmad Fatoum, Kent Gibson, Jan Lübbe,
	Marek Vasut, Geert Uytterhoeven
  Cc: open list:GPIO SUBSYSTEM

Hi!

I'll allow myself to start a thread about it before anyone invests a
significant amount of work into it. Yesterday (01.02.2025) during the
"embedded dinner" after the FOSDEM 2025 embedded devroom concluded, we
discussed the motivation behind my wish to remove /sys/class/gpio and
the reasons why many users prefer it over libgpiod or even a
user-space compatibility layer I presented during my talk earlier that
day[1].

The gist of it is: some people need to play with GPIOs very early, for
example in an initramfs that is very limited in size and doesn't
contain anything other than busybox so echoing into sysfs attributes
is preferable over trying to cram additional tools or even the entire
python interpreter into the limited system. An alternative to consider
is of course adding some limited GPIO functionality to busybox.

The main thing that bothers me in the GPIO sysfs class is not its
existence per se but the fact that it identifies individual GPIOs by
their global numbers and not hardware offsets which is the biggest
obstacle to removing the global numberspace and the legacy GPIO API
from the kernel.

I think it was Ahmad or Marek who suggested that users aren't really
attached to the global numbering but to the ease of use of sysfs.

I floated an idea of introducing a backward compatible change to sysfs
that would allow users to identify GPIOs by the label of their parent
chip and the hardware offset of the line within that chip (like what
we do for the character device) in the form of the export/unexport
pair of attributes inside the gpiochipXYZ directory associated with
given controller. These attributes, unlike the "global"
export/unexport would take the hardware offset and create the line
directory within the chip directory of which the layout would be the
same as that of its global counterpart (in fact: it could point to the
same directory in sysfs as a single line can only be requested once).

We could then encourage users to switch to using the chip-local
exports and eventually at least remove the global export/unexport pair
if we cannot make the entire sysfs class go away.

Please let me know what you think about it?

Bart

[1] https://fosdem.org/2025/schedule/event/fosdem-2025-5288-the-status-of-removing-sys-class-gpio-and-the-global-gpio-numberspace-from-the-kernel/

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2025-03-11 15:26 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-02 12:45 Replacing global GPIO numbers in sysfs with hardware offsets Bartosz Golaszewski
2025-02-03 14:23 ` Geert Uytterhoeven
2025-02-07 20:18   ` Bartosz Golaszewski
2025-02-09  9:40     ` Geert Uytterhoeven
2025-02-25 18:25       ` Ayush Singh
2025-02-25 20:20         ` Linus Walleij
2025-02-26  6:25           ` Ayush Singh
2025-02-14  9:14 ` Linus Walleij
2025-02-21 18:01   ` Marek Vasut
2025-02-25 19:54     ` Linus Walleij
2025-02-26 12:36       ` Marek Vasut
2025-02-26 19:07         ` Bartosz Golaszewski
2025-02-28  7:49         ` Linus Walleij
2025-02-28  8:49           ` Geert Uytterhoeven
2025-02-28  8:55             ` Linus Walleij
2025-02-28  9:53               ` Geert Uytterhoeven
2025-03-05  8:22                 ` Linus Walleij
2025-03-05  8:41                   ` Kent Gibson
2025-03-11 10:28                 ` Bartosz Golaszewski
2025-03-11 10:52                   ` Geert Uytterhoeven
2025-03-11 11:53                     ` Bartosz Golaszewski
2025-03-11 15:26                       ` Geert Uytterhoeven
2025-02-21 19:56   ` Ahmad Fatoum
2025-02-25 19:56     ` Linus Walleij
2025-02-24  1:49 ` Kent Gibson
2025-02-24  8:28   ` Geert Uytterhoeven
2025-02-26  9:23   ` Bartosz Golaszewski
2025-02-26 10:58     ` Kent Gibson

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).