All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: make newer functionality available outside of GPIOLIB
@ 2011-02-08 22:44 ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2011-02-08 22:44 UTC (permalink / raw
  To: linux-kernel
  Cc: Wolfram Sang, David Brownell, Eric Miao, Dmitry Torokhov,
	Arnd Bergmann, Andrew Morton, Mark Brown, Anton Vorontsov,
	Greg Kroah-Hartman, open list:GENERIC INCLUDE/A...

The gpio subsystems offers an API which requires a dependency on GENERIC_GPIO
when used by drivers. There is also implementation framework of this API, so
archs can select GPIOLIB if they intend to use it. But they don't have to, they
can still provide GENERIC_GPIO without GPIOLIB using custom routines.

Commit 3e45f1d1155894e6f4291f5536b224874d52d8e2 (gpio: introduce
gpio_request_one() and friends) added some functions, defines and a struct to
the API, but made them available only for GPIOLIB. So, drivers using these new
functions will fail in the case of GENERIC_GPIO && !GPIOLIB.

The new functions have already been added to the fallback in <linux/gpio.h>,
but the data structure were still not available. Change this by reorganizing
the include-files.

Fixes issues like (in linux-next currently):

drivers/input/touchscreen/ads7846.c:959: error: 'GPIOF_DIR_IN' undeclared (first use in this function)

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Dmitry Torokhov <dtor@mail.ru>
---

Based on 2.6.38-rc4. Compile tested on x86.

 include/asm-generic/gpio.h   |   31 +++++--------------------------
 include/linux/gpio.h         |    2 +-
 include/linux/gpio_generic.h |   26 ++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 27 deletions(-)
 create mode 100644 include/linux/gpio_generic.h

diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index ff5c660..ebc73bc 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -4,6 +4,7 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/errno.h>
+#include <linux/gpio_generic.h>
 
 #ifdef CONFIG_GPIOLIB
 
@@ -158,6 +159,10 @@ extern int gpio_set_debounce(unsigned gpio, unsigned debounce);
 extern int gpio_get_value_cansleep(unsigned gpio);
 extern void gpio_set_value_cansleep(unsigned gpio, int value);
 
+extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
+extern int gpio_request_array(struct gpio *array, size_t num);
+extern void gpio_free_array(struct gpio *array, size_t num);
+
 
 /* A platform's <asm/gpio.h> code may want to inline the I/O calls when
  * the GPIO is constant and refers to some always-present controller,
@@ -170,32 +175,6 @@ extern int __gpio_cansleep(unsigned gpio);
 
 extern int __gpio_to_irq(unsigned gpio);
 
-#define GPIOF_DIR_OUT	(0 << 0)
-#define GPIOF_DIR_IN	(1 << 0)
-
-#define GPIOF_INIT_LOW	(0 << 1)
-#define GPIOF_INIT_HIGH	(1 << 1)
-
-#define GPIOF_IN		(GPIOF_DIR_IN)
-#define GPIOF_OUT_INIT_LOW	(GPIOF_DIR_OUT | GPIOF_INIT_LOW)
-#define GPIOF_OUT_INIT_HIGH	(GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
-
-/**
- * struct gpio - a structure describing a GPIO with configuration
- * @gpio:	the GPIO number
- * @flags:	GPIO configuration as specified by GPIOF_*
- * @label:	a literal description string of this GPIO
- */
-struct gpio {
-	unsigned	gpio;
-	unsigned long	flags;
-	const char	*label;
-};
-
-extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
-extern int gpio_request_array(struct gpio *array, size_t num);
-extern void gpio_free_array(struct gpio *array, size_t num);
-
 #ifdef CONFIG_GPIO_SYSFS
 
 /*
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 32720ba..584ceb6 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -11,9 +11,9 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/errno.h>
+#include <linux/gpio_generic.h>
 
 struct device;
-struct gpio;
 struct gpio_chip;
 
 /*
diff --git a/include/linux/gpio_generic.h b/include/linux/gpio_generic.h
new file mode 100644
index 0000000..d662697
--- /dev/null
+++ b/include/linux/gpio_generic.h
@@ -0,0 +1,26 @@
+#ifndef __LINUX_GPIO_GENERIC_H
+#define __LINUX_GPIO_GENERIC_H
+
+/**
+ * struct gpio - a structure describing a GPIO with configuration
+ * @gpio:	the GPIO number
+ * @flags:	GPIO configuration as specified by GPIOF_*
+ * @label:	a literal description string of this GPIO
+ */
+struct gpio {
+	unsigned	gpio;
+	unsigned long	flags;
+	const char	*label;
+};
+
+#define GPIOF_DIR_OUT	(0 << 0)
+#define GPIOF_DIR_IN	(1 << 0)
+
+#define GPIOF_INIT_LOW	(0 << 1)
+#define GPIOF_INIT_HIGH	(1 << 1)
+
+#define GPIOF_IN		(GPIOF_DIR_IN)
+#define GPIOF_OUT_INIT_LOW	(GPIOF_DIR_OUT | GPIOF_INIT_LOW)
+#define GPIOF_OUT_INIT_HIGH	(GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
+
+#endif /* __LINUX_GPIO_GENERIC_H */
-- 
1.7.2.3


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

* [PATCH] gpio: make newer functionality available outside of GPIOLIB
@ 2011-02-08 22:44 ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2011-02-08 22:44 UTC (permalink / raw
  To: linux-kernel
  Cc: Wolfram Sang, David Brownell, Eric Miao, Dmitry Torokhov,
	Arnd Bergmann, Andrew Morton, Mark Brown, Anton Vorontsov,
	Greg Kroah-Hartman, open list:GENERIC INCLUDE/A...

The gpio subsystems offers an API which requires a dependency on GENERIC_GPIO
when used by drivers. There is also implementation framework of this API, so
archs can select GPIOLIB if they intend to use it. But they don't have to, they
can still provide GENERIC_GPIO without GPIOLIB using custom routines.

Commit 3e45f1d1155894e6f4291f5536b224874d52d8e2 (gpio: introduce
gpio_request_one() and friends) added some functions, defines and a struct to
the API, but made them available only for GPIOLIB. So, drivers using these new
functions will fail in the case of GENERIC_GPIO && !GPIOLIB.

The new functions have already been added to the fallback in <linux/gpio.h>,
but the data structure were still not available. Change this by reorganizing
the include-files.

Fixes issues like (in linux-next currently):

drivers/input/touchscreen/ads7846.c:959: error: 'GPIOF_DIR_IN' undeclared (first use in this function)

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Dmitry Torokhov <dtor@mail.ru>
---

Based on 2.6.38-rc4. Compile tested on x86.

 include/asm-generic/gpio.h   |   31 +++++--------------------------
 include/linux/gpio.h         |    2 +-
 include/linux/gpio_generic.h |   26 ++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 27 deletions(-)
 create mode 100644 include/linux/gpio_generic.h

diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index ff5c660..ebc73bc 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -4,6 +4,7 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/errno.h>
+#include <linux/gpio_generic.h>
 
 #ifdef CONFIG_GPIOLIB
 
@@ -158,6 +159,10 @@ extern int gpio_set_debounce(unsigned gpio, unsigned debounce);
 extern int gpio_get_value_cansleep(unsigned gpio);
 extern void gpio_set_value_cansleep(unsigned gpio, int value);
 
+extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
+extern int gpio_request_array(struct gpio *array, size_t num);
+extern void gpio_free_array(struct gpio *array, size_t num);
+
 
 /* A platform's <asm/gpio.h> code may want to inline the I/O calls when
  * the GPIO is constant and refers to some always-present controller,
@@ -170,32 +175,6 @@ extern int __gpio_cansleep(unsigned gpio);
 
 extern int __gpio_to_irq(unsigned gpio);
 
-#define GPIOF_DIR_OUT	(0 << 0)
-#define GPIOF_DIR_IN	(1 << 0)
-
-#define GPIOF_INIT_LOW	(0 << 1)
-#define GPIOF_INIT_HIGH	(1 << 1)
-
-#define GPIOF_IN		(GPIOF_DIR_IN)
-#define GPIOF_OUT_INIT_LOW	(GPIOF_DIR_OUT | GPIOF_INIT_LOW)
-#define GPIOF_OUT_INIT_HIGH	(GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
-
-/**
- * struct gpio - a structure describing a GPIO with configuration
- * @gpio:	the GPIO number
- * @flags:	GPIO configuration as specified by GPIOF_*
- * @label:	a literal description string of this GPIO
- */
-struct gpio {
-	unsigned	gpio;
-	unsigned long	flags;
-	const char	*label;
-};
-
-extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
-extern int gpio_request_array(struct gpio *array, size_t num);
-extern void gpio_free_array(struct gpio *array, size_t num);
-
 #ifdef CONFIG_GPIO_SYSFS
 
 /*
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 32720ba..584ceb6 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -11,9 +11,9 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/errno.h>
+#include <linux/gpio_generic.h>
 
 struct device;
-struct gpio;
 struct gpio_chip;
 
 /*
diff --git a/include/linux/gpio_generic.h b/include/linux/gpio_generic.h
new file mode 100644
index 0000000..d662697
--- /dev/null
+++ b/include/linux/gpio_generic.h
@@ -0,0 +1,26 @@
+#ifndef __LINUX_GPIO_GENERIC_H
+#define __LINUX_GPIO_GENERIC_H
+
+/**
+ * struct gpio - a structure describing a GPIO with configuration
+ * @gpio:	the GPIO number
+ * @flags:	GPIO configuration as specified by GPIOF_*
+ * @label:	a literal description string of this GPIO
+ */
+struct gpio {
+	unsigned	gpio;
+	unsigned long	flags;
+	const char	*label;
+};
+
+#define GPIOF_DIR_OUT	(0 << 0)
+#define GPIOF_DIR_IN	(1 << 0)
+
+#define GPIOF_INIT_LOW	(0 << 1)
+#define GPIOF_INIT_HIGH	(1 << 1)
+
+#define GPIOF_IN		(GPIOF_DIR_IN)
+#define GPIOF_OUT_INIT_LOW	(GPIOF_DIR_OUT | GPIOF_INIT_LOW)
+#define GPIOF_OUT_INIT_HIGH	(GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
+
+#endif /* __LINUX_GPIO_GENERIC_H */
-- 
1.7.2.3

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

* Re: [PATCH] gpio: make newer functionality available outside of GPIOLIB
  2011-02-08 22:44 ` Wolfram Sang
  (?)
@ 2011-02-08 23:18 ` Lars-Peter Clausen
  2011-02-09 13:34   ` Wolfram Sang
  -1 siblings, 1 reply; 4+ messages in thread
From: Lars-Peter Clausen @ 2011-02-08 23:18 UTC (permalink / raw
  To: Wolfram Sang
  Cc: linux-kernel, David Brownell, Eric Miao, Dmitry Torokhov,
	Arnd Bergmann (maintainer:GENERIC INCLUDE/A...),
	Andrew Morton (commit_signer:4/8=50%),
	Mark Brown (commit_signer:1/8=12%),
	Anton Vorontsov (commit_signer:1/8=12%),
	Greg Kroah-Hartman (commit_signer:1/8=12%),
	open list:GENERIC INCLUDE/A...

On 02/08/2011 11:44 PM, Wolfram Sang wrote:
> The gpio subsystems offers an API which requires a dependency on GENERIC_GPIO
> when used by drivers. There is also implementation framework of this API, so
> archs can select GPIOLIB if they intend to use it. But they don't have to, they
> can still provide GENERIC_GPIO without GPIOLIB using custom routines.
> 
> Commit 3e45f1d1155894e6f4291f5536b224874d52d8e2 (gpio: introduce
> gpio_request_one() and friends) added some functions, defines and a struct to
> the API, but made them available only for GPIOLIB. So, drivers using these new
> functions will fail in the case of GENERIC_GPIO && !GPIOLIB.
Actually the patch fixes only the case where !GENERIC_GPIO.
In the GENERIC_GPIO && !GPIOLIB case gpio_request_one and friends are likely to
be undefined unless the arch gpio code actually implements them.

Given that these functions are pretty generic and build on top of the generic
gpio interface I think they should be available if GENERIC_GPIO is selected and
not only just through GPIOLIB. Otherwise all the archs not using gpiolib but
providing the gpio api would have to be patched as well.

- Lars

> the include-files.
> 
> Fixes issues like (in linux-next currently):
> 
> drivers/input/touchscreen/ads7846.c:959: error: 'GPIOF_DIR_IN' undeclared (first use in this function)
> 
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> Cc: David Brownell <dbrownell@users.sourceforge.net>
> Cc: Eric Miao <eric.y.miao@gmail.com>
> Cc: Dmitry Torokhov <dtor@mail.ru>
> ---
> 
> Based on 2.6.38-rc4. Compile tested on x86.
> 
>  include/asm-generic/gpio.h   |   31 +++++--------------------------
>  include/linux/gpio.h         |    2 +-
>  include/linux/gpio_generic.h |   26 ++++++++++++++++++++++++++
>  3 files changed, 32 insertions(+), 27 deletions(-)
>  create mode 100644 include/linux/gpio_generic.h
> 
> diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
> index ff5c660..ebc73bc 100644
> --- a/include/asm-generic/gpio.h
> +++ b/include/asm-generic/gpio.h
> @@ -4,6 +4,7 @@
>  #include <linux/kernel.h>
>  #include <linux/types.h>
>  #include <linux/errno.h>
> +#include <linux/gpio_generic.h>
>  
>  #ifdef CONFIG_GPIOLIB
>  
> @@ -158,6 +159,10 @@ extern int gpio_set_debounce(unsigned gpio, unsigned debounce);
>  extern int gpio_get_value_cansleep(unsigned gpio);
>  extern void gpio_set_value_cansleep(unsigned gpio, int value);
>  
> +extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
> +extern int gpio_request_array(struct gpio *array, size_t num);
> +extern void gpio_free_array(struct gpio *array, size_t num);
> +
>  
>  /* A platform's <asm/gpio.h> code may want to inline the I/O calls when
>   * the GPIO is constant and refers to some always-present controller,
> @@ -170,32 +175,6 @@ extern int __gpio_cansleep(unsigned gpio);
>  
>  extern int __gpio_to_irq(unsigned gpio);
>  
> -#define GPIOF_DIR_OUT	(0 << 0)
> -#define GPIOF_DIR_IN	(1 << 0)
> -
> -#define GPIOF_INIT_LOW	(0 << 1)
> -#define GPIOF_INIT_HIGH	(1 << 1)
> -
> -#define GPIOF_IN		(GPIOF_DIR_IN)
> -#define GPIOF_OUT_INIT_LOW	(GPIOF_DIR_OUT | GPIOF_INIT_LOW)
> -#define GPIOF_OUT_INIT_HIGH	(GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
> -
> -/**
> - * struct gpio - a structure describing a GPIO with configuration
> - * @gpio:	the GPIO number
> - * @flags:	GPIO configuration as specified by GPIOF_*
> - * @label:	a literal description string of this GPIO
> - */
> -struct gpio {
> -	unsigned	gpio;
> -	unsigned long	flags;
> -	const char	*label;
> -};
> -
> -extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
> -extern int gpio_request_array(struct gpio *array, size_t num);
> -extern void gpio_free_array(struct gpio *array, size_t num);
This conflicts with the patch making "array" const.

> -
>  #ifdef CONFIG_GPIO_SYSFS
>  
>  /*
> diff --git a/include/linux/gpio.h b/include/linux/gpio.h
> index 32720ba..584ceb6 100644
> --- a/include/linux/gpio.h
> +++ b/include/linux/gpio.h
> @@ -11,9 +11,9 @@
>  #include <linux/kernel.h>
>  #include <linux/types.h>
>  #include <linux/errno.h>
> +#include <linux/gpio_generic.h>
>  
>  struct device;
> -struct gpio;
>  struct gpio_chip;
>  
>  /*
> diff --git a/include/linux/gpio_generic.h b/include/linux/gpio_generic.h
> new file mode 100644
> index 0000000..d662697
> --- /dev/null
> +++ b/include/linux/gpio_generic.h
> @@ -0,0 +1,26 @@
> +#ifndef __LINUX_GPIO_GENERIC_H
> +#define __LINUX_GPIO_GENERIC_H
> +
> +/**
> + * struct gpio - a structure describing a GPIO with configuration
> + * @gpio:	the GPIO number
> + * @flags:	GPIO configuration as specified by GPIOF_*
> + * @label:	a literal description string of this GPIO
> + */
> +struct gpio {
> +	unsigned	gpio;
> +	unsigned long	flags;
> +	const char	*label;
> +};
> +
> +#define GPIOF_DIR_OUT	(0 << 0)
> +#define GPIOF_DIR_IN	(1 << 0)
> +
> +#define GPIOF_INIT_LOW	(0 << 1)
> +#define GPIOF_INIT_HIGH	(1 << 1)
> +
> +#define GPIOF_IN		(GPIOF_DIR_IN)
> +#define GPIOF_OUT_INIT_LOW	(GPIOF_DIR_OUT | GPIOF_INIT_LOW)
> +#define GPIOF_OUT_INIT_HIGH	(GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
> +
> +#endif /* __LINUX_GPIO_GENERIC_H */


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

* Re: [PATCH] gpio: make newer functionality available outside of GPIOLIB
  2011-02-08 23:18 ` Lars-Peter Clausen
@ 2011-02-09 13:34   ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2011-02-09 13:34 UTC (permalink / raw
  To: Lars-Peter Clausen
  Cc: linux-kernel, David Brownell, Eric Miao, Dmitry Torokhov,
	Arnd Bergmann (maintainer:GENERIC INCLUDE/A...),
	Andrew Morton (commit_signer:4/8=50%),
	Mark Brown (commit_signer:1/8=12%),
	Anton Vorontsov (commit_signer:1/8=12%),
	Greg Kroah-Hartman (commit_signer:1/8=12%),
	open list:GENERIC INCLUDE/A...

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


> Given that these functions are pretty generic and build on top of the generic
> gpio interface I think they should be available if GENERIC_GPIO is selected and
> not only just through GPIOLIB. Otherwise all the archs not using gpiolib but
> providing the gpio api would have to be patched as well.

I agree that could be argumented for these calls. Will try something
later if nobody objects that approach.

Regards,

   Wolfram

-- 
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] 4+ messages in thread

end of thread, other threads:[~2011-02-09 13:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-08 22:44 [PATCH] gpio: make newer functionality available outside of GPIOLIB Wolfram Sang
2011-02-08 22:44 ` Wolfram Sang
2011-02-08 23:18 ` Lars-Peter Clausen
2011-02-09 13:34   ` Wolfram Sang

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.