From: Nicolas Ferre <nicolas.ferre@atmel.com>
To: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, bn@niasdigital.com,
ryan@bluewatersys.com, david-b@pacbell.net
Cc: avictor.za@gmail.com, Nicolas Ferre <nicolas.ferre@atmel.com>
Subject: [PATCH] pio: add arch specific gpio_is_valid() function
Date: Mon, 23 Aug 2010 17:01:09 +0200 [thread overview]
Message-ID: <1282575669-24501-1-git-send-email-nicolas.ferre@atmel.com> (raw)
In-Reply-To: <20091107122002.1ecf6483@hskinnemoen-d830>
Add a simple gpio_is_valid() function to replace
the standard one. It introduces the __HAVE_ARCH_GPIO_IS_VALID
macro to overload the generic code.
As an implementation example, it takes into account the AT91
pio numbering to check if a proper value is used.
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
Hi all,
I come back on this thread as I would like to implement the gpio_is_valid()
function for AT91. I have based this piece of code on comments from Ben and
Haavard and chose the __HAVE_ARCH_* macro definition as it seems wide spread
in kernel code.
Please make comments and if it is ok for you, eventually accept for merging...
arch/arm/mach-at91/include/mach/gpio.h | 9 +++++++++
include/asm-generic/gpio.h | 4 ++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-at91/include/mach/gpio.h b/arch/arm/mach-at91/include/mach/gpio.h
index 5cce2ed..103486d 100644
--- a/arch/arm/mach-at91/include/mach/gpio.h
+++ b/arch/arm/mach-at91/include/mach/gpio.h
@@ -188,6 +188,15 @@
#define AT91_PIN_PE31 (PIN_BASE + 0x80 + 31)
#ifndef __ASSEMBLY__
+static inline int gpio_is_valid(int number)
+{
+ if (number >= PIN_BASE)
+ return 1;
+ return 0;
+}
+#define __HAVE_ARCH_GPIO_IS_VALID 1
+
+
/* setup setup routines, called from board init or driver probe() */
extern int __init_or_module at91_set_GPIO_periph(unsigned pin, int use_pullup);
extern int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup);
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 4f3d75e..2840f35 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -22,11 +22,13 @@
#define ARCH_NR_GPIOS 256
#endif
+#ifndef __HAVE_ARCH_GPIO_IS_VALID
static inline int gpio_is_valid(int number)
{
/* only some non-negative numbers are valid */
return ((unsigned)number) < ARCH_NR_GPIOS;
}
+#endif
struct device;
struct seq_file;
@@ -185,11 +187,13 @@ extern void gpio_unexport(unsigned gpio);
#else /* !CONFIG_HAVE_GPIO_LIB */
+#ifndef __HAVE_ARCH_GPIO_IS_VALID
static inline int gpio_is_valid(int number)
{
/* only non-negative numbers are valid */
return number >= 0;
}
+#endif
/* platforms that don't directly support access to GPIOs through I2C, SPI,
* or other blocking infrastructure can use these wrappers.
--
1.5.6.5
next prev parent reply other threads:[~2010-08-23 13:56 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-17 16:29 [PATCH 0/2] mmc: atmel-mci: introduce MCI2 support on at91 Nicolas Ferre
2009-09-17 16:29 ` [PATCH 1/2] atmel-mci: change use of dma slave interface Nicolas Ferre
2009-09-29 19:29 ` Andrew Morton
2009-09-30 13:33 ` Nicolas Ferre
2009-09-30 13:55 ` Haavard Skinnemoen
2009-10-23 16:34 ` [PATCH 0/2 v2]mmc: atmel-mci: introduce MCI2 support on at91 Nicolas Ferre
2009-10-23 16:34 ` [PATCH 1/3 v2] atmel-mci: change use of dma slave interface Nicolas Ferre
2009-10-23 16:34 ` [PATCH 2/3 v2] mmc: atmel-mci: New MCI2 module support in atmel-mci driver Nicolas Ferre
2009-11-02 17:18 ` Nicolas Ferre
2009-11-18 13:33 ` Nicolas Ferre
2009-10-23 16:34 ` [PATCH 3/3 v2] at91/atmel-mci: inclusion of sd/mmc driver in at91sam9g45 chip and board Nicolas Ferre
2009-10-26 8:15 ` Yegor Yefremov
2009-11-02 17:14 ` Nicolas Ferre
2009-10-27 19:43 ` Andrew Victor
2009-10-28 0:35 ` Haavard Skinnemoen
2009-10-28 0:53 ` Thiago A. Corrêa
2009-10-28 1:31 ` Haavard Skinnemoen
2009-10-28 19:53 ` Andrew Victor
2009-10-28 20:50 ` Ben Nizette
2009-11-02 17:11 ` Nicolas Ferre
2009-11-02 22:10 ` Ben Nizette
2009-11-02 22:14 ` Ben Nizette
2009-11-03 2:30 ` Ryan Mallon
2009-11-03 2:55 ` Ben Nizette
2009-11-07 11:20 ` Haavard Skinnemoen
2010-08-23 15:01 ` Nicolas Ferre [this message]
2010-08-23 16:36 ` [PATCH] pio: add arch specific gpio_is_valid() function David Brownell
2010-08-24 8:19 ` Nicolas Ferre
2010-09-06 14:21 ` [PATCH v2] AT91: pio: add " Nicolas Ferre
2010-09-07 1:51 ` David Brownell
2010-09-03 16:41 ` [PATCH] pio: add arch specific " Jean-Christophe PLAGNIOL-VILLARD
2010-09-07 2:23 ` David Brownell
2010-09-07 2:44 ` Ryan Mallon
2010-09-07 3:54 ` Eric Miao
2010-09-07 4:07 ` Ryan Mallon
2010-09-07 4:19 ` Eric Miao
2010-09-07 4:26 ` Ryan Mallon
2010-09-07 18:10 ` David Brownell
2010-09-07 19:13 ` avictor.za
2010-09-07 19:30 ` Ryan Mallon
2010-09-07 21:22 ` Alan Cox
2010-09-07 23:44 ` David Brownell
2010-09-08 0:11 ` Alan Cox
2010-09-07 6:33 ` David Brownell
2010-09-07 8:41 ` Ben Nizette
2010-09-07 17:32 ` David Brownell
2009-09-17 16:29 ` [PATCH 2/2] mmc: atmel-mci: New MCI2 module support in atmel-mci driver Nicolas Ferre
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=1282575669-24501-1-git-send-email-nicolas.ferre@atmel.com \
--to=nicolas.ferre@atmel.com \
--cc=avictor.za@gmail.com \
--cc=bn@niasdigital.com \
--cc=david-b@pacbell.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ryan@bluewatersys.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
all inboxes | Powered by JetHome®