mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: Alexander Shiyan <shc_work@mail.ru>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] GPIO: Add gpio_to_desc helper
Date: Sat, 11 May 2013 16:50:01 +0200	[thread overview]
Message-ID: <20130511145001.GG19265@game.jcrosoft.org> (raw)
In-Reply-To: <1368283608.730392767@f336.mail.ru>

On 18:46 Sat 11 May     , Alexander Shiyan wrote:
> > > > > > On 18:04 Fri 10 May     , Alexander Shiyan wrote:
> > > > > > > Patch adds gpio_to_desc helper for validate GPIO.
> > > > > > > A bit optimization is performed (about -250 bytes on ARM).
> > > > > > > 
> > > > > > > Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
> > > > > > > ---
> > > > > > >  drivers/gpio/gpiolib.c | 97 ++++++++++++++++++++++++++------------------------
> > > > > > >  1 file changed, 51 insertions(+), 46 deletions(-)
> > > > > > > 
> > > > > > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> > > > > > > index 6398268..d7aa094 100644
> > > > > > > --- a/drivers/gpio/gpiolib.c
> > > > > > > +++ b/drivers/gpio/gpiolib.c
> > > > > > > @@ -32,20 +32,30 @@ static int gpio_ensure_requested(struct gpio_info *gi, int gpio)
> > > > > > >  	return gpio_request(gpio, "gpio");
> > > > > > >  }
> > > > > > >  
> > > > > > > +static struct gpio_info *gpio_to_desc(unsigned gpio)
> > > > > > > +{
> > > > > > > +	if (!gpio_is_valid(gpio))
> > > > > > put the WARN too as we need to known a gpio_xxx is used on a non valid gpio
> > > > > 
> > > > > Original bb code does not contain any warnings here. So if it really
> > > > > necessary it can be added later.
> > > > 
> > > > put it as we keep the code inline with the kernel a key point for sync
> > > 
> > > And this warning avoid my second patch to remove checks when we are
> > > call gpio_free/set/get etc... with non existent (optional) gpios.
> > 
> > yes as this patch break the compatibility with the kernel sorry NACK on it
> > 
> > > I strongly do not want to add it.
> > 
> > if you can gpio_xxx with an invalid gpio it's wrong
> > and as we keep the same API as in linux we need to WARN
> > as you DO need to check the gpio is valid before calling the gpio lib
> > 
> > we keep api in sync to simplify maintainance between barebox and the kernel
> 
> I prefer to add one warning to gpio_request only. It can be useful for debug
> and not annoy if gpio is really is optional. OK?
please follow the linux implementation

all of them

if I call the gpio_set_value I expect it to set the value

If I'm nust and call with a invalid big warning fix your code

if the code we mostly do not check the return of gpio_set & co

as they work if you have the gpio requested and always return 0 (mostlty)

Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2013-05-11 14:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-10 14:04 Alexander Shiyan
2013-05-10 14:12 ` Jean-Christophe PLAGNIOL-VILLARD
2013-05-11 10:54   ` Re[2]: " Alexander Shiyan
2013-05-11 11:31     ` Jean-Christophe PLAGNIOL-VILLARD
2013-05-11 12:05       ` Re[2]: " Alexander Shiyan
2013-05-11 14:38         ` Jean-Christophe PLAGNIOL-VILLARD
2013-05-11 14:46           ` Re[2]: " Alexander Shiyan
2013-05-11 14:50             ` Jean-Christophe PLAGNIOL-VILLARD [this message]

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=20130511145001.GG19265@game.jcrosoft.org \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    --cc=shc_work@mail.ru \
    /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