From 96886c4361f1ae3f6c775d7c9295e2d557101d0f Mon Sep 17 00:00:00 2001 From: "Arnaud Patard (Rtp)" Date: Fri, 26 Nov 2010 15:20:52 +0100 Subject: iMX51: introduce IMX_GPIO_NR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, to define a GPIO number, we're using something like : #define EFIKAMX_PCBID0 (2*32 + 16) to define GPIO 3 16. This is not really readable and it's error prone imho (note the 3 vs 2). So, I'm introducing a new macro to define this in a better way. Now, the code sample become : #define EFIKAMX_PCBID0 IMX_GPIO_NR(3, 16) v2: - move to gpio.h - add parens & spaces - switch to IMX_GPIO_NR instead of MX51_GPIO_NR Signed-off-by: Arnaud Patard Cc: Amit Kucheria Cc: Sascha Hauer Cc: Eric BĂ©nard Signed-off-by: Sascha Hauer --- arch/arm/plat-mxc/include/mach/gpio.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'arch/arm/plat-mxc') diff --git a/arch/arm/plat-mxc/include/mach/gpio.h b/arch/arm/plat-mxc/include/mach/gpio.h index af33b74f569..0044e2f1bea 100644 --- a/arch/arm/plat-mxc/include/mach/gpio.h +++ b/arch/arm/plat-mxc/include/mach/gpio.h @@ -23,6 +23,11 @@ #include #include + +/* There's a off-by-one betweem the gpio bank number and the gpiochip */ +/* range e.g. GPIO_1_5 is gpio 5 under linux */ +#define IMX_GPIO_NR(bank, nr) (((bank) - 1) * 32 + (nr)) + /* use gpiolib dispatchers */ #define gpio_get_value __gpio_get_value #define gpio_set_value __gpio_set_value -- cgit v1.2.3-70-g09d2