All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] gpio: move those interface depends on GPIOLIB into proper section
@ 2012-10-31  7:00 Yuanhan Liu
  2012-10-31  7:00 ` [PATCH 2/2] gpio: do not call __gpio_xxx under !CONFIG_GPIOLIB Yuanhan Liu
  2012-10-31  7:12 ` [PATCH 1/2] gpio: move those interface depends on GPIOLIB into proper section Fengguang Wu
  0 siblings, 2 replies; 6+ messages in thread
From: Yuanhan Liu @ 2012-10-31  7:00 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yuanhan Liu, Grant Likely, Linus Walleij, Fengguang Wu

There are 2 issues with current code:

1. redefinition of 'gpio_cansleep':
include/linux/gpio.h:60:19: error: redefinition of 'gpio_cansleep'
include/asm-generic/gpio.h:212:19: note: previous definition of 'gpio_cansleep' was here

The root cause is include/linux/gpio.h has a defintion of it. And if
CONFIG_GPIOLIB is not set, include/asm-generic/gpio.h has another
definition.

2. include/linux/gpio.h:62:2: error: implicit declaration of function '__gpio_cansleep'

Only happens when CONFIG_GPIOLIB is not set, too. Since it called
gpiolib functions without putting something like: #ifdef CONFIG_GPIOLIB

So, move those functions into proper section at
include/asm-generic/gpio.h would resolve 2 above issues.

Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 include/asm-generic/gpio.h |   39 +++++++++++++++++++++++++++++++++++++++
 include/linux/gpio.h       |   22 +---------------------
 2 files changed, 40 insertions(+), 21 deletions(-)

diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index a9432fc..a73272d 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -199,14 +199,53 @@ extern void gpio_unexport(unsigned gpio);
 
 #endif	/* CONFIG_GPIO_SYSFS */
 
+static inline int gpio_get_value(unsigned int gpio)
+{
+	return __gpio_get_value(gpio);
+}
+
+static inline void gpio_set_value(unsigned int gpio, int value)
+{
+	__gpio_set_value(gpio, value);
+}
+
+static inline int gpio_cansleep(unsigned int gpio)
+{
+	return __gpio_cansleep(gpio);
+}
+
+static inline int gpio_to_irq(unsigned int gpio)
+{
+	return __gpio_to_irq(gpio);
+}
+
+
 #else	/* !CONFIG_GPIOLIB */
 
+static inline int gpio_get_value(unsigned int gpio)
+{
+	WARN_ON(1);
+	return 0;
+}
+
+static inline void gpio_set_value(unsigned int gpio, int value)
+{
+	WARN_ON(1);
+}
+
 static inline bool gpio_is_valid(int number)
 {
 	/* only non-negative numbers are valid */
 	return number >= 0;
 }
 
+static inline int gpio_to_irq(unsigned int gpio)
+{
+	WARN_ON(1);
+	return -EINVAL;
+}
+
+
 /* platforms that don't directly support access to GPIOs through I2C, SPI,
  * or other blocking infrastructure can use these wrappers.
  */
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 2e31e8b..eb6e6ac 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -47,26 +47,6 @@ struct gpio {
 
 #include <asm-generic/gpio.h>
 
-static inline int gpio_get_value(unsigned int gpio)
-{
-	return __gpio_get_value(gpio);
-}
-
-static inline void gpio_set_value(unsigned int gpio, int value)
-{
-	__gpio_set_value(gpio, value);
-}
-
-static inline int gpio_cansleep(unsigned int gpio)
-{
-	return __gpio_cansleep(gpio);
-}
-
-static inline int gpio_to_irq(unsigned int gpio)
-{
-	return __gpio_to_irq(gpio);
-}
-
 static inline int irq_to_gpio(unsigned int irq)
 {
 	return -EINVAL;
@@ -74,7 +54,7 @@ static inline int irq_to_gpio(unsigned int irq)
 
 #endif
 
-#else
+#else /* !CONFIG_GENERIC_GPIO */
 
 #include <linux/kernel.h>
 #include <linux/types.h>
-- 
1.7.7.6


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

end of thread, other threads:[~2012-11-06  5:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-31  7:00 [PATCH 1/2] gpio: move those interface depends on GPIOLIB into proper section Yuanhan Liu
2012-10-31  7:00 ` [PATCH 2/2] gpio: do not call __gpio_xxx under !CONFIG_GPIOLIB Yuanhan Liu
2012-11-04 17:47   ` Linus Walleij
2012-11-06  5:27     ` Yuanhan Liu
2012-10-31  7:12 ` [PATCH 1/2] gpio: move those interface depends on GPIOLIB into proper section Fengguang Wu
2012-10-31  7:19   ` Yuanhan Liu

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.