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

Greg KH
2009-12-11T15:49:19Z

On Fri, Dec 11, 2009 at 10:41:40AM +0200, Jani Nikula wrote:
> Let's see. 'udevadm monitor --env' gives me this when I 'echo add >
> uevent' for an exported gpio #5:
>
> UDEV [1230784956.241303] add /class/gpio/gpio5 (gpio)
> UDEV_LOG=3
> ACTION=add
> DEVPATH=/class/gpio/gpio5
> SUBSYSTEM=gpio
> SEQNUM=930
> UDEVD_EVENT=1
>
> Now *assuming* we had /sys/class/gpio/gpioN/name, I could create very
> crude udev rules along the lines of this:
>
> SUBSYSTEM=="gpio", ACTION=="add", ATTR{name}!="", RUN="/bin/ln -s /sys$devpath /tmp/gpio-$attr{name}"
> SUBSYSTEM=="gpio", ACTION=="remove", ATTR{name}!="", RUN="/bin/rm /tmp/gpio-$attr{name}"
>
> Not exactly pretty, but seems to work (using another attr for testing).
> Is there a more elegant way of doing this with udev when there are no
> device nodes? Or is it even sensible to use udev without the device
> nodes? And what would be the right place for the symlinks?

Kay said he didn't like you creating symlinks in /dev with udev, but
this looks ok to me.

> *If* we got that working in a sensible fashion, it'd be a matter of
> adding the "name" attribute to each gpio.

Yup, just use whatever you were wanting to use as the symlink name, it
seems that logic was already done.

thanks.

greg k-h