linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] gpio: add flags to export GPIOs when requesting
@ 2011-12-13 17:34 Wolfram Sang
  2012-01-06 15:27 ` Wolfram Sang
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2011-12-13 17:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Grant Likely, Linus Walleij, Stephen Warren, Denis Kuzmenko,
	Dong Aisheng-B29396, Wolfram Sang

Introduce new flags to automatically export GPIOs when using the convenience
functions gpio_request_one() or gpio_request_array(). This eases support for
custom boards where lots of GPIOs need to be exported for customer
applications.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---

Based on 3.2-rc5. Previous discussion (with kind of acks) can be found here

http://lkml.org/lkml/2011/11/15/378

 Documentation/gpio.txt |    3 +++
 drivers/gpio/gpiolib.c |   12 +++++++++++-
 include/linux/gpio.h   |    5 +++++
 3 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/Documentation/gpio.txt b/Documentation/gpio.txt
index 792faa3..9e28c05 100644
--- a/Documentation/gpio.txt
+++ b/Documentation/gpio.txt
@@ -303,6 +303,9 @@ where 'flags' is currently defined to specify the following properties:
 	* GPIOF_INIT_LOW	- as output, set initial level to LOW
 	* GPIOF_INIT_HIGH	- as output, set initial level to HIGH
 
+	* GPIOF_EXPORT_DIR_FIXED	- export gpio to sysfs, keep direction
+	* GPIOF_EXPORT_DIR_CHANGEABLE	- also export, allow changing direction
+
 since GPIOF_INIT_* are only valid when configured as output, so group valid
 combinations as:
 
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index a971e3d..65ba047 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1285,8 +1285,18 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
 				(flags & GPIOF_INIT_HIGH) ? 1 : 0);
 
 	if (err)
-		gpio_free(gpio);
+		goto free_gpio;
+
+	if (flags & GPIOF_EXPORT) {
+		err = gpio_export(gpio, flags & GPIOF_EXPORT_CHANGEABLE);
+		if (err)
+			goto free_gpio;
+	}
+
+	return 0;
 
+ free_gpio:
+	gpio_free(gpio);
 	return err;
 }
 EXPORT_SYMBOL_GPL(gpio_request_one);
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 38ac48b..38afe24 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -14,6 +14,11 @@
 #define GPIOF_OUT_INIT_LOW	(GPIOF_DIR_OUT | GPIOF_INIT_LOW)
 #define GPIOF_OUT_INIT_HIGH	(GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
 
+#define GPIOF_EXPORT		(1 << 2)
+#define GPIOF_EXPORT_CHANGEABLE	(1 << 3)
+#define GPIOF_EXPORT_DIR_FIXED	(GPIOF_EXPORT)
+#define GPIOF_EXPORT_DIR_CHANGEABLE (GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE)
+
 /**
  * struct gpio - a structure describing a GPIO with configuration
  * @gpio:	the GPIO number
-- 
1.7.2.5


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

* Re: [PATCH RESEND] gpio: add flags to export GPIOs when requesting
  2011-12-13 17:34 [PATCH RESEND] gpio: add flags to export GPIOs when requesting Wolfram Sang
@ 2012-01-06 15:27 ` Wolfram Sang
  2012-01-16 16:31   ` Grant Likely
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2012-01-06 15:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Grant Likely, Linus Walleij, Stephen Warren, Denis Kuzmenko,
	Dong Aisheng-B29396

[-- Attachment #1: Type: text/plain, Size: 2937 bytes --]

On Tue, Dec 13, 2011 at 06:34:01PM +0100, Wolfram Sang wrote:
> Introduce new flags to automatically export GPIOs when using the convenience
> functions gpio_request_one() or gpio_request_array(). This eases support for
> custom boards where lots of GPIOs need to be exported for customer
> applications.
> 
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> ---
> 
> Based on 3.2-rc5. Previous discussion (with kind of acks) can be found here
> 
> http://lkml.org/lkml/2011/11/15/378

Ping. I am using this patch with v3.2 right now and it is really useful
(and no build failure this time (I owe you a drink for my last patch!))

> 
>  Documentation/gpio.txt |    3 +++
>  drivers/gpio/gpiolib.c |   12 +++++++++++-
>  include/linux/gpio.h   |    5 +++++
>  3 files changed, 19 insertions(+), 1 deletions(-)
> 
> diff --git a/Documentation/gpio.txt b/Documentation/gpio.txt
> index 792faa3..9e28c05 100644
> --- a/Documentation/gpio.txt
> +++ b/Documentation/gpio.txt
> @@ -303,6 +303,9 @@ where 'flags' is currently defined to specify the following properties:
>  	* GPIOF_INIT_LOW	- as output, set initial level to LOW
>  	* GPIOF_INIT_HIGH	- as output, set initial level to HIGH
>  
> +	* GPIOF_EXPORT_DIR_FIXED	- export gpio to sysfs, keep direction
> +	* GPIOF_EXPORT_DIR_CHANGEABLE	- also export, allow changing direction
> +
>  since GPIOF_INIT_* are only valid when configured as output, so group valid
>  combinations as:
>  
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index a971e3d..65ba047 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -1285,8 +1285,18 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
>  				(flags & GPIOF_INIT_HIGH) ? 1 : 0);
>  
>  	if (err)
> -		gpio_free(gpio);
> +		goto free_gpio;
> +
> +	if (flags & GPIOF_EXPORT) {
> +		err = gpio_export(gpio, flags & GPIOF_EXPORT_CHANGEABLE);
> +		if (err)
> +			goto free_gpio;
> +	}
> +
> +	return 0;
>  
> + free_gpio:
> +	gpio_free(gpio);
>  	return err;
>  }
>  EXPORT_SYMBOL_GPL(gpio_request_one);
> diff --git a/include/linux/gpio.h b/include/linux/gpio.h
> index 38ac48b..38afe24 100644
> --- a/include/linux/gpio.h
> +++ b/include/linux/gpio.h
> @@ -14,6 +14,11 @@
>  #define GPIOF_OUT_INIT_LOW	(GPIOF_DIR_OUT | GPIOF_INIT_LOW)
>  #define GPIOF_OUT_INIT_HIGH	(GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
>  
> +#define GPIOF_EXPORT		(1 << 2)
> +#define GPIOF_EXPORT_CHANGEABLE	(1 << 3)
> +#define GPIOF_EXPORT_DIR_FIXED	(GPIOF_EXPORT)
> +#define GPIOF_EXPORT_DIR_CHANGEABLE (GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE)
> +
>  /**
>   * struct gpio - a structure describing a GPIO with configuration
>   * @gpio:	the GPIO number
> -- 
> 1.7.2.5
> 

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH RESEND] gpio: add flags to export GPIOs when requesting
  2012-01-06 15:27 ` Wolfram Sang
@ 2012-01-16 16:31   ` Grant Likely
  2012-03-30 20:29     ` Wolfram Sang
  0 siblings, 1 reply; 5+ messages in thread
From: Grant Likely @ 2012-01-16 16:31 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel, Linus Walleij, Stephen Warren, Denis Kuzmenko,
	Dong Aisheng-B29396

On Fri, Jan 06, 2012 at 04:27:41PM +0100, Wolfram Sang wrote:
> On Tue, Dec 13, 2011 at 06:34:01PM +0100, Wolfram Sang wrote:
> > Introduce new flags to automatically export GPIOs when using the convenience
> > functions gpio_request_one() or gpio_request_array(). This eases support for
> > custom boards where lots of GPIOs need to be exported for customer
> > applications.
> > 
> > Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> > ---
> > 
> > Based on 3.2-rc5. Previous discussion (with kind of acks) can be found here
> > 
> > http://lkml.org/lkml/2011/11/15/378
> 
> Ping. I am using this patch with v3.2 right now and it is really useful
> (and no build failure this time (I owe you a drink for my last patch!))

Applied, thanks.

g.

> 
> > 
> >  Documentation/gpio.txt |    3 +++
> >  drivers/gpio/gpiolib.c |   12 +++++++++++-
> >  include/linux/gpio.h   |    5 +++++
> >  3 files changed, 19 insertions(+), 1 deletions(-)
> > 
> > diff --git a/Documentation/gpio.txt b/Documentation/gpio.txt
> > index 792faa3..9e28c05 100644
> > --- a/Documentation/gpio.txt
> > +++ b/Documentation/gpio.txt
> > @@ -303,6 +303,9 @@ where 'flags' is currently defined to specify the following properties:
> >  	* GPIOF_INIT_LOW	- as output, set initial level to LOW
> >  	* GPIOF_INIT_HIGH	- as output, set initial level to HIGH
> >  
> > +	* GPIOF_EXPORT_DIR_FIXED	- export gpio to sysfs, keep direction
> > +	* GPIOF_EXPORT_DIR_CHANGEABLE	- also export, allow changing direction
> > +
> >  since GPIOF_INIT_* are only valid when configured as output, so group valid
> >  combinations as:
> >  
> > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> > index a971e3d..65ba047 100644
> > --- a/drivers/gpio/gpiolib.c
> > +++ b/drivers/gpio/gpiolib.c
> > @@ -1285,8 +1285,18 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
> >  				(flags & GPIOF_INIT_HIGH) ? 1 : 0);
> >  
> >  	if (err)
> > -		gpio_free(gpio);
> > +		goto free_gpio;
> > +
> > +	if (flags & GPIOF_EXPORT) {
> > +		err = gpio_export(gpio, flags & GPIOF_EXPORT_CHANGEABLE);
> > +		if (err)
> > +			goto free_gpio;
> > +	}
> > +
> > +	return 0;
> >  
> > + free_gpio:
> > +	gpio_free(gpio);
> >  	return err;
> >  }
> >  EXPORT_SYMBOL_GPL(gpio_request_one);
> > diff --git a/include/linux/gpio.h b/include/linux/gpio.h
> > index 38ac48b..38afe24 100644
> > --- a/include/linux/gpio.h
> > +++ b/include/linux/gpio.h
> > @@ -14,6 +14,11 @@
> >  #define GPIOF_OUT_INIT_LOW	(GPIOF_DIR_OUT | GPIOF_INIT_LOW)
> >  #define GPIOF_OUT_INIT_HIGH	(GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
> >  
> > +#define GPIOF_EXPORT		(1 << 2)
> > +#define GPIOF_EXPORT_CHANGEABLE	(1 << 3)
> > +#define GPIOF_EXPORT_DIR_FIXED	(GPIOF_EXPORT)
> > +#define GPIOF_EXPORT_DIR_CHANGEABLE (GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE)
> > +
> >  /**
> >   * struct gpio - a structure describing a GPIO with configuration
> >   * @gpio:	the GPIO number
> > -- 
> > 1.7.2.5
> > 
> 
> -- 
> Pengutronix e.K.                           | Wolfram Sang                |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |



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

* Re: [PATCH RESEND] gpio: add flags to export GPIOs when requesting
  2012-01-16 16:31   ` Grant Likely
@ 2012-03-30 20:29     ` Wolfram Sang
  2012-03-31  5:54       ` Grant Likely
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2012-03-30 20:29 UTC (permalink / raw)
  To: Grant Likely
  Cc: linux-kernel, Linus Walleij, Stephen Warren, Denis Kuzmenko,
	Dong Aisheng-B29396

[-- Attachment #1: Type: text/plain, Size: 1092 bytes --]

On Mon, Jan 16, 2012 at 09:31:54AM -0700, Grant Likely wrote:
> On Fri, Jan 06, 2012 at 04:27:41PM +0100, Wolfram Sang wrote:
> > On Tue, Dec 13, 2011 at 06:34:01PM +0100, Wolfram Sang wrote:
> > > Introduce new flags to automatically export GPIOs when using the convenience
> > > functions gpio_request_one() or gpio_request_array(). This eases support for
> > > custom boards where lots of GPIOs need to be exported for customer
> > > applications.
> > > 
> > > Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> > > ---
> > > 
> > > Based on 3.2-rc5. Previous discussion (with kind of acks) can be found here
> > > 
> > > http://lkml.org/lkml/2011/11/15/378
> > 
> > Ping. I am using this patch with v3.2 right now and it is really useful
> > (and no build failure this time (I owe you a drink for my last patch!))
> 
> Applied, thanks.

Has it been missed? I don't see it in linus-tree or your gpio-next?

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH RESEND] gpio: add flags to export GPIOs when requesting
  2012-03-30 20:29     ` Wolfram Sang
@ 2012-03-31  5:54       ` Grant Likely
  0 siblings, 0 replies; 5+ messages in thread
From: Grant Likely @ 2012-03-31  5:54 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel, Linus Walleij, Stephen Warren, Denis Kuzmenko,
	Dong Aisheng-B29396

On Fri, 30 Mar 2012 22:29:00 +0200, Wolfram Sang <w.sang@pengutronix.de> wrote:
> On Mon, Jan 16, 2012 at 09:31:54AM -0700, Grant Likely wrote:
> > On Fri, Jan 06, 2012 at 04:27:41PM +0100, Wolfram Sang wrote:
> > > On Tue, Dec 13, 2011 at 06:34:01PM +0100, Wolfram Sang wrote:
> > > > Introduce new flags to automatically export GPIOs when using the convenience
> > > > functions gpio_request_one() or gpio_request_array(). This eases support for
> > > > custom boards where lots of GPIOs need to be exported for customer
> > > > applications.
> > > > 
> > > > Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> > > > ---
> > > > 
> > > > Based on 3.2-rc5. Previous discussion (with kind of acks) can be found here
> > > > 
> > > > http://lkml.org/lkml/2011/11/15/378
> > > 
> > > Ping. I am using this patch with v3.2 right now and it is really useful
> > > (and no build failure this time (I owe you a drink for my last patch!))
> > 
> > Applied, thanks.
> 
> Has it been missed? I don't see it in linus-tree or your gpio-next?

Hmmm.  I don't know how, but I appear to have dropped this patch.  :-(
It didn't get any linux-next exposure so it will have to wait for
v3.5.  Sorry about this.  I have picked it up again and it will appear
in my gpio/next branch after the merge window closes.

g.


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

end of thread, other threads:[~2012-03-31  5:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-13 17:34 [PATCH RESEND] gpio: add flags to export GPIOs when requesting Wolfram Sang
2012-01-06 15:27 ` Wolfram Sang
2012-01-16 16:31   ` Grant Likely
2012-03-30 20:29     ` Wolfram Sang
2012-03-31  5:54       ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).