From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Brownell <dbrownell@users.sourceforge.net>,
Greg Kroah-Hartman <greg@kroah.com>,
Kumar Gala <galak@kernel.crashing.org>,
Timur Tabi <timur@freescale.com>, Li Yang <leoli@freescale.com>,
Laurent Pinchart <laurentp@cse-semaphore.com>,
linuxppc-dev@ozlabs.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] gpiolib: make gpio_to_chip() public
Date: Thu, 18 Sep 2008 19:17:29 +0400 [thread overview]
Message-ID: <20080918151729.GA31187@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <20080918151659.GA20140@oksana.dev.rtsoft.ru>
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 <avorontsov@ru.mvista.com>
---
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);
--
1.5.6.3
next prev parent reply other threads:[~2008-09-18 15:17 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-18 15:16 [PATCH 0/3] Patches to support QE USB Host Controller Anton Vorontsov
2008-09-18 15:17 ` Anton Vorontsov [this message]
2008-09-18 15:17 ` [PATCH 2/3] powerpc/qe: new call to revert a gpio to a dedicated function Anton Vorontsov
2008-09-18 15:17 ` [PATCH 3/3] USB: driver for Freescale QUICC Engine USB Host Controller Anton Vorontsov
2008-09-19 23:23 ` Andrew Morton
2008-09-23 18:31 ` Anton Vorontsov
2008-09-23 18:32 ` [PATCH 1/2] USB: Protect hcd.h from multiple inclusions Anton Vorontsov
2008-09-23 18:32 ` [PATCH 2/2] USB: driver for Freescale QUICC Engine USB Host Controller Anton Vorontsov
2008-09-23 21:32 ` [PATCH 3/3] " Sergei Shtylyov
2008-09-23 21:35 ` Sergei Shtylyov
2008-09-23 22:57 ` Anton Vorontsov
2008-09-24 10:24 ` Sergei Shtylyov
2008-09-24 10:48 ` Sergei Shtylyov
2008-09-24 18:59 ` David Brownell
2008-09-24 19:17 ` Sergei Shtylyov
-- strict thread matches above, loose matches on Subject: below --
2008-08-08 16:17 [PATCH 0/3] Patches to support QE " Anton Vorontsov
2008-08-08 16:18 ` [PATCH 1/3] gpiolib: make gpio_to_chip() public Anton Vorontsov
2008-08-14 14:04 ` Laurent Pinchart
2008-08-14 14:14 ` Anton Vorontsov
2008-08-14 14:45 ` Laurent Pinchart
2008-08-14 15:10 ` Anton Vorontsov
2008-08-18 13:58 ` Laurent Pinchart
2008-08-18 14:33 ` Anton Vorontsov
2008-08-18 14:44 ` Laurent Pinchart
2008-08-18 15:33 ` Anton Vorontsov
2008-08-19 9:26 ` Laurent Pinchart
2008-08-19 14:50 ` Anton Vorontsov
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=20080918151729.GA31187@oksana.dev.rtsoft.ru \
--to=avorontsov@ru.mvista.com \
--cc=akpm@linux-foundation.org \
--cc=dbrownell@users.sourceforge.net \
--cc=galak@kernel.crashing.org \
--cc=greg@kroah.com \
--cc=laurentp@cse-semaphore.com \
--cc=leoli@freescale.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=timur@freescale.com \
/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;
as well as URLs for NNTP newsgroup(s).