From: Ben Nizette <bn@niasdigital.com>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: David Brownell <david-b@pacbell.net>, linux-kernel@vger.kernel.org
Subject: Re: [RFC] generic GPIO parameter API
Date: Wed, 04 Jun 2008 08:02:44 +1000 [thread overview]
Message-ID: <1212530564.5446.70.camel@moss.renham> (raw)
In-Reply-To: <Pine.LNX.4.64.0806031023530.20715@axis700.grange>
On Tue, 2008-06-03 at 10:29 +0200, Guennadi Liakhovetski wrote:
> On Tue, 3 Jun 2008, Ben Nizette wrote:
> > On Tue, 2008-06-03 at 08:42 +0200, Guennadi Liakhovetski wrote:
> > > On Tue, 3 Jun 2008, Ben Nizette wrote:
> > > >
> > > > I like the idea in general. The biggest worry I have is trying to find
> > > > the parameter for you to fiddle with.
> > >
> > > Oh, this doesn't worry me - I have a driver here for a controller with
> > > switchable pullups.
> >
> > You're talking about a gpio chip driver?
>
> Yes.
>
> > How does the end user go about turning the pullups on and off?
>
> Either using the in-kernel API
I guess it's this bit I was wondering about more precisely. _Which_ in
kernel API? The gpio_find_parameter thing you had above? If so, how
are you discovering the gpio_chip? (Note that if you are indeed
discovering the gpio_chip, this isn't portable. gpio chips shouldn't be
known outside of gpiolib, gpiolib's optional and separate from the gpio
framework).
> or over sysfs, if it's a user-space app.
>
> > How does the end user know that that's what they want to do?
>
> That's their problem, isn't it? We are talking about an embedded system,
> where applications are written with datasheets and schematics in hand. So,
> you will know whether or not you want to switch pullups.
>
> > > > So, I reckon if we're to do this we should stick with the current style
> > > > of gpio calls for the outside interface, maybe something more like
> > > >
> > > > int gpio_set_param(int gpio, int param, int val);
> > > > int gpio_get_param(int gpio, int param);
> > >
> > > For the get I would rather pass it "int *val" because we don't know which
> > > values are valid and which are an error code for this specific parameter.
> >
> > Well everything else in the world just uses negative returns for errors,
> > I'm sure that any parameter get/set routines can conform with that, no?
> > This way is more consistent with, gpio_{get,set}_val etc not to mention
> > the rest of the kernel.
>
> gpio_get_val() is easy - you can only get a 0 or a 1 in success case
> there. Whereas with an arbitrary gpio parameter you don't know what valid
> values it can return. Ok, practically, I can hardly imagine a GPIO
> parameter with 2^32 valid values, but who knows...
>
Hmm, in the absence of a solid use case I'm a fan of sticking with
tradition. I can just see people forgetting to put an &foo in get but
just foo in set (I know I would). But so long as it's solidly
documented then I guess I wouldn't be able to complain :-)
Just so long as we agree that there should be this kind of interface in
the gpio framework, quite apart from how it's implemented inside
gpiolib.
Cheers,
--Ben.
> Thanks
> Guennadi
> ---
> Guennadi Liakhovetski, Ph.D.
> Freelance Open-Source Software Developer
next prev parent reply other threads:[~2008-06-03 22:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-02 17:22 [RFC] generic GPIO parameter API Guennadi Liakhovetski
2008-06-02 17:54 ` Guennadi Liakhovetski
2008-06-02 23:13 ` Ben Nizette
2008-06-03 6:42 ` Guennadi Liakhovetski
2008-06-03 7:32 ` Ben Nizette
2008-06-03 8:29 ` Guennadi Liakhovetski
2008-06-03 22:02 ` Ben Nizette [this message]
2008-06-06 5:29 ` David Brownell
2008-06-06 5:50 ` Guennadi Liakhovetski
2008-06-09 16:23 ` Guennadi Liakhovetski
2008-06-09 16:54 ` Mark Brown
2008-06-09 17:09 ` Guennadi Liakhovetski
2008-06-10 9:43 ` Mark Brown
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=1212530564.5446.70.camel@moss.renham \
--to=bn@niasdigital.com \
--cc=david-b@pacbell.net \
--cc=g.liakhovetski@gmx.de \
--cc=linux-kernel@vger.kernel.org \
/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