From: Trent Piepho <tpiepho@freescale.com>
To: David Brownell <david-b@pacbell.net>
Cc: lkml <linux-kernel@vger.kernel.org>,
Ben Nizette <bn@niasdigital.com>,
Trent Piepho <tpiepho@freescale.com>,
hartleys <hartleys@visionengravers.com>,
Mike Frysinger <vapier.adi@gmail.com>,
Bryan Wu <cooloney@kernel.org>
Subject: Re: [patch/rfc 2.6.25-git v2] gpio: sysfs interface
Date: Wed, 30 Apr 2008 15:47:50 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0804301511120.1537@t2.domain.actdsltmp> (raw)
In-Reply-To: <200804301434.25211.david-b@pacbell.net>
On Wed, 30 Apr 2008, 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)
"simple"? What I had was a lot simpler.
So, I want to set gpio 5 on a pcf9557 extender.
cat 1 > /sys/class/gpio/pcf9557-0:0
But now I can't do this anymore, it has to be harder. So how do I do it? It
doesn't seem very considerate to ignore the real use cases of the person who
wrote the code to begin with.
> GPIOs may be exported by kernel code using gpio_export(), which should
> be most useful for driver debugging. Userspace may also ask that they
I have a JTAG interface implemented via GPIOs. With my system, one can see
the gpios used in sysfs with the proper labels (TCK, TDO, TDI, etc.). This is
very helpful for people connecting something to the interface to know they
have the write gpio lines connected. What's the point of allowing
one to label gpio lines if it's not going to be easy to see?
It also means that if they have trouble getting what their connecting to work,
they can always control the line via sysfs and see with a probe that it
changes. They can raise TRST (which they know is the right line from the
label) and see the system reset.
Adding gpio_export() calls to the kernel source and recompiling and
re-flashing just isn't going to happen for a large portion of users.
Why can't the gpio lines just show up when something requests them?
> be imported by writing to the sysfs control file, helping to cope with
> incomplete board support:
>
> echo "23" > /sys/class/gpio/control
> ... will gpio_request(23, "sysfs") and gpio_export(23); use
So if a driver is already using gpio 23, then there is no way to see it in
sysfs, since the gpio_request() will fail?
> /sys/class/gpio/gpio-23/direction to configure it.
> echo "-23" > /sys/class/gpio/control
> ... will gpio_free(23)
So if a driver was already using gpio 23 and you wanted to look at it from
userspace, you'll free it from both sysfs and the driver that was using it
when you're done?
> +When a kernel driver has requested a GPIO, it may only be made available
> +in the sysfs interface by gpio_export(). This prevents userspace code
> +from clobbering important state.
You could say the same about 90% of the writable files in sysfs.
next prev parent reply other threads:[~2008-04-30 22:52 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-28 19:39 [patch/rfc 2.6.25-git] " David Brownell
2008-04-28 20:46 ` Andrew Morton
2008-04-28 23:28 ` David Brownell
2008-04-29 2:54 ` Andrew Morton
2008-04-29 3:42 ` Greg KH
2008-04-29 18:45 ` David Brownell
2008-04-29 19:09 ` Andrew Morton
2008-05-02 20:36 ` Pavel Machek
2008-05-17 22:14 ` David Brownell
2008-05-18 0:36 ` [patch 2.6.26-rc2-git] " David Brownell
2008-05-20 7:17 ` Andrew Morton
2008-05-18 4:55 ` [patch/rfc 2.6.25-git] " Ben Nizette
2008-05-19 22:39 ` Pavel Machek
2008-05-20 1:26 ` David Brownell
2008-05-20 8:02 ` Pavel Machek
2008-04-28 23:01 ` Ben Nizette
2008-04-29 0:44 ` David Brownell
2008-04-29 1:58 ` Ben Nizette
2008-04-29 3:44 ` David Brownell
2008-04-29 4:47 ` Ben Nizette
2008-04-29 21:28 ` David Brownell
2008-04-29 6:17 ` Trent Piepho
2008-04-29 22:39 ` David Brownell
2008-04-28 23:09 ` Trent Piepho
2008-04-29 0:45 ` David Brownell
2008-04-29 5:48 ` Trent Piepho
2008-04-29 12:35 ` Ben Nizette
2008-04-29 18:15 ` Trent Piepho
2008-04-29 21:56 ` David Brownell
2008-04-30 0:49 ` Trent Piepho
2008-04-30 17:49 ` David Brownell
2008-04-29 21:55 ` David Brownell
2008-04-29 23:29 ` Ben Nizette
2008-04-30 1:04 ` David Brownell
2008-04-30 2:08 ` Ben Nizette
2008-04-30 3:13 ` Trent Piepho
2008-04-30 10:33 ` Ben Nizette
2008-04-30 17:42 ` David Brownell
2008-04-30 21:34 ` [patch/rfc 2.6.25-git v2] " David Brownell
2008-04-30 22:47 ` Trent Piepho [this message]
2008-04-30 23:14 ` Ben Nizette
2008-05-01 2:12 ` David Brownell
2008-05-01 2:08 ` David Brownell
2008-05-01 3:41 ` Trent Piepho
2008-05-01 4:35 ` David Brownell
2008-05-01 21:16 ` Trent Piepho
2008-05-03 2:58 ` David Brownell
2008-05-03 3:05 ` David Brownell
2008-04-30 23:28 ` Ben Nizette
2008-05-01 21:40 ` David Brownell
2008-04-29 0:47 ` [patch/rfc 2.6.25-git] " Ben Nizette
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0804301511120.1537@t2.domain.actdsltmp \
--to=tpiepho@freescale.com \
--cc=bn@niasdigital.com \
--cc=cooloney@kernel.org \
--cc=david-b@pacbell.net \
--cc=hartleys@visionengravers.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vapier.adi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®