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

* [PATCH 2/2] gpio: do not call __gpio_xxx under !CONFIG_GPIOLIB
  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 ` Yuanhan Liu
  2012-11-04 17:47   ` Linus Walleij
  2012-10-31  7:12 ` [PATCH 1/2] gpio: move those interface depends on GPIOLIB into proper section Fengguang Wu
  1 sibling, 1 reply; 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

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 <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 |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index a73272d..704bf5d 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -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 */
-- 
1.7.7.6


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

* Re: [PATCH 1/2] gpio: move those interface depends on GPIOLIB into proper section
  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-10-31  7:12 ` Fengguang Wu
  2012-10-31  7:19   ` Yuanhan Liu
  1 sibling, 1 reply; 6+ messages in thread
From: Fengguang Wu @ 2012-10-31  7:12 UTC (permalink / raw)
  To: Yuanhan Liu; +Cc: linux-kernel, Grant Likely, Linus Walleij

On Wed, Oct 31, 2012 at 03:00:54PM +0800, Yuanhan Liu wrote:
> 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.

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

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

* Re: [PATCH 1/2] gpio: move those interface depends on GPIOLIB into proper section
  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
  0 siblings, 0 replies; 6+ messages in thread
From: Yuanhan Liu @ 2012-10-31  7:19 UTC (permalink / raw)
  To: Fengguang Wu; +Cc: linux-kernel, Grant Likely, Linus Walleij

On Wed, Oct 31, 2012 at 03:12:36PM +0800, Fengguang Wu wrote:
> On Wed, Oct 31, 2012 at 03:00:54PM +0800, Yuanhan Liu wrote:
> > 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.
> 
> 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!

> 
> 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

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

* Re: [PATCH 2/2] gpio: do not call __gpio_xxx under !CONFIG_GPIOLIB
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2012-11-04 17:47 UTC (permalink / raw)
  To: Yuanhan Liu; +Cc: linux-kernel, Grant Likely, Fengguang Wu

On Wed, Oct 31, 2012 at 8:00 AM, Yuanhan Liu
<yuanhan.liu@linux.intel.com> wrote:

> 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...

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

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

> -       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

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

* Re: [PATCH 2/2] gpio: do not call __gpio_xxx under !CONFIG_GPIOLIB
  2012-11-04 17:47   ` Linus Walleij
@ 2012-11-06  5:27     ` Yuanhan Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Yuanhan Liu @ 2012-11-06  5:27 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-kernel, Grant Likely, Fengguang Wu

On Sun, Nov 04, 2012 at 06:47:12PM +0100, Linus Walleij wrote:
> On Wed, Oct 31, 2012 at 8:00 AM, Yuanhan Liu
> <yuanhan.liu@linux.intel.com> wrote:
> 
> > 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...
> 
> >  static inline int gpio_get_value_cansleep(unsigned gpio)
> >  {
> > -       might_sleep();
Hi,

> 
> 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
> 
> > -       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

^ permalink raw reply	[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.