aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-mxc
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2008-11-04 10:48:46 -0500
committerSascha Hauer <s.hauer@pengutronix.de>2008-12-16 08:46:14 -0500
commit7bd1822135175354e1662cc890a156f1d89dc211 (patch)
tree91c0278ee0cfb2728bee25ff9fd3ca171d225ab8 /arch/arm/plat-mxc
parentd1900d3a18b114eabc15f6369f64439c248d55f3 (diff)
[ARM] MX1/MX2: simplify mxc_gpio_setup_multiple_pins
mxc_gpio_setup_multiple_pins used to take several ALLOC_MODE flags. Most of them are unused, so simplify the function by removing the flags. Also, instead of using a confusing MXC_GPIO_ALLOC_MODE_RELEASE flag in a function having alloc in its name, add a mxc_gpio_release_multiple_pins function. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/plat-mxc')
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-mx1-mx2.h9
-rw-r--r--arch/arm/plat-mxc/iomux-mx1-mx2.c37
2 files changed, 21 insertions, 25 deletions
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx1-mx2.h b/arch/arm/plat-mxc/include/mach/iomux-mx1-mx2.h
index f49d798c5c3c..6c331c939c00 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-mx1-mx2.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx1-mx2.h
@@ -21,12 +21,6 @@
21 21
22#include <linux/io.h> 22#include <linux/io.h>
23 23
24#define MXC_GPIO_ALLOC_MODE_NORMAL 0
25#define MXC_GPIO_ALLOC_MODE_NO_ALLOC 1
26#define MXC_GPIO_ALLOC_MODE_TRY_ALLOC 2
27#define MXC_GPIO_ALLOC_MODE_ALLOC_ONLY 4
28#define MXC_GPIO_ALLOC_MODE_RELEASE 8
29
30/* 24/*
31 * GPIO Module and I/O Multiplexer 25 * GPIO Module and I/O Multiplexer
32 * x = 0..3 for reg_A, reg_B, reg_C, reg_D 26 * x = 0..3 for reg_A, reg_B, reg_C, reg_D
@@ -103,7 +97,8 @@
103 97
104extern void mxc_gpio_mode(int gpio_mode); 98extern void mxc_gpio_mode(int gpio_mode);
105extern int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count, 99extern int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count,
106 int alloc_mode, const char *label); 100 const char *label);
101extern void mxc_gpio_release_multiple_pins(const int *pin_list, int count);
107 102
108/*-------------------------------------------------------------------------*/ 103/*-------------------------------------------------------------------------*/
109 104
diff --git a/arch/arm/plat-mxc/iomux-mx1-mx2.c b/arch/arm/plat-mxc/iomux-mx1-mx2.c
index d97387aa9a42..df6f18395686 100644
--- a/arch/arm/plat-mxc/iomux-mx1-mx2.c
+++ b/arch/arm/plat-mxc/iomux-mx1-mx2.c
@@ -110,12 +110,13 @@ void mxc_gpio_mode(int gpio_mode)
110EXPORT_SYMBOL(mxc_gpio_mode); 110EXPORT_SYMBOL(mxc_gpio_mode);
111 111
112int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count, 112int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count,
113 int alloc_mode, const char *label) 113 const char *label)
114{ 114{
115 const int *p = pin_list; 115 const int *p = pin_list;
116 int i; 116 int i;
117 unsigned gpio; 117 unsigned gpio;
118 unsigned mode; 118 unsigned mode;
119 int ret = -EINVAL;
119 120
120 for (i = 0; i < count; i++) { 121 for (i = 0; i < count; i++) {
121 gpio = *p & (GPIO_PIN_MASK | GPIO_PORT_MASK); 122 gpio = *p & (GPIO_PIN_MASK | GPIO_PORT_MASK);
@@ -124,33 +125,33 @@ int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count,
124 if (gpio >= (GPIO_PORT_MAX + 1) * 32) 125 if (gpio >= (GPIO_PORT_MAX + 1) * 32)
125 goto setup_error; 126 goto setup_error;
126 127
127 if (alloc_mode & MXC_GPIO_ALLOC_MODE_RELEASE) 128 ret = gpio_request(gpio, label);
128 gpio_free(gpio); 129 if (ret)
129 else if (!(alloc_mode & MXC_GPIO_ALLOC_MODE_NO_ALLOC)) 130 goto setup_error;
130 if (gpio_request(gpio, label)
131 && !(alloc_mode & MXC_GPIO_ALLOC_MODE_TRY_ALLOC))
132 goto setup_error;
133 131
134 if (!(alloc_mode & (MXC_GPIO_ALLOC_MODE_ALLOC_ONLY | 132 mxc_gpio_mode(gpio | mode);
135 MXC_GPIO_ALLOC_MODE_RELEASE)))
136 mxc_gpio_mode(gpio | mode);
137 133
138 p++; 134 p++;
139 } 135 }
140 return 0; 136 return 0;
141 137
142setup_error: 138setup_error:
143 if (alloc_mode & (MXC_GPIO_ALLOC_MODE_NO_ALLOC | 139 mxc_gpio_release_multiple_pins(pin_list, i);
144 MXC_GPIO_ALLOC_MODE_TRY_ALLOC)) 140 return ret;
145 return -EINVAL; 141}
142EXPORT_SYMBOL(mxc_gpio_setup_multiple_pins);
146 143
147 while (p != pin_list) { 144void mxc_gpio_release_multiple_pins(const int *pin_list, int count)
148 p--; 145{
149 gpio = *p & (GPIO_PIN_MASK | GPIO_PORT_MASK); 146 const int *p = pin_list;
147 int i;
148
149 for (i = 0; i < count; i++) {
150 unsigned gpio = *p & (GPIO_PIN_MASK | GPIO_PORT_MASK);
150 gpio_free(gpio); 151 gpio_free(gpio);
152 p++;
151 } 153 }
152 154
153 return -EINVAL;
154} 155}
155EXPORT_SYMBOL(mxc_gpio_setup_multiple_pins); 156EXPORT_SYMBOL(mxc_gpio_release_multiple_pins);
156 157