From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] gpiolib: add gpio_request and gpio_free support
Date: Fri, 21 Dec 2012 11:33:35 +0100 [thread overview]
Message-ID: <20121221103335.GA3406@game.jcrosoft.org> (raw)
In-Reply-To: <20121221071223.GK26326@pengutronix.de>
On 08:12 Fri 21 Dec , Sascha Hauer wrote:
> On Thu, Dec 20, 2012 at 03:23:59PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > as today if no request or free provided do not complain
> >
> > if the gpio is not request auto requested at first use
> >
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> > drivers/gpio/gpio.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++-----
> > include/gpio.h | 7 +++++
> > 2 files changed, 87 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/gpio/gpio.c b/drivers/gpio/gpio.c
> > index 042a062..e29f0ba 100644
> > --- a/drivers/gpio/gpio.c
> > +++ b/drivers/gpio/gpio.c
> > @@ -1,19 +1,71 @@
> > #include <common.h>
> > #include <gpio.h>
> > #include <errno.h>
> > +#include <malloc.h>
> >
> > static LIST_HEAD(chip_list);
> >
> > -static struct gpio_chip *gpio_desc[ARCH_NR_GPIOS];
> > +struct gpio_info {
> > + struct gpio_chip *chip;
> > + bool requested;
> > + char *label;
> > +};
> > +
> > +static struct gpio_info gpio_desc[ARCH_NR_GPIOS];
> > +
> > +int gpio_request(unsigned gpio, const char *label)
> > +{
> > + struct gpio_info *gi = &gpio_desc[gpio];
> > + struct gpio_chip *chip = gi->chip;
> > + int ret;
> > +
> > + if (!gpio_is_valid(gpio))
> > + return -EINVAL;
> > + if (!chip)
> > + return -EINVAL;
> > + if (gi->requested)
> > + return -ENODEV;
>
> -EBUSY?
>
> > void gpio_set_value(unsigned gpio, int value)
> > {
> > - struct gpio_chip *chip = gpio_desc[gpio];
> > + struct gpio_info *gi = &gpio_desc[gpio];
> > + struct gpio_chip *chip = gi->chip;
> >
> > if (!gpio_is_valid(gpio))
> > return;
> > if (!chip)
> > return;
> > + if (!gi->requested && gpio_request(gpio, "gpio"))
> > + return;
>
> Could you factor out this into a gpio_ensure_requested function? This
> way we would have a single point where the implicit gpio_request calls
> are handled.
ok
Best Regards,
J.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2012-12-21 10:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-20 13:12 [PATCH 0/2] gpiolib: add request and free support Jean-Christophe PLAGNIOL-VILLARD
2012-12-20 14:23 ` [PATCH 1/2] gpiolib: add gpio_request and gpio_free support Jean-Christophe PLAGNIOL-VILLARD
2012-12-20 14:24 ` [PATCH 2/2] gpiolib: add command to dump the current gpio status Jean-Christophe PLAGNIOL-VILLARD
2012-12-21 7:12 ` [PATCH 1/2] gpiolib: add gpio_request and gpio_free support Sascha Hauer
2012-12-21 10:33 ` 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=20121221103335.GA3406@game.jcrosoft.org \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.