On 2/14/25 10:14 AM, Linus Walleij wrote:
On Sun, Feb 2, 2025 at 1:46 PM Bartosz Golaszewski <brgl@xxxxxxxx> wrote:
Hi,
I'm sorry for the late reply.
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 (...)
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?
Yes, I think it is mostly equivalent to what I say in drivers/gpio/TODO,
my only point being that when we add something like this, we
put it in debugfs where it belongs, and as illustrated by your
example, it is indeed used for debugging/exploring the
system:
I would very much like to avoid having to enable debugfs on production
systems to access GPIOs in early userspace (e.g. initramfs). This was so
far possible via the sysfs API without tools, currently it is becoming
not easily possible. A sysfs API "v2" which makes that possible would be
very much appreciated.
Also note that I do not care about static GPIO number assignment in the
sysfs API, so that part can go.
----------------8<----------------------------8<------------------------
Debugfs in place of sysfs
The old sysfs code that enables simple uses of GPIOs from the
command line is still popular despite the existance of the proper
character device. The reason is that it is simple to use on
root filesystems where you only have a minimal set of tools such
as "cat", "echo" etc.
Yes
The old sysfs still need to be strongly deprecated and removed
as it relies on the global GPIO numberspace that assume a strict
order of global GPIO numbers that do not change between boots
and is independent of probe order.
Yes
To solve this and provide an ABI that people can use for hacks
and development, implement a debugfs
sysfs please.
[...]