public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] gpiolib: Add !CONFIG_GPIOLIB definitions of devm_ functions
@ 2012-04-04 15:14 Mark Brown
  2012-04-06  4:40 ` Grant Likely
  0 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2012-04-04 15:14 UTC (permalink / raw)
  To: Grant Likely, Linus Walleij; +Cc: linux-kernel, Mark Brown

Currently the managed gpio_request() and gpio_free() are not stubbed out
for configurations not using gpiolib - do that to aid use in drivers.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 include/linux/gpio.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index f8b46af..ceb8eef 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -89,6 +89,12 @@ static inline int gpio_request(unsigned gpio, const char *label)
 	return -ENOSYS;
 }
 
+static inline int devm_gpio_request(struct device *dev, unsigned gpio,
+				    const char *label)
+{
+	return -ENOSYS;
+}
+
 static inline int gpio_request_one(unsigned gpio,
 					unsigned long flags, const char *label)
 {
@@ -108,6 +114,14 @@ static inline void gpio_free(unsigned gpio)
 	WARN_ON(1);
 }
 
+static inline void devm_gpio_free(struct device *dev, unsigned gpio)
+{
+	might_sleep();
+
+	/* GPIO can never have been requested */
+	WARN_ON(1);
+}
+
 static inline void gpio_free_array(const struct gpio *array, size_t num)
 {
 	might_sleep();
-- 
1.7.9.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] gpiolib: Add !CONFIG_GPIOLIB definitions of devm_ functions
  2012-04-04 15:14 Mark Brown
@ 2012-04-06  4:40 ` Grant Likely
  0 siblings, 0 replies; 8+ messages in thread
From: Grant Likely @ 2012-04-06  4:40 UTC (permalink / raw)
  To: Mark Brown, Linus Walleij; +Cc: linux-kernel, Mark Brown

On Wed,  4 Apr 2012 16:14:48 +0100, Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:
> Currently the managed gpio_request() and gpio_free() are not stubbed out
> for configurations not using gpiolib - do that to aid use in drivers.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Applied, thanks.

g.

> ---
>  include/linux/gpio.h |   14 ++++++++++++++
>  1 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/gpio.h b/include/linux/gpio.h
> index f8b46af..ceb8eef 100644
> --- a/include/linux/gpio.h
> +++ b/include/linux/gpio.h
> @@ -89,6 +89,12 @@ static inline int gpio_request(unsigned gpio, const char *label)
>  	return -ENOSYS;
>  }
>  
> +static inline int devm_gpio_request(struct device *dev, unsigned gpio,
> +				    const char *label)
> +{
> +	return -ENOSYS;
> +}
> +
>  static inline int gpio_request_one(unsigned gpio,
>  					unsigned long flags, const char *label)
>  {
> @@ -108,6 +114,14 @@ static inline void gpio_free(unsigned gpio)
>  	WARN_ON(1);
>  }
>  
> +static inline void devm_gpio_free(struct device *dev, unsigned gpio)
> +{
> +	might_sleep();
> +
> +	/* GPIO can never have been requested */
> +	WARN_ON(1);
> +}
> +
>  static inline void gpio_free_array(const struct gpio *array, size_t num)
>  {
>  	might_sleep();
> -- 
> 1.7.9.1
> 

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] gpiolib: Add !CONFIG_GPIOLIB definitions of devm_ functions
@ 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-18  0:11 ` [PATCH 1/2] gpiolib: Add !CONFIG_GPIOLIB definitions of devm_ functions Grant Likely
  0 siblings, 2 replies; 8+ messages in thread
From: Mark Brown @ 2012-05-02 11:46 UTC (permalink / raw)
  To: Grant Likely, Linus Walleij; +Cc: linux-kernel, Mark Brown

Currently the managed gpio_request() and gpio_free() are not stubbed out
for configurations not using gpiolib - do that to aid use in drivers.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---

I thought you'd applied this but it's not showing up in -next.

 include/linux/gpio.h |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index d1890d46..8e0fe1b 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -66,6 +66,12 @@ static inline int devm_gpio_request(struct device *dev, unsigned gpio,
 	return -ENOSYS;
 }
 
+static inline int devm_gpio_request(struct device *dev, unsigned gpio,
+				    const char *label)
+{
+	return -ENOSYS;
+}
+
 static inline int gpio_request_one(unsigned gpio,
 					unsigned long flags, const char *label)
 {
@@ -93,6 +99,14 @@ static inline void devm_gpio_free(struct device *dev, unsigned gpio)
 	WARN_ON(1);
 }
 
+static inline void devm_gpio_free(struct device *dev, unsigned gpio)
+{
+	might_sleep();
+
+	/* GPIO can never have been requested */
+	WARN_ON(1);
+}
+
 static inline void gpio_free_array(const struct gpio *array, size_t num)
 {
 	might_sleep();
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] gpiolib: Implement devm_gpio_request_one()
  2012-05-02 11:46 [PATCH 1/2] gpiolib: Add !CONFIG_GPIOLIB definitions of devm_ functions Mark Brown
@ 2012-05-02 11:46 ` Mark Brown
  2012-05-12 19:05   ` Mark Brown
  2012-05-12 23:19   ` Linus Walleij
  2012-05-18  0:11 ` [PATCH 1/2] gpiolib: Add !CONFIG_GPIOLIB definitions of devm_ functions Grant Likely
  1 sibling, 2 replies; 8+ messages in thread
From: Mark Brown @ 2012-05-02 11:46 UTC (permalink / raw)
  To: Grant Likely, Linus Walleij; +Cc: linux-kernel, Mark Brown

Allow drivers to use the modern request and configure idiom together
with devres.

As with plain gpio_request() and gpio_request_one() we can't implement
the old school version in terms of _one() as this would force the
explicit selection of a direction in gpio_request() which could break
systems if we pick the wrong one.  Implementing devm_gpio_request_one()
in terms of devm_gpio_request() would needlessly complicate things or
lead to duplication from the unmanaged version depending on how it's
done.

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(+)

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;
+}
+
+/**
  *      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 8e0fe1b..a68024e 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -78,6 +78,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.10


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] gpiolib: Implement devm_gpio_request_one()
  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
  1 sibling, 1 reply; 8+ messages in thread
From: Mark Brown @ 2012-05-12 19:05 UTC (permalink / raw)
  To: Grant Likely, Linus Walleij; +Cc: linux-kernel

On Wed, May 02, 2012 at 12:46:46PM +0100, Mark Brown wrote:
> Allow drivers to use the modern request and configure idiom together
> with devres.

> As with plain gpio_request() and gpio_request_one() we can't implement
> the old school version in terms of _one() as this would force the
> explicit selection of a direction in gpio_request() which could break
> systems if we pick the wrong one.  Implementing devm_gpio_request_one()
> in terms of devm_gpio_request() would needlessly complicate things or
> lead to duplication from the unmanaged version depending on how it's
> done.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Any chance we can get this into 3.5?  Writing error handling code is
boring :)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] gpiolib: Implement devm_gpio_request_one()
  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-12 23:19   ` Linus Walleij
  1 sibling, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2012-05-12 23:19 UTC (permalink / raw)
  To: Mark Brown; +Cc: Grant Likely, Linus Walleij, linux-kernel

On Wed, May 2, 2012 at 1:46 PM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:

> Allow drivers to use the modern request and configure idiom together
> with devres.
>
> As with plain gpio_request() and gpio_request_one() we can't implement
> the old school version in terms of _one() as this would force the
> explicit selection of a direction in gpio_request() which could break
> systems if we pick the wrong one.  Implementing devm_gpio_request_one()
> in terms of devm_gpio_request() would needlessly complicate things or
> lead to duplication from the unmanaged version depending on how it's
> done.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] gpiolib: Implement devm_gpio_request_one()
  2012-05-12 19:05   ` Mark Brown
@ 2012-05-18  0:10     ` Grant Likely
  0 siblings, 0 replies; 8+ messages in thread
From: Grant Likely @ 2012-05-18  0:10 UTC (permalink / raw)
  To: Mark Brown, Linus Walleij; +Cc: linux-kernel

On Sat, 12 May 2012 20:05:02 +0100, Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:
> On Wed, May 02, 2012 at 12:46:46PM +0100, Mark Brown wrote:
> > Allow drivers to use the modern request and configure idiom together
> > with devres.
> 
> > As with plain gpio_request() and gpio_request_one() we can't implement
> > the old school version in terms of _one() as this would force the
> > explicit selection of a direction in gpio_request() which could break
> > systems if we pick the wrong one.  Implementing devm_gpio_request_one()
> > in terms of devm_gpio_request() would needlessly complicate things or
> > lead to duplication from the unmanaged version depending on how it's
> > done.
> > 
> > Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> 
> Any chance we can get this into 3.5?  Writing error handling code is
> boring :)

Applied, thanks.  I'll push it out this evening.

g.


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] gpiolib: Add !CONFIG_GPIOLIB definitions of devm_ functions
  2012-05-02 11:46 [PATCH 1/2] gpiolib: Add !CONFIG_GPIOLIB definitions of devm_ functions Mark Brown
  2012-05-02 11:46 ` [PATCH 2/2] gpiolib: Implement devm_gpio_request_one() Mark Brown
@ 2012-05-18  0:11 ` Grant Likely
  1 sibling, 0 replies; 8+ messages in thread
From: Grant Likely @ 2012-05-18  0:11 UTC (permalink / raw)
  To: Mark Brown, Linus Walleij; +Cc: linux-kernel, Mark Brown

On Wed,  2 May 2012 12:46:45 +0100, Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:
> Currently the managed gpio_request() and gpio_free() are not stubbed out
> for configurations not using gpiolib - do that to aid use in drivers.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> 
> I thought you'd applied this but it's not showing up in -next.

It was in my local tree.  I think I just forgot to push it out.

g.

> 
>  include/linux/gpio.h |   14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/include/linux/gpio.h b/include/linux/gpio.h
> index d1890d46..8e0fe1b 100644
> --- a/include/linux/gpio.h
> +++ b/include/linux/gpio.h
> @@ -66,6 +66,12 @@ static inline int devm_gpio_request(struct device *dev, unsigned gpio,
>  	return -ENOSYS;
>  }
>  
> +static inline int devm_gpio_request(struct device *dev, unsigned gpio,
> +				    const char *label)
> +{
> +	return -ENOSYS;
> +}
> +
>  static inline int gpio_request_one(unsigned gpio,
>  					unsigned long flags, const char *label)
>  {
> @@ -93,6 +99,14 @@ static inline void devm_gpio_free(struct device *dev, unsigned gpio)
>  	WARN_ON(1);
>  }
>  
> +static inline void devm_gpio_free(struct device *dev, unsigned gpio)
> +{
> +	might_sleep();
> +
> +	/* GPIO can never have been requested */
> +	WARN_ON(1);
> +}
> +
>  static inline void gpio_free_array(const struct gpio *array, size_t num)
>  {
>  	might_sleep();
> -- 
> 1.7.10
> 

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-05-18  0:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-02 11:46 [PATCH 1/2] gpiolib: Add !CONFIG_GPIOLIB definitions of devm_ functions 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
2012-05-18  0:11 ` [PATCH 1/2] gpiolib: Add !CONFIG_GPIOLIB definitions of devm_ functions Grant Likely
  -- strict thread matches above, loose matches on Subject: below --
2012-04-04 15:14 Mark Brown
2012-04-06  4:40 ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox