aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-mxc/iomux-mx1-mx2.c
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/iomux-mx1-mx2.c
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/iomux-mx1-mx2.c')
-rw-r--r--arch/arm/plat-mxc/iomux-mx1-mx2.c37
1 files changed, 19 insertions, 18 deletions
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