aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris
diff options
context:
space:
mode:
authorJesper Nilsson <jesper.nilsson@axis.com>2008-01-25 09:42:41 -0500
committerJesper Nilsson <jesper.nilsson@axis.com>2008-02-08 05:06:34 -0500
commit45a4127c10abff5edce4448c7bc951d0a112e67a (patch)
treece08e42dff601a450a5e0d22572d6376d0789438 /arch/cris
parent46aac058fe525a2a659e3363fa9bcd7d6bbf2d73 (diff)
CRIS v10: Update drivers/gpio.c, fix locking and general improvements.
- Change all spin_lock/local_irq_save to spin_lock_irqsave. - Change multiple returns in functions where we have a lock to goto out. - Correct number of arguments to gpio_poll_timer_interrupt, gpio_pa_interrupt. - Break out gpio_write logic to smaller functions to make it readable. - In setget_input and setget_output, avoid extra if-indent level. - Change name LED_* -> CRIS_LED_* to avoid name clash. - Don't use braces around single statement ifs. - Fix whitespace errors. - Remove useless CVS id and log.
Diffstat (limited to 'arch/cris')
-rw-r--r--arch/cris/arch-v10/drivers/gpio.c587
1 files changed, 228 insertions, 359 deletions
diff --git a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c
index 0d347a705835..26ae11be208d 100644
--- a/arch/cris/arch-v10/drivers/gpio.c
+++ b/arch/cris/arch-v10/drivers/gpio.c
@@ -1,138 +1,11 @@
1/* $Id: gpio.c,v 1.17 2005/06/19 17:06:46 starvik Exp $ 1/*
2 *
3 * Etrax general port I/O device 2 * Etrax general port I/O device
4 * 3 *
5 * Copyright (c) 1999, 2000, 2001, 2002 Axis Communications AB 4 * Copyright (c) 1999-2007 Axis Communications AB
6 * 5 *
7 * Authors: Bjorn Wesen (initial version) 6 * Authors: Bjorn Wesen (initial version)
8 * Ola Knutsson (LED handling) 7 * Ola Knutsson (LED handling)
9 * Johan Adolfsson (read/set directions, write, port G) 8 * Johan Adolfsson (read/set directions, write, port G)
10 *
11 * $Log: gpio.c,v $
12 * Revision 1.17 2005/06/19 17:06:46 starvik
13 * Merge of Linux 2.6.12.
14 *
15 * Revision 1.16 2005/03/07 13:02:29 starvik
16 * Protect driver global states with spinlock
17 *
18 * Revision 1.15 2005/01/05 06:08:55 starvik
19 * No need to do local_irq_disable after local_irq_save.
20 *
21 * Revision 1.14 2004/12/13 12:21:52 starvik
22 * Added I/O and DMA allocators from Linux 2.4
23 *
24 * Revision 1.12 2004/08/24 07:19:59 starvik
25 * Whitespace cleanup
26 *
27 * Revision 1.11 2004/05/14 07:58:03 starvik
28 * Merge of changes from 2.4
29 *
30 * Revision 1.9 2003/09/11 07:29:48 starvik
31 * Merge of Linux 2.6.0-test5
32 *
33 * Revision 1.8 2003/07/04 08:27:37 starvik
34 * Merge of Linux 2.5.74
35 *
36 * Revision 1.7 2003/01/10 07:44:07 starvik
37 * init_ioremap is now called by kernel before drivers are initialized
38 *
39 * Revision 1.6 2002/12/11 13:13:57 starvik
40 * Added arch/ to v10 specific includes
41 * Added fix from Linux 2.4 in serial.c (flush_to_flip_buffer)
42 *
43 * Revision 1.5 2002/11/20 11:56:11 starvik
44 * Merge of Linux 2.5.48
45 *
46 * Revision 1.4 2002/11/18 10:10:05 starvik
47 * Linux 2.5 port of latest gpio.c from Linux 2.4
48 *
49 * Revision 1.20 2002/10/16 21:16:24 johana
50 * Added support for PA high level interrupt.
51 * That gives 2ms response time with iodtest for high levels and 2-12 ms
52 * response time on low levels if the check is not made in
53 * process.c:cpu_idle() as well.
54 *
55 * Revision 1.19 2002/10/14 18:27:33 johana
56 * Implemented alarm handling so select() now works.
57 * Latency is around 6-9 ms with a etrax_gpio_wake_up_check() in
58 * cpu_idle().
59 * Otherwise I get 15-18 ms (same as doing the poll in userspace -
60 * but less overhead).
61 * TODO? Perhaps we should add the check in IMMEDIATE_BH (or whatever it
62 * is in 2.4) as well?
63 * TODO? Perhaps call request_irq()/free_irq() only when needed?
64 * Increased version to 2.5
65 *
66 * Revision 1.18 2002/10/11 15:02:00 johana
67 * Mask inverted 8 bit value in setget_input().
68 *
69 * Revision 1.17 2002/06/17 15:53:01 johana
70 * Added IO_READ_INBITS, IO_READ_OUTBITS, IO_SETGET_INPUT and IO_SETGET_OUTPUT
71 * that take a pointer as argument and thus can handle 32 bit ports (G)
72 * correctly.
73 * These should be used instead of IO_READBITS, IO_SETINPUT and IO_SETOUTPUT.
74 * (especially if Port G bit 31 is used)
75 *
76 * Revision 1.16 2002/06/17 09:59:51 johana
77 * Returning 32 bit values in the ioctl return value doesn't work if bit
78 * 31 is set (could happen for port G), so mask it of with 0x7FFFFFFF.
79 * A new set of ioctl's will be added.
80 *
81 * Revision 1.15 2002/05/06 13:19:13 johana
82 * IO_SETINPUT returns mask with bit set = inputs for PA and PB as well.
83 *
84 * Revision 1.14 2002/04/12 12:01:53 johana
85 * Use global r_port_g_data_shadow.
86 * Moved gpio_init_port_g() closer to gpio_init() and marked it __init.
87 *
88 * Revision 1.13 2002/04/10 12:03:55 johana
89 * Added support for port G /dev/gpiog (minor 3).
90 * Changed indentation on switch cases.
91 * Fixed other spaces to tabs.
92 *
93 * Revision 1.12 2001/11/12 19:42:15 pkj
94 * * Corrected return values from gpio_leds_ioctl().
95 * * Fixed compiler warnings.
96 *
97 * Revision 1.11 2001/10/30 14:39:12 johana
98 * Added D() around gpio_write printk.
99 *
100 * Revision 1.10 2001/10/25 10:24:42 johana
101 * Added IO_CFG_WRITE_MODE ioctl and write method that can do fast
102 * bittoggling in the kernel. (This speeds up programming an FPGA with 450kB
103 * from ~60 seconds to 4 seconds).
104 * Added save_flags/cli/restore_flags in ioctl.
105 *
106 * Revision 1.9 2001/05/04 14:16:07 matsfg
107 * Corrected spelling error
108 *
109 * Revision 1.8 2001/04/27 13:55:26 matsfg
110 * Moved initioremap.
111 * Turns off all LEDS on init.
112 * Added support for shutdown and powerbutton.
113 *
114 * Revision 1.7 2001/04/04 13:30:08 matsfg
115 * Added bitset and bitclear for leds. Calls init_ioremap to set up memmapping
116 *
117 * Revision 1.6 2001/03/26 16:03:06 bjornw
118 * Needs linux/config.h
119 *
120 * Revision 1.5 2001/03/26 14:22:03 bjornw
121 * Namechange of some config options
122 *
123 * Revision 1.4 2001/02/27 13:52:48 bjornw
124 * malloc.h -> slab.h
125 *
126 * Revision 1.3 2001/01/24 15:06:48 bjornw
127 * gpio_wq correct type
128 *
129 * Revision 1.2 2001/01/18 16:07:30 bjornw
130 * 2.4 port
131 *
132 * Revision 1.1 2001/01/18 15:55:16 bjornw
133 * Verbatim copy of etraxgpio.c from elinux 2.0 added
134 *
135 *
136 */ 9 */
137 10
138 11
@@ -165,7 +38,7 @@ static int dp_cnt;
165#else 38#else
166#define DP(x) 39#define DP(x)
167#endif 40#endif
168 41
169static char gpio_name[] = "etrax gpio"; 42static char gpio_name[] = "etrax gpio";
170 43
171#if 0 44#if 0
@@ -211,12 +84,12 @@ static DEFINE_SPINLOCK(gpio_lock); /* Protect directions etc */
211/* Port A and B use 8 bit access, but Port G is 32 bit */ 84/* Port A and B use 8 bit access, but Port G is 32 bit */
212#define NUM_PORTS (GPIO_MINOR_B+1) 85#define NUM_PORTS (GPIO_MINOR_B+1)
213 86
214static volatile unsigned char *ports[NUM_PORTS] = { 87static volatile unsigned char *ports[NUM_PORTS] = {
215 R_PORT_PA_DATA, 88 R_PORT_PA_DATA,
216 R_PORT_PB_DATA, 89 R_PORT_PB_DATA,
217}; 90};
218static volatile unsigned char *shads[NUM_PORTS] = { 91static volatile unsigned char *shads[NUM_PORTS] = {
219 &port_pa_data_shadow, 92 &port_pa_data_shadow,
220 &port_pb_data_shadow 93 &port_pb_data_shadow
221}; 94};
222 95
@@ -236,29 +109,29 @@ static volatile unsigned char *shads[NUM_PORTS] = {
236#endif 109#endif
237 110
238 111
239static unsigned char changeable_dir[NUM_PORTS] = { 112static unsigned char changeable_dir[NUM_PORTS] = {
240 CONFIG_ETRAX_PA_CHANGEABLE_DIR, 113 CONFIG_ETRAX_PA_CHANGEABLE_DIR,
241 CONFIG_ETRAX_PB_CHANGEABLE_DIR 114 CONFIG_ETRAX_PB_CHANGEABLE_DIR
242}; 115};
243static unsigned char changeable_bits[NUM_PORTS] = { 116static unsigned char changeable_bits[NUM_PORTS] = {
244 CONFIG_ETRAX_PA_CHANGEABLE_BITS, 117 CONFIG_ETRAX_PA_CHANGEABLE_BITS,
245 CONFIG_ETRAX_PB_CHANGEABLE_BITS 118 CONFIG_ETRAX_PB_CHANGEABLE_BITS
246}; 119};
247 120
248static volatile unsigned char *dir[NUM_PORTS] = { 121static volatile unsigned char *dir[NUM_PORTS] = {
249 R_PORT_PA_DIR, 122 R_PORT_PA_DIR,
250 R_PORT_PB_DIR 123 R_PORT_PB_DIR
251}; 124};
252 125
253static volatile unsigned char *dir_shadow[NUM_PORTS] = { 126static volatile unsigned char *dir_shadow[NUM_PORTS] = {
254 &port_pa_dir_shadow, 127 &port_pa_dir_shadow,
255 &port_pb_dir_shadow 128 &port_pb_dir_shadow
256}; 129};
257 130
258/* All bits in port g that can change dir. */ 131/* All bits in port g that can change dir. */
259static const unsigned long int changeable_dir_g_mask = 0x01FFFF01; 132static const unsigned long int changeable_dir_g_mask = 0x01FFFF01;
260 133
261/* Port G is 32 bit, handle it special, some bits are both inputs 134/* Port G is 32 bit, handle it special, some bits are both inputs
262 and outputs at the same time, only some of the bits can change direction 135 and outputs at the same time, only some of the bits can change direction
263 and some of them in groups of 8 bit. */ 136 and some of them in groups of 8 bit. */
264static unsigned long changeable_dir_g; 137static unsigned long changeable_dir_g;
@@ -269,18 +142,17 @@ static unsigned long dir_g_shadow; /* 1=output */
269#define USE_PORTS(priv) ((priv)->minor <= GPIO_MINOR_B) 142#define USE_PORTS(priv) ((priv)->minor <= GPIO_MINOR_B)
270 143
271 144
272 145static unsigned int gpio_poll(struct file *file, poll_table *wait)
273static unsigned int
274gpio_poll(struct file *file,
275 poll_table *wait)
276{ 146{
277 unsigned int mask = 0; 147 unsigned int mask = 0;
278 struct gpio_private *priv = (struct gpio_private *)file->private_data; 148 struct gpio_private *priv = (struct gpio_private *)file->private_data;
279 unsigned long data; 149 unsigned long data;
280 spin_lock(&gpio_lock); 150 unsigned long flags;
151
152 spin_lock_irqsave(&gpio_lock, flags);
153
281 poll_wait(file, &priv->alarm_wq, wait); 154 poll_wait(file, &priv->alarm_wq, wait);
282 if (priv->minor == GPIO_MINOR_A) { 155 if (priv->minor == GPIO_MINOR_A) {
283 unsigned long flags;
284 unsigned long tmp; 156 unsigned long tmp;
285 data = *R_PORT_PA_DATA; 157 data = *R_PORT_PA_DATA;
286 /* PA has support for high level interrupt - 158 /* PA has support for high level interrupt -
@@ -288,27 +160,25 @@ gpio_poll(struct file *file,
288 */ 160 */
289 tmp = ~data & priv->highalarm & 0xFF; 161 tmp = ~data & priv->highalarm & 0xFF;
290 tmp = (tmp << R_IRQ_MASK1_SET__pa0__BITNR); 162 tmp = (tmp << R_IRQ_MASK1_SET__pa0__BITNR);
291 local_irq_save(flags); 163
292 gpio_pa_irq_enabled_mask |= tmp; 164 gpio_pa_irq_enabled_mask |= tmp;
293 *R_IRQ_MASK1_SET = tmp; 165 *R_IRQ_MASK1_SET = tmp;
294 local_irq_restore(flags);
295
296 } else if (priv->minor == GPIO_MINOR_B) 166 } else if (priv->minor == GPIO_MINOR_B)
297 data = *R_PORT_PB_DATA; 167 data = *R_PORT_PB_DATA;
298 else if (priv->minor == GPIO_MINOR_G) 168 else if (priv->minor == GPIO_MINOR_G)
299 data = *R_PORT_G_DATA; 169 data = *R_PORT_G_DATA;
300 else { 170 else {
301 spin_unlock(&gpio_lock); 171 mask = 0;
302 return 0; 172 goto out;
303 } 173 }
304 174
305 if ((data & priv->highalarm) || 175 if ((data & priv->highalarm) ||
306 (~data & priv->lowalarm)) { 176 (~data & priv->lowalarm)) {
307 mask = POLLIN|POLLRDNORM; 177 mask = POLLIN|POLLRDNORM;
308 } 178 }
309 179
310 spin_unlock(&gpio_lock); 180out:
311 181 spin_unlock_irqrestore(&gpio_lock, flags);
312 DP(printk("gpio_poll ready: mask 0x%08X\n", mask)); 182 DP(printk("gpio_poll ready: mask 0x%08X\n", mask));
313 183
314 return mask; 184 return mask;
@@ -316,16 +186,19 @@ gpio_poll(struct file *file,
316 186
317int etrax_gpio_wake_up_check(void) 187int etrax_gpio_wake_up_check(void)
318{ 188{
319 struct gpio_private *priv = alarmlist; 189 struct gpio_private *priv;
320 unsigned long data = 0; 190 unsigned long data = 0;
321 int ret = 0; 191 int ret = 0;
322 spin_lock(&gpio_lock); 192 unsigned long flags;
193
194 spin_lock_irqsave(&gpio_lock, flags);
195 priv = alarmlist;
323 while (priv) { 196 while (priv) {
324 if (USE_PORTS(priv)) { 197 if (USE_PORTS(priv))
325 data = *priv->port; 198 data = *priv->port;
326 } else if (priv->minor == GPIO_MINOR_G) { 199 else if (priv->minor == GPIO_MINOR_G)
327 data = *R_PORT_G_DATA; 200 data = *R_PORT_G_DATA;
328 } 201
329 if ((data & priv->highalarm) || 202 if ((data & priv->highalarm) ||
330 (~data & priv->lowalarm)) { 203 (~data & priv->lowalarm)) {
331 DP(printk("etrax_gpio_wake_up_check %i\n",priv->minor)); 204 DP(printk("etrax_gpio_wake_up_check %i\n",priv->minor));
@@ -334,12 +207,12 @@ int etrax_gpio_wake_up_check(void)
334 } 207 }
335 priv = priv->next; 208 priv = priv->next;
336 } 209 }
337 spin_unlock(&gpio_lock); 210 spin_unlock_irqrestore(&gpio_lock, flags);
338 return ret; 211 return ret;
339} 212}
340 213
341static irqreturn_t 214static irqreturn_t
342gpio_poll_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) 215gpio_poll_timer_interrupt(int irq, void *dev_id)
343{ 216{
344 if (gpio_some_alarms) { 217 if (gpio_some_alarms) {
345 etrax_gpio_wake_up_check(); 218 etrax_gpio_wake_up_check();
@@ -349,10 +222,13 @@ gpio_poll_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
349} 222}
350 223
351static irqreturn_t 224static irqreturn_t
352gpio_pa_interrupt(int irq, void *dev_id, struct pt_regs *regs) 225gpio_pa_interrupt(int irq, void *dev_id)
353{ 226{
354 unsigned long tmp; 227 unsigned long tmp;
355 spin_lock(&gpio_lock); 228 unsigned long flags;
229
230 spin_lock_irqsave(&gpio_lock, flags);
231
356 /* Find what PA interrupts are active */ 232 /* Find what PA interrupts are active */
357 tmp = (*R_IRQ_READ1); 233 tmp = (*R_IRQ_READ1);
358 234
@@ -363,75 +239,70 @@ gpio_pa_interrupt(int irq, void *dev_id, struct pt_regs *regs)
363 *R_IRQ_MASK1_CLR = tmp; 239 *R_IRQ_MASK1_CLR = tmp;
364 gpio_pa_irq_enabled_mask &= ~tmp; 240 gpio_pa_irq_enabled_mask &= ~tmp;
365 241
366 spin_unlock(&gpio_lock); 242 spin_unlock_irqrestore(&gpio_lock, flags);
367 243
368 if (gpio_some_alarms) { 244 if (gpio_some_alarms)
369 return IRQ_RETVAL(etrax_gpio_wake_up_check()); 245 return IRQ_RETVAL(etrax_gpio_wake_up_check());
370 } 246
371 return IRQ_NONE; 247 return IRQ_NONE;
372} 248}
373 249
250static void gpio_write_bit(struct gpio_private *priv,
251 unsigned char data, int bit)
252{
253 *priv->port = *priv->shadow &= ~(priv->clk_mask);
254 if (data & 1 << bit)
255 *priv->port = *priv->shadow |= priv->data_mask;
256 else
257 *priv->port = *priv->shadow &= ~(priv->data_mask);
258
259 /* For FPGA: min 5.0ns (DCC) before CCLK high */
260 *priv->port = *priv->shadow |= priv->clk_mask;
261}
262
263static void gpio_write_byte(struct gpio_private *priv, unsigned char data)
264{
265 int i;
266
267 if (priv->write_msb)
268 for (i = 7; i >= 0; i--)
269 gpio_write_bit(priv, data, i);
270 else
271 for (i = 0; i <= 7; i++)
272 gpio_write_bit(priv, data, i);
273}
374 274
375static ssize_t gpio_write(struct file * file, const char * buf, size_t count, 275static ssize_t gpio_write(struct file * file, const char * buf, size_t count,
376 loff_t *off) 276 loff_t *off)
377{ 277{
378 struct gpio_private *priv = (struct gpio_private *)file->private_data; 278 struct gpio_private *priv = (struct gpio_private *)file->private_data;
379 unsigned char data, clk_mask, data_mask, write_msb;
380 unsigned long flags; 279 unsigned long flags;
280 ssize_t retval = count;
381 281
382 spin_lock(&gpio_lock); 282 if (priv->minor != GPIO_MINOR_A && priv->minor != GPIO_MINOR_B)
283 return -EFAULT;
284
285 if (!access_ok(VERIFY_READ, buf, count))
286 return -EFAULT;
287
288 spin_lock_irqsave(&gpio_lock, flags);
383 289
384 ssize_t retval = count;
385 if (priv->minor !=GPIO_MINOR_A && priv->minor != GPIO_MINOR_B) {
386 retval = -EFAULT;
387 goto out;
388 }
389
390 if (!access_ok(VERIFY_READ, buf, count)) {
391 retval = -EFAULT;
392 goto out;
393 }
394 clk_mask = priv->clk_mask;
395 data_mask = priv->data_mask;
396 /* It must have been configured using the IO_CFG_WRITE_MODE */ 290 /* It must have been configured using the IO_CFG_WRITE_MODE */
397 /* Perhaps a better error code? */ 291 /* Perhaps a better error code? */
398 if (clk_mask == 0 || data_mask == 0) { 292 if (priv->clk_mask == 0 || priv->data_mask == 0) {
399 retval = -EPERM; 293 retval = -EPERM;
400 goto out; 294 goto out;
401 } 295 }
402 write_msb = priv->write_msb; 296
403 D(printk("gpio_write: %lu to data 0x%02X clk 0x%02X msb: %i\n",count, data_mask, clk_mask, write_msb)); 297 D(printk(KERN_DEBUG "gpio_write: %02X to data 0x%02X "
404 while (count--) { 298 "clk 0x%02X msb: %i\n",
405 int i; 299 count, priv->data_mask, priv->clk_mask, priv->write_msb));
406 data = *buf++; 300
407 if (priv->write_msb) { 301 while (count--)
408 for (i = 7; i >= 0;i--) { 302 gpio_write_byte(priv, *buf++);
409 local_irq_save(flags); 303
410 *priv->port = *priv->shadow &= ~clk_mask;
411 if (data & 1<<i)
412 *priv->port = *priv->shadow |= data_mask;
413 else
414 *priv->port = *priv->shadow &= ~data_mask;
415 /* For FPGA: min 5.0ns (DCC) before CCLK high */
416 *priv->port = *priv->shadow |= clk_mask;
417 local_irq_restore(flags);
418 }
419 } else {
420 for (i = 0; i <= 7;i++) {
421 local_irq_save(flags);
422 *priv->port = *priv->shadow &= ~clk_mask;
423 if (data & 1<<i)
424 *priv->port = *priv->shadow |= data_mask;
425 else
426 *priv->port = *priv->shadow &= ~data_mask;
427 /* For FPGA: min 5.0ns (DCC) before CCLK high */
428 *priv->port = *priv->shadow |= clk_mask;
429 local_irq_restore(flags);
430 }
431 }
432 }
433out: 304out:
434 spin_unlock(&gpio_lock); 305 spin_unlock_irqrestore(&gpio_lock, flags);
435 return retval; 306 return retval;
436} 307}
437 308
@@ -442,22 +313,22 @@ gpio_open(struct inode *inode, struct file *filp)
442{ 313{
443 struct gpio_private *priv; 314 struct gpio_private *priv;
444 int p = iminor(inode); 315 int p = iminor(inode);
316 unsigned long flags;
445 317
446 if (p > GPIO_MINOR_LAST) 318 if (p > GPIO_MINOR_LAST)
447 return -EINVAL; 319 return -EINVAL;
448 320
449 priv = kmalloc(sizeof(struct gpio_private), 321 priv = kmalloc(sizeof(struct gpio_private), GFP_KERNEL);
450 GFP_KERNEL);
451 322
452 if (!priv) 323 if (!priv)
453 return -ENOMEM; 324 return -ENOMEM;
454 325
326 memset(priv, 0, sizeof(*priv));
327
455 priv->minor = p; 328 priv->minor = p;
456 329
457 /* initialize the io/alarm struct and link it into our alarmlist */ 330 /* initialize the io/alarm struct */
458 331
459 priv->next = alarmlist;
460 alarmlist = priv;
461 if (USE_PORTS(priv)) { /* A and B */ 332 if (USE_PORTS(priv)) { /* A and B */
462 priv->port = ports[p]; 333 priv->port = ports[p];
463 priv->shadow = shads[p]; 334 priv->shadow = shads[p];
@@ -482,6 +353,12 @@ gpio_open(struct inode *inode, struct file *filp)
482 353
483 filp->private_data = (void *)priv; 354 filp->private_data = (void *)priv;
484 355
356 /* link it into our alarmlist */
357 spin_lock_irqsave(&gpio_lock, flags);
358 priv->next = alarmlist;
359 alarmlist = priv;
360 spin_unlock_irqrestore(&gpio_lock, flags);
361
485 return 0; 362 return 0;
486} 363}
487 364
@@ -490,11 +367,12 @@ gpio_release(struct inode *inode, struct file *filp)
490{ 367{
491 struct gpio_private *p; 368 struct gpio_private *p;
492 struct gpio_private *todel; 369 struct gpio_private *todel;
370 unsigned long flags;
493 371
494 spin_lock(&gpio_lock); 372 spin_lock_irqsave(&gpio_lock, flags);
495 373
496 p = alarmlist; 374 p = alarmlist;
497 todel = (struct gpio_private *)filp->private_data; 375 todel = (struct gpio_private *)filp->private_data;
498 376
499 /* unlink from alarmlist and free the private structure */ 377 /* unlink from alarmlist and free the private structure */
500 378
@@ -512,123 +390,114 @@ gpio_release(struct inode *inode, struct file *filp)
512 while (p) { 390 while (p) {
513 if (p->highalarm | p->lowalarm) { 391 if (p->highalarm | p->lowalarm) {
514 gpio_some_alarms = 1; 392 gpio_some_alarms = 1;
515 spin_unlock(&gpio_lock); 393 goto out;
516 return 0;
517 } 394 }
518 p = p->next; 395 p = p->next;
519 } 396 }
520 gpio_some_alarms = 0; 397 gpio_some_alarms = 0;
521 spin_unlock(&gpio_lock); 398out:
399 spin_unlock_irqrestore(&gpio_lock, flags);
522 return 0; 400 return 0;
523} 401}
524 402
525/* Main device API. ioctl's to read/set/clear bits, as well as to 403/* Main device API. ioctl's to read/set/clear bits, as well as to
526 * set alarms to wait for using a subsequent select(). 404 * set alarms to wait for using a subsequent select().
527 */ 405 */
528
529unsigned long inline setget_input(struct gpio_private *priv, unsigned long arg) 406unsigned long inline setget_input(struct gpio_private *priv, unsigned long arg)
530{ 407{
531 /* Set direction 0=unchanged 1=input, 408 /* Set direction 0=unchanged 1=input,
532 * return mask with 1=input 409 * return mask with 1=input */
533 */
534 unsigned long flags;
535 if (USE_PORTS(priv)) { 410 if (USE_PORTS(priv)) {
536 local_irq_save(flags); 411 *priv->dir = *priv->dir_shadow &=
537 *priv->dir = *priv->dir_shadow &=
538 ~((unsigned char)arg & priv->changeable_dir); 412 ~((unsigned char)arg & priv->changeable_dir);
539 local_irq_restore(flags);
540 return ~(*priv->dir_shadow) & 0xFF; /* Only 8 bits */ 413 return ~(*priv->dir_shadow) & 0xFF; /* Only 8 bits */
541 } else if (priv->minor == GPIO_MINOR_G) { 414 }
542 /* We must fiddle with R_GEN_CONFIG to change dir */ 415
543 local_irq_save(flags); 416 if (priv->minor != GPIO_MINOR_G)
544 if (((arg & dir_g_in_bits) != arg) && 417 return 0;
545 (arg & changeable_dir_g)) { 418
546 arg &= changeable_dir_g; 419 /* We must fiddle with R_GEN_CONFIG to change dir */
547 /* Clear bits in genconfig to set to input */ 420 if (((arg & dir_g_in_bits) != arg) &&
548 if (arg & (1<<0)) { 421 (arg & changeable_dir_g)) {
549 genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG,g0dir); 422 arg &= changeable_dir_g;
550 dir_g_in_bits |= (1<<0); 423 /* Clear bits in genconfig to set to input */
551 dir_g_out_bits &= ~(1<<0); 424 if (arg & (1<<0)) {
552 } 425 genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, g0dir);
553 if ((arg & 0x0000FF00) == 0x0000FF00) { 426 dir_g_in_bits |= (1<<0);
554 genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG,g8_15dir); 427 dir_g_out_bits &= ~(1<<0);
555 dir_g_in_bits |= 0x0000FF00; 428 }
556 dir_g_out_bits &= ~0x0000FF00; 429 if ((arg & 0x0000FF00) == 0x0000FF00) {
557 } 430 genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, g8_15dir);
558 if ((arg & 0x00FF0000) == 0x00FF0000) { 431 dir_g_in_bits |= 0x0000FF00;
559 genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG,g16_23dir); 432 dir_g_out_bits &= ~0x0000FF00;
560 dir_g_in_bits |= 0x00FF0000; 433 }
561 dir_g_out_bits &= ~0x00FF0000; 434 if ((arg & 0x00FF0000) == 0x00FF0000) {
562 } 435 genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, g16_23dir);
563 if (arg & (1<<24)) { 436 dir_g_in_bits |= 0x00FF0000;
564 genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG,g24dir); 437 dir_g_out_bits &= ~0x00FF0000;
565 dir_g_in_bits |= (1<<24); 438 }
566 dir_g_out_bits &= ~(1<<24); 439 if (arg & (1<<24)) {
567 } 440 genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, g24dir);
568 D(printk(KERN_INFO "gpio: SETINPUT on port G set " 441 dir_g_in_bits |= (1<<24);
569 "genconfig to 0x%08lX " 442 dir_g_out_bits &= ~(1<<24);
570 "in_bits: 0x%08lX "
571 "out_bits: 0x%08lX\n",
572 (unsigned long)genconfig_shadow,
573 dir_g_in_bits, dir_g_out_bits));
574 *R_GEN_CONFIG = genconfig_shadow;
575 /* Must be a >120 ns delay before writing this again */
576
577 } 443 }
578 local_irq_restore(flags); 444 D(printk(KERN_DEBUG "gpio: SETINPUT on port G set "
579 return dir_g_in_bits; 445 "genconfig to 0x%08lX "
446 "in_bits: 0x%08lX "
447 "out_bits: 0x%08lX\n",
448 (unsigned long)genconfig_shadow,
449 dir_g_in_bits, dir_g_out_bits));
450 *R_GEN_CONFIG = genconfig_shadow;
451 /* Must be a >120 ns delay before writing this again */
452
580 } 453 }
581 return 0; 454 return dir_g_in_bits;
582} /* setget_input */ 455} /* setget_input */
583 456
584unsigned long inline setget_output(struct gpio_private *priv, unsigned long arg) 457unsigned long inline setget_output(struct gpio_private *priv, unsigned long arg)
585{ 458{
586 unsigned long flags;
587 if (USE_PORTS(priv)) { 459 if (USE_PORTS(priv)) {
588 local_irq_save(flags); 460 *priv->dir = *priv->dir_shadow |=
589 *priv->dir = *priv->dir_shadow |= 461 ((unsigned char)arg & priv->changeable_dir);
590 ((unsigned char)arg & priv->changeable_dir);
591 local_irq_restore(flags);
592 return *priv->dir_shadow; 462 return *priv->dir_shadow;
593 } else if (priv->minor == GPIO_MINOR_G) { 463 }
594 /* We must fiddle with R_GEN_CONFIG to change dir */ 464 if (priv->minor != GPIO_MINOR_G)
595 local_irq_save(flags); 465 return 0;
596 if (((arg & dir_g_out_bits) != arg) && 466
597 (arg & changeable_dir_g)) { 467 /* We must fiddle with R_GEN_CONFIG to change dir */
598 /* Set bits in genconfig to set to output */ 468 if (((arg & dir_g_out_bits) != arg) &&
599 if (arg & (1<<0)) { 469 (arg & changeable_dir_g)) {
600 genconfig_shadow |= IO_MASK(R_GEN_CONFIG,g0dir); 470 /* Set bits in genconfig to set to output */
601 dir_g_out_bits |= (1<<0); 471 if (arg & (1<<0)) {
602 dir_g_in_bits &= ~(1<<0); 472 genconfig_shadow |= IO_MASK(R_GEN_CONFIG, g0dir);
603 } 473 dir_g_out_bits |= (1<<0);
604 if ((arg & 0x0000FF00) == 0x0000FF00) { 474 dir_g_in_bits &= ~(1<<0);
605 genconfig_shadow |= IO_MASK(R_GEN_CONFIG,g8_15dir); 475 }
606 dir_g_out_bits |= 0x0000FF00; 476 if ((arg & 0x0000FF00) == 0x0000FF00) {
607 dir_g_in_bits &= ~0x0000FF00; 477 genconfig_shadow |= IO_MASK(R_GEN_CONFIG, g8_15dir);
608 } 478 dir_g_out_bits |= 0x0000FF00;
609 if ((arg & 0x00FF0000) == 0x00FF0000) { 479 dir_g_in_bits &= ~0x0000FF00;
610 genconfig_shadow |= IO_MASK(R_GEN_CONFIG,g16_23dir); 480 }
611 dir_g_out_bits |= 0x00FF0000; 481 if ((arg & 0x00FF0000) == 0x00FF0000) {
612 dir_g_in_bits &= ~0x00FF0000; 482 genconfig_shadow |= IO_MASK(R_GEN_CONFIG, g16_23dir);
613 } 483 dir_g_out_bits |= 0x00FF0000;
614 if (arg & (1<<24)) { 484 dir_g_in_bits &= ~0x00FF0000;
615 genconfig_shadow |= IO_MASK(R_GEN_CONFIG,g24dir);
616 dir_g_out_bits |= (1<<24);
617 dir_g_in_bits &= ~(1<<24);
618 }
619 D(printk(KERN_INFO "gpio: SETOUTPUT on port G set "
620 "genconfig to 0x%08lX "
621 "in_bits: 0x%08lX "
622 "out_bits: 0x%08lX\n",
623 (unsigned long)genconfig_shadow,
624 dir_g_in_bits, dir_g_out_bits));
625 *R_GEN_CONFIG = genconfig_shadow;
626 /* Must be a >120 ns delay before writing this again */
627 } 485 }
628 local_irq_restore(flags); 486 if (arg & (1<<24)) {
629 return dir_g_out_bits & 0x7FFFFFFF; 487 genconfig_shadow |= IO_MASK(R_GEN_CONFIG, g24dir);
488 dir_g_out_bits |= (1<<24);
489 dir_g_in_bits &= ~(1<<24);
490 }
491 D(printk(KERN_INFO "gpio: SETOUTPUT on port G set "
492 "genconfig to 0x%08lX "
493 "in_bits: 0x%08lX "
494 "out_bits: 0x%08lX\n",
495 (unsigned long)genconfig_shadow,
496 dir_g_in_bits, dir_g_out_bits));
497 *R_GEN_CONFIG = genconfig_shadow;
498 /* Must be a >120 ns delay before writing this again */
630 } 499 }
631 return 0; 500 return dir_g_out_bits & 0x7FFFFFFF;
632} /* setget_output */ 501} /* setget_output */
633 502
634static int 503static int
@@ -643,11 +512,10 @@ gpio_ioctl(struct inode *inode, struct file *file,
643 int ret = 0; 512 int ret = 0;
644 513
645 struct gpio_private *priv = (struct gpio_private *)file->private_data; 514 struct gpio_private *priv = (struct gpio_private *)file->private_data;
646 if (_IOC_TYPE(cmd) != ETRAXGPIO_IOCTYPE) { 515 if (_IOC_TYPE(cmd) != ETRAXGPIO_IOCTYPE)
647 return -EINVAL; 516 return -EINVAL;
648 }
649 517
650 spin_lock(&gpio_lock); 518 spin_lock_irqsave(&gpio_lock, flags);
651 519
652 switch (_IOC_NR(cmd)) { 520 switch (_IOC_NR(cmd)) {
653 case IO_READBITS: /* Use IO_READ_INBITS and IO_READ_OUTBITS instead */ 521 case IO_READBITS: /* Use IO_READ_INBITS and IO_READ_OUTBITS instead */
@@ -659,7 +527,6 @@ gpio_ioctl(struct inode *inode, struct file *file,
659 } 527 }
660 break; 528 break;
661 case IO_SETBITS: 529 case IO_SETBITS:
662 local_irq_save(flags);
663 // set changeable bits with a 1 in arg 530 // set changeable bits with a 1 in arg
664 if (USE_PORTS(priv)) { 531 if (USE_PORTS(priv)) {
665 *priv->port = *priv->shadow |= 532 *priv->port = *priv->shadow |=
@@ -667,10 +534,8 @@ gpio_ioctl(struct inode *inode, struct file *file,
667 } else if (priv->minor == GPIO_MINOR_G) { 534 } else if (priv->minor == GPIO_MINOR_G) {
668 *R_PORT_G_DATA = port_g_data_shadow |= (arg & dir_g_out_bits); 535 *R_PORT_G_DATA = port_g_data_shadow |= (arg & dir_g_out_bits);
669 } 536 }
670 local_irq_restore(flags);
671 break; 537 break;
672 case IO_CLRBITS: 538 case IO_CLRBITS:
673 local_irq_save(flags);
674 // clear changeable bits with a 1 in arg 539 // clear changeable bits with a 1 in arg
675 if (USE_PORTS(priv)) { 540 if (USE_PORTS(priv)) {
676 *priv->port = *priv->shadow &= 541 *priv->port = *priv->shadow &=
@@ -678,7 +543,6 @@ gpio_ioctl(struct inode *inode, struct file *file,
678 } else if (priv->minor == GPIO_MINOR_G) { 543 } else if (priv->minor == GPIO_MINOR_G) {
679 *R_PORT_G_DATA = port_g_data_shadow &= ~((unsigned long)arg & dir_g_out_bits); 544 *R_PORT_G_DATA = port_g_data_shadow &= ~((unsigned long)arg & dir_g_out_bits);
680 } 545 }
681 local_irq_restore(flags);
682 break; 546 break;
683 case IO_HIGHALARM: 547 case IO_HIGHALARM:
684 // set alarm when bits with 1 in arg go high 548 // set alarm when bits with 1 in arg go high
@@ -698,6 +562,8 @@ gpio_ioctl(struct inode *inode, struct file *file,
698 /* Must update gpio_some_alarms */ 562 /* Must update gpio_some_alarms */
699 struct gpio_private *p = alarmlist; 563 struct gpio_private *p = alarmlist;
700 int some_alarms; 564 int some_alarms;
565 spin_lock_irq(&gpio_lock);
566 p = alarmlist;
701 some_alarms = 0; 567 some_alarms = 0;
702 while (p) { 568 while (p) {
703 if (p->highalarm | p->lowalarm) { 569 if (p->highalarm | p->lowalarm) {
@@ -707,6 +573,7 @@ gpio_ioctl(struct inode *inode, struct file *file,
707 p = p->next; 573 p = p->next;
708 } 574 }
709 gpio_some_alarms = some_alarms; 575 gpio_some_alarms = some_alarms;
576 spin_unlock_irq(&gpio_lock);
710 } 577 }
711 break; 578 break;
712 case IO_READDIR: /* Use IO_SETGET_INPUT/OUTPUT instead! */ 579 case IO_READDIR: /* Use IO_SETGET_INPUT/OUTPUT instead! */
@@ -796,8 +663,7 @@ gpio_ioctl(struct inode *inode, struct file *file,
796 /* bits set in *arg is set to output, 663 /* bits set in *arg is set to output,
797 * *arg updated with current output pins. 664 * *arg updated with current output pins.
798 */ 665 */
799 if (copy_from_user(&val, (unsigned long*)arg, sizeof(val))) 666 if (copy_from_user(&val, (unsigned long *)arg, sizeof(val))) {
800 {
801 ret = -EFAULT; 667 ret = -EFAULT;
802 break; 668 break;
803 } 669 }
@@ -812,7 +678,7 @@ gpio_ioctl(struct inode *inode, struct file *file,
812 ret = -EINVAL; 678 ret = -EINVAL;
813 } /* switch */ 679 } /* switch */
814 680
815 spin_unlock(&gpio_lock); 681 spin_unlock_irqrestore(&gpio_lock, flags);
816 return ret; 682 return ret;
817} 683}
818 684
@@ -824,18 +690,18 @@ gpio_leds_ioctl(unsigned int cmd, unsigned long arg)
824 690
825 switch (_IOC_NR(cmd)) { 691 switch (_IOC_NR(cmd)) {
826 case IO_LEDACTIVE_SET: 692 case IO_LEDACTIVE_SET:
827 green = ((unsigned char) arg) & 1; 693 green = ((unsigned char)arg) & 1;
828 red = (((unsigned char) arg) >> 1) & 1; 694 red = (((unsigned char)arg) >> 1) & 1;
829 LED_ACTIVE_SET_G(green); 695 CRIS_LED_ACTIVE_SET_G(green);
830 LED_ACTIVE_SET_R(red); 696 CRIS_LED_ACTIVE_SET_R(red);
831 break; 697 break;
832 698
833 case IO_LED_SETBIT: 699 case IO_LED_SETBIT:
834 LED_BIT_SET(arg); 700 CRIS_LED_BIT_SET(arg);
835 break; 701 break;
836 702
837 case IO_LED_CLRBIT: 703 case IO_LED_CLRBIT:
838 LED_BIT_CLR(arg); 704 CRIS_LED_BIT_CLR(arg);
839 break; 705 break;
840 706
841 default: 707 default:
@@ -854,16 +720,18 @@ const struct file_operations gpio_fops = {
854 .release = gpio_release, 720 .release = gpio_release,
855}; 721};
856 722
857
858void ioif_watcher(const unsigned int gpio_in_available, 723void ioif_watcher(const unsigned int gpio_in_available,
859 const unsigned int gpio_out_available, 724 const unsigned int gpio_out_available,
860 const unsigned char pa_available, 725 const unsigned char pa_available,
861 const unsigned char pb_available) 726 const unsigned char pb_available)
862{ 727{
863 unsigned long int flags; 728 unsigned long int flags;
864 D(printk("gpio.c: ioif_watcher called\n")); 729
865 D(printk("gpio.c: G in: 0x%08x G out: 0x%08x PA: 0x%02x PB: 0x%02x\n", 730 D(printk(KERN_DEBUG "gpio.c: ioif_watcher called\n"));
866 gpio_in_available, gpio_out_available, pa_available, pb_available)); 731 D(printk(KERN_DEBUG "gpio.c: G in: 0x%08x G out: 0x%08x "
732 "PA: 0x%02x PB: 0x%02x\n",
733 gpio_in_available, gpio_out_available,
734 pa_available, pb_available));
867 735
868 spin_lock_irqsave(&gpio_lock, flags); 736 spin_lock_irqsave(&gpio_lock, flags);
869 737
@@ -872,7 +740,7 @@ void ioif_watcher(const unsigned int gpio_in_available,
872 740
873 /* Initialise the dir_g_shadow etc. depending on genconfig */ 741 /* Initialise the dir_g_shadow etc. depending on genconfig */
874 /* 0=input 1=output */ 742 /* 0=input 1=output */
875 if (genconfig_shadow & IO_STATE(R_GEN_CONFIG, g0dir, out)) 743 if (genconfig_shadow & IO_STATE(R_GEN_CONFIG, g0dir, out))
876 dir_g_shadow |= (1 << 0); 744 dir_g_shadow |= (1 << 0);
877 if (genconfig_shadow & IO_STATE(R_GEN_CONFIG, g8_15dir, out)) 745 if (genconfig_shadow & IO_STATE(R_GEN_CONFIG, g8_15dir, out))
878 dir_g_shadow |= 0x0000FF00; 746 dir_g_shadow |= 0x0000FF00;
@@ -884,7 +752,8 @@ void ioif_watcher(const unsigned int gpio_in_available,
884 changeable_dir_g = changeable_dir_g_mask; 752 changeable_dir_g = changeable_dir_g_mask;
885 changeable_dir_g &= dir_g_out_bits; 753 changeable_dir_g &= dir_g_out_bits;
886 changeable_dir_g &= dir_g_in_bits; 754 changeable_dir_g &= dir_g_in_bits;
887 /* Correct the bits that can change direction */ 755
756 /* Correct the bits that can change direction */
888 dir_g_out_bits &= ~changeable_dir_g; 757 dir_g_out_bits &= ~changeable_dir_g;
889 dir_g_out_bits |= dir_g_shadow; 758 dir_g_out_bits |= dir_g_shadow;
890 dir_g_in_bits &= ~changeable_dir_g; 759 dir_g_in_bits &= ~changeable_dir_g;
@@ -892,7 +761,8 @@ void ioif_watcher(const unsigned int gpio_in_available,
892 761
893 spin_unlock_irqrestore(&gpio_lock, flags); 762 spin_unlock_irqrestore(&gpio_lock, flags);
894 763
895 printk(KERN_INFO "GPIO port G: in_bits: 0x%08lX out_bits: 0x%08lX val: %08lX\n", 764 printk(KERN_INFO "GPIO port G: in_bits: 0x%08lX out_bits: 0x%08lX "
765 "val: %08lX\n",
896 dir_g_in_bits, dir_g_out_bits, (unsigned long)*R_PORT_G_DATA); 766 dir_g_in_bits, dir_g_out_bits, (unsigned long)*R_PORT_G_DATA);
897 printk(KERN_INFO "GPIO port G: dir: %08lX changeable: %08lX\n", 767 printk(KERN_INFO "GPIO port G: dir: %08lX changeable: %08lX\n",
898 dir_g_shadow, changeable_dir_g); 768 dir_g_shadow, changeable_dir_g);
@@ -907,9 +777,6 @@ gpio_init(void)
907#if defined (CONFIG_ETRAX_CSP0_LEDS) 777#if defined (CONFIG_ETRAX_CSP0_LEDS)
908 int i; 778 int i;
909#endif 779#endif
910 printk("gpio init\n");
911
912 /* do the formalities */
913 780
914 res = register_chrdev(GPIO_MAJOR, gpio_name, &gpio_fops); 781 res = register_chrdev(GPIO_MAJOR, gpio_name, &gpio_fops);
915 if (res < 0) { 782 if (res < 0) {
@@ -919,39 +786,41 @@ gpio_init(void)
919 786
920 /* Clear all leds */ 787 /* Clear all leds */
921#if defined (CONFIG_ETRAX_CSP0_LEDS) || defined (CONFIG_ETRAX_PA_LEDS) || defined (CONFIG_ETRAX_PB_LEDS) 788#if defined (CONFIG_ETRAX_CSP0_LEDS) || defined (CONFIG_ETRAX_PA_LEDS) || defined (CONFIG_ETRAX_PB_LEDS)
922 LED_NETWORK_SET(0); 789 CRIS_LED_NETWORK_SET(0);
923 LED_ACTIVE_SET(0); 790 CRIS_LED_ACTIVE_SET(0);
924 LED_DISK_READ(0); 791 CRIS_LED_DISK_READ(0);
925 LED_DISK_WRITE(0); 792 CRIS_LED_DISK_WRITE(0);
926 793
927#if defined (CONFIG_ETRAX_CSP0_LEDS) 794#if defined (CONFIG_ETRAX_CSP0_LEDS)
928 for (i = 0; i < 32; i++) { 795 for (i = 0; i < 32; i++)
929 LED_BIT_SET(i); 796 CRIS_LED_BIT_SET(i);
930 }
931#endif 797#endif
932 798
933#endif 799#endif
934 /* The I/O interface allocation watcher will be called when 800 /* The I/O interface allocation watcher will be called when
935 * registering it. */ 801 * registering it. */
936 if (cris_io_interface_register_watcher(ioif_watcher)){ 802 if (cris_io_interface_register_watcher(ioif_watcher)){
937 printk(KERN_WARNING "gpio_init: Failed to install IO if allocator watcher\n"); 803 printk(KERN_WARNING "gpio_init: Failed to install IO "
804 "if allocator watcher\n");
938 } 805 }
939 806
940 printk(KERN_INFO "ETRAX 100LX GPIO driver v2.5, (c) 2001, 2002, 2003, 2004 Axis Communications AB\n"); 807 printk(KERN_INFO "ETRAX 100LX GPIO driver v2.5, (c) 2001-2008 "
808 "Axis Communications AB\n");
941 /* We call etrax_gpio_wake_up_check() from timer interrupt and 809 /* We call etrax_gpio_wake_up_check() from timer interrupt and
942 * from cpu_idle() in kernel/process.c 810 * from cpu_idle() in kernel/process.c
943 * The check in cpu_idle() reduces latency from ~15 ms to ~6 ms 811 * The check in cpu_idle() reduces latency from ~15 ms to ~6 ms
944 * in some tests. 812 * in some tests.
945 */ 813 */
946 if (request_irq(TIMER0_IRQ_NBR, gpio_poll_timer_interrupt, 814 res = request_irq(TIMER0_IRQ_NBR, gpio_poll_timer_interrupt,
947 IRQF_SHARED | IRQF_DISABLED,"gpio poll", NULL)) { 815 IRQF_SHARED | IRQF_DISABLED, "gpio poll", gpio_name);
816 if (res) {
948 printk(KERN_CRIT "err: timer0 irq for gpio\n"); 817 printk(KERN_CRIT "err: timer0 irq for gpio\n");
818 return res;
949 } 819 }
950 if (request_irq(PA_IRQ_NBR, gpio_pa_interrupt, 820 res = request_irq(PA_IRQ_NBR, gpio_pa_interrupt,
951 IRQF_SHARED | IRQF_DISABLED,"gpio PA", NULL)) { 821 IRQF_SHARED | IRQF_DISABLED, "gpio PA", gpio_name);
822 if (res)
952 printk(KERN_CRIT "err: PA irq for gpio\n"); 823 printk(KERN_CRIT "err: PA irq for gpio\n");
953 }
954
955 824
956 return res; 825 return res;
957} 826}