From: Trent Piepho <tpiepho@freescale.com>
To: David Brownell <david-b@pacbell.net>
Cc: lkml <linux-kernel@vger.kernel.org>,
hartleys <hartleys@visionengravers.com>,
Ben Nizette <bn@niasdigital.com>,
Mike Frysinger <vapier.adi@gmail.com>,
Bryan Wu <cooloney@kernel.org>
Subject: Re: [patch/rfc 2.6.25-git] gpio: sysfs interface
Date: Mon, 28 Apr 2008 16:09:05 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0804281507160.6832@t2.domain.actdsltmp> (raw)
In-Reply-To: <200804281239.51729.david-b@pacbell.net>
On Mon, 28 Apr 2008, David Brownell wrote:
> Simple sysfs interface for GPIOs.
>
> /sys/class/gpio
> /gpio-N ... for each exported GPIO #N
I liked it better they way I had it, "label:N".
When you have multiple GPIO sources, it's a lot easier to see where they are
comming from if they use the chip label. Especially if support for dynamic
allocation of gpio numbers is written.
> /value ... always readable, writes fail except for output GPIOs
> /direction ... writable as: in, out (default low), high, low
You took away the code for the label field? That was one of the features of
my code that Ben Nizette mentioned as an advantage over a char-device
interface.
> /control ... to request a GPIO be exported or unexported
>
> GPIOs may be exported by kernel code using gpio_export(), which should
> be most useful for driver debugging. Userspace may also ask that they
> be exported by writing to the sysfs control file, helping to cope with
> incomplete board support:
Why can't all gpios appear read-only in sysfs by default?
> This adds a device pointer to "struct gpio_chip". When GPIO providers
> initialize that, sysfs gpio class devices become children of that device
> instead of being "virtual" devices. The (few) gpio_chip providers which
> have such a device node have been updated. (Some also needed to update
> their module "owner" field ... for which missing kerneldoc was added.)
I don't see what's wrong with having devices add to gpiolib create a device
for the gpio's to be the children of. You said that some devices can't do
this, but I don't see the difficulty.
platform_device_register_simple("my-gpio", 0, NULL, 0);
How hard is that?
> Based on a patch from Trent Piepho <tpiepho@freescale.com>, and comments
> from various folk including Hartley Sweeten.
I don't recall seeing those comments. Where were they posted?
> + status = gpio_export(gpio);
> + if (status < 0)
> + gpio_free(gpio);
> + else
> + set_bit(FLAG_SYSFS, &gpio_desc[gpio].flags);
> +
> + } else if (strcmp(cmd, "unexport") == 0) {
> + /* reject bogus commands (gpio_unexport ignores them) */
> + if (!gpio_is_valid(gpio))
> + goto fail;
> + if (!test_and_clear_bit(FLAG_SYSFS, &gpio_desc[gpio].flags))
> + goto fail;
> +
> + gpio_free(gpio);
Maybe you could simplify the text parsing by having positive gpio numbers
export the gpio and negative numbers un-export the gpio? Then there would not
be any need to parse a command with arguments.
next prev parent reply other threads:[~2008-04-28 23:14 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-28 19:39 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 [this message]
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
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.0804281507160.6832@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®