aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-s3c24xx/gpiolib.c
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-10-31 12:14:27 -0400
committerBen Dooks <ben-linux@fluff.org>2008-12-15 16:46:24 -0500
commitf2edc7565a14aa82231c847abf33d02314cac9f9 (patch)
tree1baab69b530dc6da39ccb55a02017a14479e9bea /arch/arm/plat-s3c24xx/gpiolib.c
parentcec444b79073e7d6ef35ced5ef63c3fd83d9b9a7 (diff)
[ARM] S3C24XX: Reduce code lineage of gpiolib.c
All the s3c24xx gpiolib chips share the same get/set calls and all but one bank shares the same calls for .direction_input and .direction_output methods. Change the initialisation process to use an new call to register the chips that fills in any blank calls with the default values to avoid having to fill them in the structure initialisers. Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/plat-s3c24xx/gpiolib.c')
-rw-r--r--arch/arm/plat-s3c24xx/gpiolib.c49
1 files changed, 22 insertions, 27 deletions
diff --git a/arch/arm/plat-s3c24xx/gpiolib.c b/arch/arm/plat-s3c24xx/gpiolib.c
index 3caec6bad3eb..b07c2d0dd533 100644
--- a/arch/arm/plat-s3c24xx/gpiolib.c
+++ b/arch/arm/plat-s3c24xx/gpiolib.c
@@ -161,8 +161,6 @@ static struct s3c24xx_gpio_chip gpios[] = {
161 .ngpio = 24, 161 .ngpio = 24,
162 .direction_input = s3c24xx_gpiolib_banka_input, 162 .direction_input = s3c24xx_gpiolib_banka_input,
163 .direction_output = s3c24xx_gpiolib_banka_output, 163 .direction_output = s3c24xx_gpiolib_banka_output,
164 .set = s3c24xx_gpiolib_set,
165 .get = s3c24xx_gpiolib_get,
166 }, 164 },
167 }, 165 },
168 [1] = { 166 [1] = {
@@ -172,10 +170,6 @@ static struct s3c24xx_gpio_chip gpios[] = {
172 .owner = THIS_MODULE, 170 .owner = THIS_MODULE,
173 .label = "GPIOB", 171 .label = "GPIOB",
174 .ngpio = 16, 172 .ngpio = 16,
175 .direction_input = s3c24xx_gpiolib_input,
176 .direction_output = s3c24xx_gpiolib_output,
177 .set = s3c24xx_gpiolib_set,
178 .get = s3c24xx_gpiolib_get,
179 }, 173 },
180 }, 174 },
181 [2] = { 175 [2] = {
@@ -185,10 +179,6 @@ static struct s3c24xx_gpio_chip gpios[] = {
185 .owner = THIS_MODULE, 179 .owner = THIS_MODULE,
186 .label = "GPIOC", 180 .label = "GPIOC",
187 .ngpio = 16, 181 .ngpio = 16,
188 .direction_input = s3c24xx_gpiolib_input,
189 .direction_output = s3c24xx_gpiolib_output,
190 .set = s3c24xx_gpiolib_set,
191 .get = s3c24xx_gpiolib_get,
192 }, 182 },
193 }, 183 },
194 [3] = { 184 [3] = {
@@ -198,10 +188,6 @@ static struct s3c24xx_gpio_chip gpios[] = {
198 .owner = THIS_MODULE, 188 .owner = THIS_MODULE,
199 .label = "GPIOD", 189 .label = "GPIOD",
200 .ngpio = 16, 190 .ngpio = 16,
201 .direction_input = s3c24xx_gpiolib_input,
202 .direction_output = s3c24xx_gpiolib_output,
203 .set = s3c24xx_gpiolib_set,
204 .get = s3c24xx_gpiolib_get,
205 }, 191 },
206 }, 192 },
207 [4] = { 193 [4] = {
@@ -211,10 +197,6 @@ static struct s3c24xx_gpio_chip gpios[] = {
211 .label = "GPIOE", 197 .label = "GPIOE",
212 .owner = THIS_MODULE, 198 .owner = THIS_MODULE,
213 .ngpio = 16, 199 .ngpio = 16,
214 .direction_input = s3c24xx_gpiolib_input,
215 .direction_output = s3c24xx_gpiolib_output,
216 .set = s3c24xx_gpiolib_set,
217 .get = s3c24xx_gpiolib_get,
218 }, 200 },
219 }, 201 },
220 [5] = { 202 [5] = {
@@ -224,10 +206,6 @@ static struct s3c24xx_gpio_chip gpios[] = {
224 .owner = THIS_MODULE, 206 .owner = THIS_MODULE,
225 .label = "GPIOF", 207 .label = "GPIOF",
226 .ngpio = 8, 208 .ngpio = 8,
227 .direction_input = s3c24xx_gpiolib_input,
228 .direction_output = s3c24xx_gpiolib_output,
229 .set = s3c24xx_gpiolib_set,
230 .get = s3c24xx_gpiolib_get,
231 }, 209 },
232 }, 210 },
233 [6] = { 211 [6] = {
@@ -237,21 +215,38 @@ static struct s3c24xx_gpio_chip gpios[] = {
237 .owner = THIS_MODULE, 215 .owner = THIS_MODULE,
238 .label = "GPIOG", 216 .label = "GPIOG",
239 .ngpio = 10, 217 .ngpio = 10,
240 .direction_input = s3c24xx_gpiolib_input,
241 .direction_output = s3c24xx_gpiolib_output,
242 .set = s3c24xx_gpiolib_set,
243 .get = s3c24xx_gpiolib_get,
244 }, 218 },
245 }, 219 },
246}; 220};
247 221
222static __init void s3c24xx_gpiolib_add(struct s3c24xx_gpio_chip *chip)
223{
224 struct gpio_chip *gc = &chip->chip;
225
226 BUG_ON(!chip->base);
227 BUG_ON(!gc->label);
228 BUG_ON(!gc->ngpio);
229
230 if (!gc->direction_input)
231 gc->direction_input = s3c24xx_gpiolib_input;
232 if (!gc->direction_output)
233 gc->direction_output = s3c24xx_gpiolib_output;
234 if (!gc->set)
235 gc->set = s3c24xx_gpiolib_set;
236 if (!gc->get)
237 gc->get = s3c24xx_gpiolib_get;
238
239 /* gpiochip_add() prints own failure message on error. */
240 gpiochip_add(gc);
241}
242
248static __init int s3c24xx_gpiolib_init(void) 243static __init int s3c24xx_gpiolib_init(void)
249{ 244{
250 struct s3c24xx_gpio_chip *chip = gpios; 245 struct s3c24xx_gpio_chip *chip = gpios;
251 int gpn; 246 int gpn;
252 247
253 for (gpn = 0; gpn < ARRAY_SIZE(gpios); gpn++, chip++) 248 for (gpn = 0; gpn < ARRAY_SIZE(gpios); gpn++, chip++)
254 gpiochip_add(&chip->chip); 249 s3c24xx_gpiolib_add(chip);
255 250
256 return 0; 251 return 0;
257} 252}