Re: [PATCH 2/3] gpiolib: add support for having symlinks under gpio class directory

Kay Sievers
2009-12-10T15:17:12Z

On Thu, Dec 10, 2009 at 15:49, Greg KH <gregkh@suse.de> wrote:
> On Thu, Dec 10, 2009 at 04:32:17PM +0200, Jani Nikula wrote:
>> We simply decided to extend gpio_export_link(). When it is called
>> with 'dev == NULL' (no driver), it creates an additional symlink
>> in /sys/class/gpio/
>>
>> # ls -l /sys/class/gpio/
>> --w-------    1 root     0            4096 Jan  1 00:00 export
>> lrwxrwxrwx    1 root     0               0 Jan  1 00:00 power_button -> ../../devices/virtual/gpio/gpio25
>> lrwxrwxrwx    1 root     0               0 Jan  1 00:00 gpio25 -> ../../devices/virtual/gpio/gpio25
>> lrwxrwxrwx    1 root     0               0 Jan  1 00:00 gpio38 -> ../../devices/virtual/gpio/gpio38
>> ...
>>
>> This is exactly what our patchset allows to do.
>>
>> An alternative would be a dummy driver just to create a home in sysfs
>> for the standalone GPIOs and use the gpio_export_link() to make the
>> links there.
>>
>> Any other suggestions?

We can not do anything like that. The symlink name must always match
the name in /sys/devices/, and it must be a 1:1 relation. We can not
allow anything else, it confuses tools which rightfully expect this.

You could convert the class to a "bus", the /sys/class layout is
pretty much broken by design, and should better be avoided. It's not
extensible, flat in its layout, and today just a too dumb version of
the "bus" subsystem which does not have all these limitations.

All the device links would show up in /sys/bus/gpio/devices/, here you
have the same rules as in /sys/class/: no additional symlinks, the
same names as in /sys/devices -- but you could add a custom folder to
the /sys/bus/gpio/ directory where you could do whatever fits your
needs. :)

Thanks,
Kay