Skip to contentSkip to conversation

gpio: move those interface depends on GPIOLIB into proper section

PATCH In review Yuanhan Liu 3 participants 6 messages Oct 31, 2012 – Nov 6, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 gpio: move those interface depends on GPIOLIB into proper section

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 <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Fengguang Wu <[email protected]>
---
 include/asm-generic/gpio.h |   39 +++++++++++++++++++++++++++++++++++++++
 include/linux/gpio.h       |   22 +---------------------
 2 files changed, 40 insertions(+), 21 deletions(-)
include/asm-generic/gpio.h +39 -0
index a9432fc..a73272d 100644
@@ -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.
  */
include/linux/gpio.h +1 -21
index 2e31e8b..eb6e6ac 100644
@@ -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>
Signature · 1 line
1.7.7.6
#1 lore raw

PATCH 2/2 gpio: do not call __gpio_xxx under !CONFIG_GPIOLIB

Those functions are availabe only when CONFIG_GPIOLIB is set. So, we should not call them under !CONFIG_GPIOLIB block.

This would fix following build errros:
include/asm-generic/gpio.h: In function 'gpio_get_value_cansleep':
include/asm-generic/gpio.h:220:2: error: implicit declaration of function '__gpio_get_value' include/asm-generic/gpio.h: In function 'gpio_set_value_cansleep':
nclude/asm-generic/gpio.h:226:2: error: implicit declaration of function '__gpio_set_value'

Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Fengguang Wu <[email protected]>
---
 include/asm-generic/gpio.h |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
include/asm-generic/gpio.h +3 -4
index a73272d..704bf5d 100644
@@ -257,14 +257,13 @@ static inline int gpio_cansleep(unsigned gpio)
 
 static inline int gpio_get_value_cansleep(unsigned gpio)
 {
-	might_sleep();
-	return __gpio_get_value(gpio);
+	WARN_ON(1);
+	return 0;
 }
 
 static inline void gpio_set_value_cansleep(unsigned gpio, int value)
 {
-	might_sleep();
-	__gpio_set_value(gpio, value);
+	WARN_ON(1);
 }
 
 #endif /* !CONFIG_GPIOLIB */
Signature · 1 line
1.7.7.6
#2 lore raw

Re: [PATCH 2/2] gpio: do not call __gpio_xxx under !CONFIG_GPIOLIB

Quoted 8 lines · Yuanhan Liu

Those functions are availabe only when CONFIG_GPIOLIB is set. So, we should not call them under !CONFIG_GPIOLIB block.

This would fix following build errros:
include/asm-generic/gpio.h: In function 'gpio_get_value_cansleep':
include/asm-generic/gpio.h:220:2: error: implicit declaration of function '__gpio_get_value' include/asm-generic/gpio.h: In function 'gpio_set_value_cansleep':
nclude/asm-generic/gpio.h:226:2: error: implicit declaration of function '__gpio_set_value'

OK...

Quoted 3 lines

static inline int gpio_get_value_cansleep(unsigned gpio) {
- might_sleep();

So why are you deleting this very useful might_sleep() runtime semantic check?

include/asm-generic/gpio.h static inline int gpio_cansleep(unsigned gpio) · line 267

Quoted 11 lines
include/asm-generic/gpio.h +3 -3
-       return __gpio_get_value(gpio);
+       WARN_ON(1);
+       return 0;
 }
 
 static inline void gpio_set_value_cansleep(unsigned gpio, int value)
 {
-       might_sleep();
-       __gpio_set_value(gpio, value);
+       WARN_ON(1);
 }

Yours,
Linus Walleij

#3 lore raw

Re: [PATCH 2/2] gpio: do not call __gpio_xxx under !CONFIG_GPIOLIB

Quoted 6 lines · Linus Walleij
Quoted 3 lines · Yuanhan Liu

Those functions are availabe only when CONFIG_GPIOLIB is set. So, we should not call them under !CONFIG_GPIOLIB block.

Quoted 11 lines
Quoted 5 lines

This would fix following build errros:
include/asm-generic/gpio.h: In function 'gpio_get_value_cansleep':
include/asm-generic/gpio.h:220:2: error: implicit declaration of function '__gpio_get_value' include/asm-generic/gpio.h: In function 'gpio_set_value_cansleep':
nclude/asm-generic/gpio.h:226:2: error: implicit declaration of function '__gpio_set_value'

OK...

Quoted 3 lines

static inline int gpio_get_value_cansleep(unsigned gpio) {
- might_sleep();

Hi,

Quoted 3 lines

So why are you deleting this very useful might_sleep() runtime semantic check?

Yes, I should keep it. I did it because I saw the definition of gpio_get_value at include/linux/gpio.h didn't call that function.

Will keep it in the next version together with the previous patch. And sorry that it may take some time, as I'm occupied by other things :(

Thanks.

	--yliu
Quoted 15 lines

include/asm-generic/gpio.h static inline int gpio_cansleep(unsigned gpio) · line 267

Quoted 12 lines
include/asm-generic/gpio.h +3 -3
-       return __gpio_get_value(gpio);
+       WARN_ON(1);
+       return 0;
 }
 
 static inline void gpio_set_value_cansleep(unsigned gpio, int value)
 {
-       might_sleep();
-       __gpio_set_value(gpio, value);
+       WARN_ON(1);
 }

Yours,
Linus Walleij

#4 lore raw
In reply to Yuanhan Liu
Quoted 10 lines · Yuanhan Liu

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.

Quoted 7 lines

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.

The patch introduces new build errors:

yuanhan:gpio-fixes [2/2] db1a5a0 blackfin-BF526-EZBRD_defconfig

[error]
arch/blackfin/include/asm/gpio.h:197:19: error: redefinition of 'gpio_get_value' arch/blackfin/include/asm/gpio.h:205:20: error: redefinition of 'gpio_set_value' arch/blackfin/include/asm/gpio.h:213:19: error: redefinition of 'gpio_cansleep' arch/blackfin/include/asm/gpio.h:218:19: error: redefinition of 'gpio_to_irq'

yuanhan:gpio-fixes [2/2] db1a5a0 blackfin-TCM-BF537_defconfig

[error]
include/asm-generic/gpio.h:225:19: error: redefinition of 'gpio_get_value' include/asm-generic/gpio.h:231:20: error: redefinition of 'gpio_set_value' include/asm-generic/gpio.h:242:19: error: redefinition of 'gpio_to_irq'

yuanhan:gpio-fixes [2/2] db1a5a0 sh-rsk7269_defconfig

[error]
arch/sh/include/asm/gpio.h:27:19: error: redefinition of 'gpio_get_value' arch/sh/include/asm/gpio.h:32:20: error: redefinition of 'gpio_set_value' arch/sh/include/asm/gpio.h:37:19: error: redefinition of 'gpio_cansleep' arch/sh/include/asm/gpio.h:42:19: error: redefinition of 'gpio_to_irq'

yuanhan:gpio-fixes [2/2] db1a5a0 avr32-atngw100_defconfig

[error]
arch/avr32/mach-at32ap/include/mach/gpio.h:18: error: redefinition of 'gpio_get_value' include/asm-generic/gpio.h:203: error: previous definition of 'gpio_get_value' was here arch/avr32/mach-at32ap/include/mach/gpio.h:23: error: redefinition of 'gpio_set_value' include/asm-generic/gpio.h:208: error: previous definition of 'gpio_set_value' was here arch/avr32/mach-at32ap/include/mach/gpio.h:28: error: redefinition of 'gpio_cansleep' include/asm-generic/gpio.h:213: error: previous definition of 'gpio_cansleep' was here arch/avr32/mach-at32ap/include/mach/gpio.h:34: error: redefinition of 'gpio_to_irq' include/asm-generic/gpio.h:218: error: previous definition of 'gpio_to_irq' was here

Thanks,
Fengguang

#5 lore raw
Quoted 13 lines · Fengguang Wu
Quoted 12 lines · Yuanhan Liu

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'

Quoted 7 lines
Quoted 5 lines

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.

The patch introduces new build errors:

Ooops. I checked the log at build server and posted it after finding no errors. Seems that the test hasn't been finished?

Sorry for the nosiy. Will send v2 then.

Thanks!

Quoted 38 lines

yuanhan:gpio-fixes [2/2] db1a5a0 blackfin-BF526-EZBRD_defconfig

[error]
arch/blackfin/include/asm/gpio.h:197:19: error: redefinition of 'gpio_get_value' arch/blackfin/include/asm/gpio.h:205:20: error: redefinition of 'gpio_set_value' arch/blackfin/include/asm/gpio.h:213:19: error: redefinition of 'gpio_cansleep' arch/blackfin/include/asm/gpio.h:218:19: error: redefinition of 'gpio_to_irq'

yuanhan:gpio-fixes [2/2] db1a5a0 blackfin-TCM-BF537_defconfig

[error]
include/asm-generic/gpio.h:225:19: error: redefinition of 'gpio_get_value' include/asm-generic/gpio.h:231:20: error: redefinition of 'gpio_set_value' include/asm-generic/gpio.h:242:19: error: redefinition of 'gpio_to_irq'

yuanhan:gpio-fixes [2/2] db1a5a0 sh-rsk7269_defconfig

[error]
arch/sh/include/asm/gpio.h:27:19: error: redefinition of 'gpio_get_value' arch/sh/include/asm/gpio.h:32:20: error: redefinition of 'gpio_set_value' arch/sh/include/asm/gpio.h:37:19: error: redefinition of 'gpio_cansleep' arch/sh/include/asm/gpio.h:42:19: error: redefinition of 'gpio_to_irq'

yuanhan:gpio-fixes [2/2] db1a5a0 avr32-atngw100_defconfig

[error]
arch/avr32/mach-at32ap/include/mach/gpio.h:18: error: redefinition of 'gpio_get_value' include/asm-generic/gpio.h:203: error: previous definition of 'gpio_get_value' was here arch/avr32/mach-at32ap/include/mach/gpio.h:23: error: redefinition of 'gpio_set_value' include/asm-generic/gpio.h:208: error: previous definition of 'gpio_set_value' was here arch/avr32/mach-at32ap/include/mach/gpio.h:28: error: redefinition of 'gpio_cansleep' include/asm-generic/gpio.h:213: error: previous definition of 'gpio_cansleep' was here arch/avr32/mach-at32ap/include/mach/gpio.h:34: error: redefinition of 'gpio_to_irq' include/asm-generic/gpio.h:218: error: previous definition of 'gpio_to_irq' was here

Thanks,
Fengguang