All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Linus Walleij <linus.walleij@stericsson.com>
Cc: linux-kernel@vger.kernel.org,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: Re: [PATCH 2/2] gpiolib: Implement devm_gpio_request_one()
Date: Thu, 05 Apr 2012 21:48:32 -0700	[thread overview]
Message-ID: <20120406044832.7C80D3E0ED5@localhost> (raw)
In-Reply-To: <1333552489-27694-2-git-send-email-broonie@opensource.wolfsonmicro.com>

On Wed,  4 Apr 2012 16:14:49 +0100, Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:
> Allow drivers to use the modern request and configure idiom together
> with devres.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>  drivers/gpio/devres.c      |   29 +++++++++++++++++++++++++++++
>  include/asm-generic/gpio.h |    2 ++
>  include/linux/gpio.h       |    6 ++++++
>  3 files changed, 37 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c
> index 3dd2939..d21a9ff 100644
> --- a/drivers/gpio/devres.c
> +++ b/drivers/gpio/devres.c
> @@ -71,6 +71,35 @@ int devm_gpio_request(struct device *dev, unsigned gpio, const char *label)
>  EXPORT_SYMBOL(devm_gpio_request);
>  
>  /**
> + *	devm_gpio_request_one - request a single GPIO with initial setup
> + *	@dev:   device to request for
> + *	@gpio:	the GPIO number
> + *	@flags:	GPIO configuration as specified by GPIOF_*
> + *	@label:	a literal description string of this GPIO
> + */
> +int devm_gpio_request_one(struct device *dev, unsigned gpio,
> +			  unsigned long flags, const char *label)
> +{
> +	unsigned *dr;
> +	int rc;
> +
> +	dr = devres_alloc(devm_gpio_release, sizeof(unsigned), GFP_KERNEL);
> +	if (!dr)
> +		return -ENOMEM;
> +
> +	rc = gpio_request_one(gpio, flags, label);
> +	if (rc) {
> +		devres_free(dr);
> +		return rc;
> +	}
> +
> +	*dr = gpio;
> +	devres_add(dev, dr);
> +
> +	return 0;
> +}

Can we make devm_gpio_request a static inline wrapper around
devm_gpio_request_one() with the flags field set to '0'?  I don't liek
the duplication of this function.

Similarily, gpio_request() should actually be a static inline around
gpio_request_one() instead of the other way around as it is currently
written.

> +
> +/**
>   *      devm_gpio_free - free an interrupt
>   *      @dev: device to free gpio for
>   *      @gpio: gpio to free
> diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
> index 5f52690..4ead123 100644
> --- a/include/asm-generic/gpio.h
> +++ b/include/asm-generic/gpio.h
> @@ -179,6 +179,8 @@ extern void gpio_free_array(const struct gpio *array, size_t num);
>  
>  /* bindings for managed devices that want to request gpios */
>  int devm_gpio_request(struct device *dev, unsigned gpio, const char *label);
> +int devm_gpio_request_one(struct device *dev, unsigned gpio,
> +			  unsigned long flags, const char *label);
>  void devm_gpio_free(struct device *dev, unsigned int gpio);
>  
>  #ifdef CONFIG_GPIO_SYSFS
> diff --git a/include/linux/gpio.h b/include/linux/gpio.h
> index ceb8eef..a8bacb8 100644
> --- a/include/linux/gpio.h
> +++ b/include/linux/gpio.h
> @@ -101,6 +101,12 @@ static inline int gpio_request_one(unsigned gpio,
>  	return -ENOSYS;
>  }
>  
> +static inline int devm_gpio_request_one(struct device *dev, unsigned gpio,
> +					unsigned long flags, const char *label)
> +{
> +	return -ENOSYS;
> +}
> +
>  static inline int gpio_request_array(const struct gpio *array, size_t num)
>  {
>  	return -ENOSYS;
> -- 
> 1.7.9.1
> 

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies,Ltd.

  reply	other threads:[~2012-04-06 14:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-04 15:14 [PATCH 1/2] gpiolib: Add !CONFIG_GPIOLIB definitions of devm_ functions Mark Brown
2012-04-04 15:14 ` [PATCH 2/2] gpiolib: Implement devm_gpio_request_one() Mark Brown
2012-04-06  4:48   ` Grant Likely [this message]
2012-04-06 14:49     ` Mark Brown
2012-04-07  2:25       ` Grant Likely
2012-04-07  9:00         ` Mark Brown
2012-04-07  9:16           ` Mark Brown
2012-04-06  4:40 ` [PATCH 1/2] gpiolib: Add !CONFIG_GPIOLIB definitions of devm_ functions Grant Likely
  -- strict thread matches above, loose matches on Subject: below --
2012-05-02 11:46 Mark Brown
2012-05-02 11:46 ` [PATCH 2/2] gpiolib: Implement devm_gpio_request_one() Mark Brown
2012-05-12 19:05   ` Mark Brown
2012-05-18  0:10     ` Grant Likely
2012-05-12 23:19   ` Linus Walleij

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=20120406044832.7C80D3E0ED5@localhost \
    --to=grant.likely@secretlab.ca \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linus.walleij@stericsson.com \
    --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 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.