lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 31 Oct 2012 15:00:54 +0800
From:	Yuanhan Liu <yuanhan.liu@...ux.intel.com>
To:	linux-kernel@...r.kernel.org
Cc:	Yuanhan Liu <yuanhan.liu@...ux.intel.com>,
	Grant Likely <grant.likely@...retlab.ca>,
	Linus Walleij <linus.walleij@...aro.org>,
	Fengguang Wu <fengguang.wu@...el.com>
Subject: [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 <grant.likely@...retlab.ca>
Cc: Linus Walleij <linus.walleij@...aro.org>
Cc: Fengguang Wu <fengguang.wu@...el.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@...ux.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ