Re: [patch/rfc 2.6.25-git v2] gpio: sysfs interface

From: David Brownell
Date: Thu May 01 2008 - 17:40:52 EST


On Wednesday 30 April 2008, Ben Nizette wrote:
>
> On Wed, 2008-04-30 at 14:34 -0700, David Brownell wrote:
> > Simple sysfs interface for GPIOs.
> >
> > /sys/class/gpio
> > /control ... to request a GPIO be imported or returned
> > /gpioN ... for each exported GPIO #N
> > /value ... always readable, writes fail for input GPIOs
> > /direction ... r/w as: in, out (default low); write high, low
> > /gpiochipN ... for each gpiochip; #N is its first GPIO
> > /base ... (r/o) same as N
> > /label ... (r/o) descriptive, not necessarily unique
> > /ngpio ... (r/o) number of GPIOs; numbered N .. N+(ngpio - 1)
>
> You dropped the 'device' symlink? Sure it won't always be available but
> I did quite like the idea of being able to walk back through sysfs and
> discover, for example, the SPI chip select to which it's attached.

Just didn't describe it in that summary ... like several other
standard attributes, like "uevent" and "subsystem". The only
thing different about "device" is that when the gpio_chip doesn't
say what device it uses, that will (necessarily) be missing.
And again, that's just like all other class device nodes.


> > +/*
> > + * /sys/class/gpio/control ... write-only
> > + * integer N: non-negative == export; negative == unexport
> > + */
> > +static ssize_t control_store(struct class *class, const char *buf, size_t len)
>
> Unexport gpio 0?

Yeah, gotta fix that. Unfortunately "-0" == "0" ... I'll have to
handle any leading "-" by hand. Trivial fix, in all.

- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/