From patchwork Wed Sep 24 00:03:32 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 1208 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 35D7BDDF9F for ; Wed, 24 Sep 2008 10:03:49 +1000 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from buildserver.ru.mvista.com (unknown [85.21.88.6]) by ozlabs.org (Postfix) with ESMTP id 2AF2CDDEE3 for ; Wed, 24 Sep 2008 10:03:34 +1000 (EST) Received: from localhost (unknown [10.150.0.9]) by buildserver.ru.mvista.com (Postfix) with ESMTP id A50A7881A; Wed, 24 Sep 2008 05:03:32 +0500 (SAMST) Date: Wed, 24 Sep 2008 04:03:32 +0400 From: Anton Vorontsov To: Andrew Morton Subject: [PATCH 1/4] gpiolib: make gpio_to_chip() public Message-ID: <20080924000332.GA29733@oksana.dev.rtsoft.ru> References: <20080924000255.GA28054@oksana.dev.rtsoft.ru> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20080924000255.GA28054@oksana.dev.rtsoft.ru> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: David Brownell , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org, Li Yang , Timur Tabi X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org We'll need this function to write platform-specific hooks to deal with pin's dedicated functions. Quite obviously this will work only for the platforms with 1-to-1 GPIO to PIN mapping. This is stopgap solution till we think out and implement a proper api (pinlib?). p.s. This patch actually exports gpio_desc and places gpio_to_chip into the asm-generic/gpio.h as `static inline'. This is needed to not cause function calls for this trivial translation. Also, the patch does not export FLAG_*s... the names are too generic, and nobody is using them outside of gpiolib.c. Signed-off-by: Anton Vorontsov --- drivers/gpio/gpiolib.c | 16 ++-------------- include/asm-generic/gpio.h | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 8d29405..fb36a90 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -40,9 +40,6 @@ */ static DEFINE_SPINLOCK(gpio_lock); -struct gpio_desc { - struct gpio_chip *chip; - unsigned long flags; /* flag symbols are bit numbers */ #define FLAG_REQUESTED 0 #define FLAG_IS_OUT 1 @@ -50,11 +47,8 @@ struct gpio_desc { #define FLAG_EXPORT 3 /* protected by sysfs_lock */ #define FLAG_SYSFS 4 /* exported via /sys/class/gpio/control */ -#ifdef CONFIG_DEBUG_FS - const char *label; -#endif -}; -static struct gpio_desc gpio_desc[ARCH_NR_GPIOS]; +struct gpio_desc gpio_desc[ARCH_NR_GPIOS]; +EXPORT_SYMBOL_GPL(gpio_desc); static inline void desc_set_label(struct gpio_desc *d, const char *label) { @@ -80,12 +74,6 @@ static void gpio_ensure_requested(struct gpio_desc *desc) } } -/* caller holds gpio_lock *OR* gpio is marked as requested */ -static inline struct gpio_chip *gpio_to_chip(unsigned gpio) -{ - return gpio_desc[gpio].chip; -} - /* dynamic allocation of GPIOs, e.g. on a hotplugged device */ static int gpiochip_find_base(int ngpio) { diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index 0f99ad3..88962f0 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -81,6 +81,23 @@ struct gpio_chip { unsigned exported:1; }; +struct gpio_desc { + struct gpio_chip *chip; + unsigned long flags; + +#ifdef CONFIG_DEBUG_FS + const char *label; +#endif +}; + +extern struct gpio_desc gpio_desc[ARCH_NR_GPIOS]; + +/* caller holds gpio_lock *OR* gpio is marked as requested */ +static inline struct gpio_chip *gpio_to_chip(unsigned gpio) +{ + return gpio_desc[gpio].chip; +} + extern const char *gpiochip_is_requested(struct gpio_chip *chip, unsigned offset); extern int __must_check gpiochip_reserve(int start, int ngpio);