From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: linux-kernel@vger.kernel.org
Cc: Yuanhan Liu <yuanhan.liu@linux.intel.com>,
Grant Likely <grant.likely@secretlab.ca>,
Linus Walleij <linus.walleij@linaro.org>,
Fengguang Wu <fengguang.wu@intel.com>
Subject: [PATCH 1/2] gpio: move those interface depends on GPIOLIB into proper section
Date: Wed, 31 Oct 2012 15:00:54 +0800 [thread overview]
Message-ID: <1351666855-23854-1-git-send-email-yuanhan.liu@linux.intel.com> (raw)
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
next reply other threads:[~2012-10-31 7:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-31 7:00 Yuanhan Liu [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1351666855-23854-1-git-send-email-yuanhan.liu@linux.intel.com \
--to=yuanhan.liu@linux.intel.com \
--cc=fengguang.wu@intel.com \
--cc=grant.likely@secretlab.ca \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome