aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/cris/arch-v10/drivers/gpio.c3
-rw-r--r--arch/cris/arch-v10/drivers/sync_serial.c34
-rw-r--r--arch/cris/arch-v32/drivers/mach-a3/gpio.c4
-rw-r--r--arch/cris/arch-v32/drivers/mach-fs/gpio.c5
-rw-r--r--arch/cris/arch-v32/drivers/sync_serial.c33
5 files changed, 52 insertions, 27 deletions
diff --git a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c
index 68a998bd1069..86048e697eb5 100644
--- a/arch/cris/arch-v10/drivers/gpio.c
+++ b/arch/cris/arch-v10/drivers/gpio.c
@@ -16,6 +16,7 @@
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/fs.h> 18#include <linux/fs.h>
19#include <linux/smp_lock.h>
19#include <linux/string.h> 20#include <linux/string.h>
20#include <linux/poll.h> 21#include <linux/poll.h>
21#include <linux/init.h> 22#include <linux/init.h>
@@ -323,6 +324,7 @@ gpio_open(struct inode *inode, struct file *filp)
323 if (!priv) 324 if (!priv)
324 return -ENOMEM; 325 return -ENOMEM;
325 326
327 lock_kernel();
326 priv->minor = p; 328 priv->minor = p;
327 329
328 /* initialize the io/alarm struct */ 330 /* initialize the io/alarm struct */
@@ -357,6 +359,7 @@ gpio_open(struct inode *inode, struct file *filp)
357 alarmlist = priv; 359 alarmlist = priv;
358 spin_unlock_irqrestore(&gpio_lock, flags); 360 spin_unlock_irqrestore(&gpio_lock, flags);
359 361
362 unlock_kernel();
360 return 0; 363 return 0;
361} 364}
362 365
diff --git a/arch/cris/arch-v10/drivers/sync_serial.c b/arch/cris/arch-v10/drivers/sync_serial.c
index 069546e342c5..91fea623c7c9 100644
--- a/arch/cris/arch-v10/drivers/sync_serial.c
+++ b/arch/cris/arch-v10/drivers/sync_serial.c
@@ -21,6 +21,7 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/poll.h> 22#include <linux/poll.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/smp_lock.h>
24#include <linux/timer.h> 25#include <linux/timer.h>
25#include <asm/irq.h> 26#include <asm/irq.h>
26#include <asm/dma.h> 27#include <asm/dma.h>
@@ -443,18 +444,21 @@ static int sync_serial_open(struct inode *inode, struct file *file)
443 int dev = MINOR(inode->i_rdev); 444 int dev = MINOR(inode->i_rdev);
444 struct sync_port *port; 445 struct sync_port *port;
445 int mode; 446 int mode;
447 int err = -EBUSY;
446 448
449 lock_kernel();
447 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); 450 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev));
448 451
449 if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) { 452 if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) {
450 DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev)); 453 DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev));
451 return -ENODEV; 454 err = -ENODEV;
455 goto out;
452 } 456 }
453 port = &ports[dev]; 457 port = &ports[dev];
454 /* Allow open this device twice (assuming one reader and one writer) */ 458 /* Allow open this device twice (assuming one reader and one writer) */
455 if (port->busy == 2) { 459 if (port->busy == 2) {
456 DEBUG(printk(KERN_DEBUG "Device is busy.. \n")); 460 DEBUG(printk(KERN_DEBUG "Device is busy.. \n"));
457 return -EBUSY; 461 goto out;
458 } 462 }
459 if (port->init_irqs) { 463 if (port->init_irqs) {
460 if (port->use_dma) { 464 if (port->use_dma) {
@@ -465,14 +469,14 @@ static int sync_serial_open(struct inode *inode, struct file *file)
465 &ports[0])) { 469 &ports[0])) {
466 printk(KERN_CRIT "Can't alloc " 470 printk(KERN_CRIT "Can't alloc "
467 "sync serial port 1 IRQ"); 471 "sync serial port 1 IRQ");
468 return -EBUSY; 472 goto out;
469 } else if (request_irq(25, rx_interrupt, 0, 473 } else if (request_irq(25, rx_interrupt, 0,
470 "synchronous serial 1 dma rx", 474 "synchronous serial 1 dma rx",
471 &ports[0])) { 475 &ports[0])) {
472 free_irq(24, &port[0]); 476 free_irq(24, &port[0]);
473 printk(KERN_CRIT "Can't alloc " 477 printk(KERN_CRIT "Can't alloc "
474 "sync serial port 1 IRQ"); 478 "sync serial port 1 IRQ");
475 return -EBUSY; 479 goto out;
476 } else if (cris_request_dma(8, 480 } else if (cris_request_dma(8,
477 "synchronous serial 1 dma tr", 481 "synchronous serial 1 dma tr",
478 DMA_VERBOSE_ON_ERROR, 482 DMA_VERBOSE_ON_ERROR,
@@ -482,7 +486,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
482 printk(KERN_CRIT "Can't alloc " 486 printk(KERN_CRIT "Can't alloc "
483 "sync serial port 1 " 487 "sync serial port 1 "
484 "TX DMA channel"); 488 "TX DMA channel");
485 return -EBUSY; 489 goto out;
486 } else if (cris_request_dma(9, 490 } else if (cris_request_dma(9,
487 "synchronous serial 1 dma rec", 491 "synchronous serial 1 dma rec",
488 DMA_VERBOSE_ON_ERROR, 492 DMA_VERBOSE_ON_ERROR,
@@ -493,7 +497,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
493 printk(KERN_CRIT "Can't alloc " 497 printk(KERN_CRIT "Can't alloc "
494 "sync serial port 1 " 498 "sync serial port 1 "
495 "RX DMA channel"); 499 "RX DMA channel");
496 return -EBUSY; 500 goto out;
497 } 501 }
498#endif 502#endif
499 RESET_DMA(8); WAIT_DMA(8); 503 RESET_DMA(8); WAIT_DMA(8);
@@ -520,14 +524,14 @@ static int sync_serial_open(struct inode *inode, struct file *file)
520 &ports[1])) { 524 &ports[1])) {
521 printk(KERN_CRIT "Can't alloc " 525 printk(KERN_CRIT "Can't alloc "
522 "sync serial port 3 IRQ"); 526 "sync serial port 3 IRQ");
523 return -EBUSY; 527 goto out;
524 } else if (request_irq(21, rx_interrupt, 0, 528 } else if (request_irq(21, rx_interrupt, 0,
525 "synchronous serial 3 dma rx", 529 "synchronous serial 3 dma rx",
526 &ports[1])) { 530 &ports[1])) {
527 free_irq(20, &ports[1]); 531 free_irq(20, &ports[1]);
528 printk(KERN_CRIT "Can't alloc " 532 printk(KERN_CRIT "Can't alloc "
529 "sync serial port 3 IRQ"); 533 "sync serial port 3 IRQ");
530 return -EBUSY; 534 goto out;
531 } else if (cris_request_dma(4, 535 } else if (cris_request_dma(4,
532 "synchronous serial 3 dma tr", 536 "synchronous serial 3 dma tr",
533 DMA_VERBOSE_ON_ERROR, 537 DMA_VERBOSE_ON_ERROR,
@@ -537,7 +541,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
537 printk(KERN_CRIT "Can't alloc " 541 printk(KERN_CRIT "Can't alloc "
538 "sync serial port 3 " 542 "sync serial port 3 "
539 "TX DMA channel"); 543 "TX DMA channel");
540 return -EBUSY; 544 goto out;
541 } else if (cris_request_dma(5, 545 } else if (cris_request_dma(5,
542 "synchronous serial 3 dma rec", 546 "synchronous serial 3 dma rec",
543 DMA_VERBOSE_ON_ERROR, 547 DMA_VERBOSE_ON_ERROR,
@@ -548,7 +552,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
548 printk(KERN_CRIT "Can't alloc " 552 printk(KERN_CRIT "Can't alloc "
549 "sync serial port 3 " 553 "sync serial port 3 "
550 "RX DMA channel"); 554 "RX DMA channel");
551 return -EBUSY; 555 goto out;
552 } 556 }
553#endif 557#endif
554 RESET_DMA(4); WAIT_DMA(4); 558 RESET_DMA(4); WAIT_DMA(4);
@@ -581,7 +585,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
581 &ports[0])) { 585 &ports[0])) {
582 printk(KERN_CRIT "Can't alloc " 586 printk(KERN_CRIT "Can't alloc "
583 "sync serial manual irq"); 587 "sync serial manual irq");
584 return -EBUSY; 588 goto out;
585 } 589 }
586 } else if (port == &ports[1]) { 590 } else if (port == &ports[1]) {
587 if (request_irq(8, 591 if (request_irq(8,
@@ -591,7 +595,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
591 &ports[1])) { 595 &ports[1])) {
592 printk(KERN_CRIT "Can't alloc " 596 printk(KERN_CRIT "Can't alloc "
593 "sync serial manual irq"); 597 "sync serial manual irq");
594 return -EBUSY; 598 goto out;
595 } 599 }
596 } 600 }
597 port->init_irqs = 0; 601 port->init_irqs = 0;
@@ -620,7 +624,11 @@ static int sync_serial_open(struct inode *inode, struct file *file)
620 *R_IRQ_MASK1_SET = 1 << port->data_avail_bit; 624 *R_IRQ_MASK1_SET = 1 << port->data_avail_bit;
621 DEBUG(printk(KERN_DEBUG "sser%d rec started\n", dev)); 625 DEBUG(printk(KERN_DEBUG "sser%d rec started\n", dev));
622 } 626 }
623 return 0; 627 ret = 0;
628
629out:
630 unlock_kernel();
631 return ret;
624} 632}
625 633
626static int sync_serial_release(struct inode *inode, struct file *file) 634static int sync_serial_release(struct inode *inode, struct file *file)
diff --git a/arch/cris/arch-v32/drivers/mach-a3/gpio.c b/arch/cris/arch-v32/drivers/mach-a3/gpio.c
index de107dad9f4f..ef98608e5067 100644
--- a/arch/cris/arch-v32/drivers/mach-a3/gpio.c
+++ b/arch/cris/arch-v32/drivers/mach-a3/gpio.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <linux/smp_lock.h>
26 27
27#include <asm/etraxgpio.h> 28#include <asm/etraxgpio.h>
28#include <hwregs/reg_map.h> 29#include <hwregs/reg_map.h>
@@ -390,6 +391,8 @@ static int gpio_open(struct inode *inode, struct file *filp)
390 391
391 if (!priv) 392 if (!priv)
392 return -ENOMEM; 393 return -ENOMEM;
394
395 lock_kernel();
393 memset(priv, 0, sizeof(*priv)); 396 memset(priv, 0, sizeof(*priv));
394 397
395 priv->minor = p; 398 priv->minor = p;
@@ -412,6 +415,7 @@ static int gpio_open(struct inode *inode, struct file *filp)
412 spin_unlock_irq(&gpio_lock); 415 spin_unlock_irq(&gpio_lock);
413 } 416 }
414 417
418 unlock_kernel();
415 return 0; 419 return 0;
416} 420}
417 421
diff --git a/arch/cris/arch-v32/drivers/mach-fs/gpio.c b/arch/cris/arch-v32/drivers/mach-fs/gpio.c
index 7863fd4efc2b..fe1fde893887 100644
--- a/arch/cris/arch-v32/drivers/mach-fs/gpio.c
+++ b/arch/cris/arch-v32/drivers/mach-fs/gpio.c
@@ -22,6 +22,7 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/spinlock.h> 24#include <linux/spinlock.h>
25#include <linux/smp_lock.h>
25 26
26#include <asm/etraxgpio.h> 27#include <asm/etraxgpio.h>
27#include <hwregs/reg_map.h> 28#include <hwregs/reg_map.h>
@@ -426,9 +427,10 @@ gpio_open(struct inode *inode, struct file *filp)
426 return -EINVAL; 427 return -EINVAL;
427 428
428 priv = kmalloc(sizeof(struct gpio_private), GFP_KERNEL); 429 priv = kmalloc(sizeof(struct gpio_private), GFP_KERNEL);
429
430 if (!priv) 430 if (!priv)
431 return -ENOMEM; 431 return -ENOMEM;
432
433 lock_kernel();
432 memset(priv, 0, sizeof(*priv)); 434 memset(priv, 0, sizeof(*priv));
433 435
434 priv->minor = p; 436 priv->minor = p;
@@ -449,6 +451,7 @@ gpio_open(struct inode *inode, struct file *filp)
449 alarmlist = priv; 451 alarmlist = priv;
450 spin_unlock_irq(&alarm_lock); 452 spin_unlock_irq(&alarm_lock);
451 453
454 unlock_kernel();
452 return 0; 455 return 0;
453} 456}
454 457
diff --git a/arch/cris/arch-v32/drivers/sync_serial.c b/arch/cris/arch-v32/drivers/sync_serial.c
index 47c377df6fb3..d2a0fbf5341f 100644
--- a/arch/cris/arch-v32/drivers/sync_serial.c
+++ b/arch/cris/arch-v32/drivers/sync_serial.c
@@ -14,6 +14,7 @@
14#include <linux/major.h> 14#include <linux/major.h>
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/smp_lock.h>
17#include <linux/interrupt.h> 18#include <linux/interrupt.h>
18#include <linux/poll.h> 19#include <linux/poll.h>
19#include <linux/init.h> 20#include <linux/init.h>
@@ -429,23 +430,26 @@ static inline int sync_data_avail_to_end(struct sync_port *port)
429static int sync_serial_open(struct inode *inode, struct file *file) 430static int sync_serial_open(struct inode *inode, struct file *file)
430{ 431{
431 int dev = iminor(inode); 432 int dev = iminor(inode);
433 int ret = -EBUSY;
432 sync_port *port; 434 sync_port *port;
433 reg_dma_rw_cfg cfg = {.en = regk_dma_yes}; 435 reg_dma_rw_cfg cfg = {.en = regk_dma_yes};
434 reg_dma_rw_intr_mask intr_mask = {.data = regk_dma_yes}; 436 reg_dma_rw_intr_mask intr_mask = {.data = regk_dma_yes};
435 437
438 lock_kernel();
436 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); 439 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev));
437 440
438 if (dev < 0 || dev >= NBR_PORTS || !ports[dev].enabled) 441 if (dev < 0 || dev >= NBR_PORTS || !ports[dev].enabled)
439 { 442 {
440 DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev)); 443 DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev));
441 return -ENODEV; 444 ret = -ENODEV;
445 goto out;
442 } 446 }
443 port = &ports[dev]; 447 port = &ports[dev];
444 /* Allow open this device twice (assuming one reader and one writer) */ 448 /* Allow open this device twice (assuming one reader and one writer) */
445 if (port->busy == 2) 449 if (port->busy == 2)
446 { 450 {
447 DEBUG(printk(KERN_DEBUG "Device is busy.. \n")); 451 DEBUG(printk(KERN_DEBUG "Device is busy.. \n"));
448 return -EBUSY; 452 goto out;
449 } 453 }
450 454
451 455
@@ -459,7 +463,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
459 "synchronous serial 0 dma tr", 463 "synchronous serial 0 dma tr",
460 &ports[0])) { 464 &ports[0])) {
461 printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ"); 465 printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ");
462 return -EBUSY; 466 goto out;
463 } else if (request_irq(DMA_IN_INTR_VECT, 467 } else if (request_irq(DMA_IN_INTR_VECT,
464 rx_interrupt, 468 rx_interrupt,
465 0, 469 0,
@@ -467,7 +471,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
467 &ports[0])) { 471 &ports[0])) {
468 free_irq(DMA_OUT_INTR_VECT, &port[0]); 472 free_irq(DMA_OUT_INTR_VECT, &port[0]);
469 printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ"); 473 printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ");
470 return -EBUSY; 474 goto out;
471 } else if (crisv32_request_dma(OUT_DMA_NBR, 475 } else if (crisv32_request_dma(OUT_DMA_NBR,
472 "synchronous serial 0 dma tr", 476 "synchronous serial 0 dma tr",
473 DMA_VERBOSE_ON_ERROR, 477 DMA_VERBOSE_ON_ERROR,
@@ -476,7 +480,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
476 free_irq(DMA_OUT_INTR_VECT, &port[0]); 480 free_irq(DMA_OUT_INTR_VECT, &port[0]);
477 free_irq(DMA_IN_INTR_VECT, &port[0]); 481 free_irq(DMA_IN_INTR_VECT, &port[0]);
478 printk(KERN_CRIT "Can't allocate sync serial port 0 TX DMA channel"); 482 printk(KERN_CRIT "Can't allocate sync serial port 0 TX DMA channel");
479 return -EBUSY; 483 goto out;
480 } else if (crisv32_request_dma(IN_DMA_NBR, 484 } else if (crisv32_request_dma(IN_DMA_NBR,
481 "synchronous serial 0 dma rec", 485 "synchronous serial 0 dma rec",
482 DMA_VERBOSE_ON_ERROR, 486 DMA_VERBOSE_ON_ERROR,
@@ -486,7 +490,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
486 free_irq(DMA_OUT_INTR_VECT, &port[0]); 490 free_irq(DMA_OUT_INTR_VECT, &port[0]);
487 free_irq(DMA_IN_INTR_VECT, &port[0]); 491 free_irq(DMA_IN_INTR_VECT, &port[0]);
488 printk(KERN_CRIT "Can't allocate sync serial port 1 RX DMA channel"); 492 printk(KERN_CRIT "Can't allocate sync serial port 1 RX DMA channel");
489 return -EBUSY; 493 goto out;
490 } 494 }
491#endif 495#endif
492 } 496 }
@@ -499,7 +503,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
499 "synchronous serial 1 dma tr", 503 "synchronous serial 1 dma tr",
500 &ports[1])) { 504 &ports[1])) {
501 printk(KERN_CRIT "Can't allocate sync serial port 1 IRQ"); 505 printk(KERN_CRIT "Can't allocate sync serial port 1 IRQ");
502 return -EBUSY; 506 goto out;
503 } else if (request_irq(DMA7_INTR_VECT, 507 } else if (request_irq(DMA7_INTR_VECT,
504 rx_interrupt, 508 rx_interrupt,
505 0, 509 0,
@@ -507,7 +511,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
507 &ports[1])) { 511 &ports[1])) {
508 free_irq(DMA6_INTR_VECT, &ports[1]); 512 free_irq(DMA6_INTR_VECT, &ports[1]);
509 printk(KERN_CRIT "Can't allocate sync serial port 3 IRQ"); 513 printk(KERN_CRIT "Can't allocate sync serial port 3 IRQ");
510 return -EBUSY; 514 goto out;
511 } else if (crisv32_request_dma( 515 } else if (crisv32_request_dma(
512 SYNC_SER1_TX_DMA_NBR, 516 SYNC_SER1_TX_DMA_NBR,
513 "synchronous serial 1 dma tr", 517 "synchronous serial 1 dma tr",
@@ -517,7 +521,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
517 free_irq(DMA6_INTR_VECT, &ports[1]); 521 free_irq(DMA6_INTR_VECT, &ports[1]);
518 free_irq(DMA7_INTR_VECT, &ports[1]); 522 free_irq(DMA7_INTR_VECT, &ports[1]);
519 printk(KERN_CRIT "Can't allocate sync serial port 3 TX DMA channel"); 523 printk(KERN_CRIT "Can't allocate sync serial port 3 TX DMA channel");
520 return -EBUSY; 524 goto out;
521 } else if (crisv32_request_dma( 525 } else if (crisv32_request_dma(
522 SYNC_SER1_RX_DMA_NBR, 526 SYNC_SER1_RX_DMA_NBR,
523 "synchronous serial 3 dma rec", 527 "synchronous serial 3 dma rec",
@@ -528,7 +532,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
528 free_irq(DMA6_INTR_VECT, &ports[1]); 532 free_irq(DMA6_INTR_VECT, &ports[1]);
529 free_irq(DMA7_INTR_VECT, &ports[1]); 533 free_irq(DMA7_INTR_VECT, &ports[1]);
530 printk(KERN_CRIT "Can't allocate sync serial port 3 RX DMA channel"); 534 printk(KERN_CRIT "Can't allocate sync serial port 3 RX DMA channel");
531 return -EBUSY; 535 goto out;
532 } 536 }
533#endif 537#endif
534 } 538 }
@@ -554,7 +558,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
554 "synchronous serial manual irq", 558 "synchronous serial manual irq",
555 &ports[0])) { 559 &ports[0])) {
556 printk("Can't allocate sync serial manual irq"); 560 printk("Can't allocate sync serial manual irq");
557 return -EBUSY; 561 goto out;
558 } 562 }
559 } 563 }
560#ifdef CONFIG_ETRAXFS 564#ifdef CONFIG_ETRAXFS
@@ -565,7 +569,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
565 "synchronous serial manual irq", 569 "synchronous serial manual irq",
566 &ports[1])) { 570 &ports[1])) {
567 printk(KERN_CRIT "Can't allocate sync serial manual irq"); 571 printk(KERN_CRIT "Can't allocate sync serial manual irq");
568 return -EBUSY; 572 goto out;
569 } 573 }
570 } 574 }
571#endif 575#endif
@@ -578,7 +582,10 @@ static int sync_serial_open(struct inode *inode, struct file *file)
578 } /* port->init_irqs */ 582 } /* port->init_irqs */
579 583
580 port->busy++; 584 port->busy++;
581 return 0; 585 ret = 0;
586out:
587 unlock_kernel();
588 return ret;
582} 589}
583 590
584static int sync_serial_release(struct inode *inode, struct file *file) 591static int sync_serial_release(struct inode *inode, struct file *file)