aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/media/dabusb.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@infradead.org>2006-01-11 09:55:29 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-20 17:49:55 -0500
commit4186ecf8ad16dd05759a09594de6a87e48759ba6 (patch)
tree3ee5292d9f4a36e3eb359b586289ec972bcbaf39 /drivers/usb/media/dabusb.c
parent35cce732d9d4d9af6b4ad4d26d8f8c0eddb573a2 (diff)
[PATCH] USB: convert a bunch of USB semaphores to mutexes
the patch below converts a bunch of semaphores-used-as-mutex in the USB code to mutexes Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/media/dabusb.c')
-rw-r--r--drivers/usb/media/dabusb.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c
index 6f560fe9a519..1774ab7a40d2 100644
--- a/drivers/usb/media/dabusb.c
+++ b/drivers/usb/media/dabusb.c
@@ -38,6 +38,7 @@
38#include <linux/delay.h> 38#include <linux/delay.h>
39#include <linux/usb.h> 39#include <linux/usb.h>
40#include <linux/smp_lock.h> 40#include <linux/smp_lock.h>
41#include <linux/mutex.h>
41 42
42#include "dabusb.h" 43#include "dabusb.h"
43#include "dabfirmware.h" 44#include "dabfirmware.h"
@@ -570,7 +571,7 @@ static ssize_t dabusb_read (struct file *file, char __user *buf, size_t count, l
570 s->readptr = 0; 571 s->readptr = 0;
571 } 572 }
572 } 573 }
573 err: //up(&s->mutex); 574 err: //mutex_unlock(&s->mutex);
574 return ret; 575 return ret;
575} 576}
576 577
@@ -585,10 +586,10 @@ static int dabusb_open (struct inode *inode, struct file *file)
585 s = &dabusb[devnum - DABUSB_MINOR]; 586 s = &dabusb[devnum - DABUSB_MINOR];
586 587
587 dbg("dabusb_open"); 588 dbg("dabusb_open");
588 down (&s->mutex); 589 mutex_lock(&s->mutex);
589 590
590 while (!s->usbdev || s->opened) { 591 while (!s->usbdev || s->opened) {
591 up (&s->mutex); 592 mutex_unlock(&s->mutex);
592 593
593 if (file->f_flags & O_NONBLOCK) { 594 if (file->f_flags & O_NONBLOCK) {
594 return -EBUSY; 595 return -EBUSY;
@@ -598,15 +599,15 @@ static int dabusb_open (struct inode *inode, struct file *file)
598 if (signal_pending (current)) { 599 if (signal_pending (current)) {
599 return -EAGAIN; 600 return -EAGAIN;
600 } 601 }
601 down (&s->mutex); 602 mutex_lock(&s->mutex);
602 } 603 }
603 if (usb_set_interface (s->usbdev, _DABUSB_IF, 1) < 0) { 604 if (usb_set_interface (s->usbdev, _DABUSB_IF, 1) < 0) {
604 up(&s->mutex); 605 mutex_unlock(&s->mutex);
605 err("set_interface failed"); 606 err("set_interface failed");
606 return -EINVAL; 607 return -EINVAL;
607 } 608 }
608 s->opened = 1; 609 s->opened = 1;
609 up (&s->mutex); 610 mutex_unlock(&s->mutex);
610 611
611 file->f_pos = 0; 612 file->f_pos = 0;
612 file->private_data = s; 613 file->private_data = s;
@@ -620,10 +621,10 @@ static int dabusb_release (struct inode *inode, struct file *file)
620 621
621 dbg("dabusb_release"); 622 dbg("dabusb_release");
622 623
623 down (&s->mutex); 624 mutex_lock(&s->mutex);
624 dabusb_stop (s); 625 dabusb_stop (s);
625 dabusb_free_buffers (s); 626 dabusb_free_buffers (s);
626 up (&s->mutex); 627 mutex_unlock(&s->mutex);
627 628
628 if (!s->remove_pending) { 629 if (!s->remove_pending) {
629 if (usb_set_interface (s->usbdev, _DABUSB_IF, 0) < 0) 630 if (usb_set_interface (s->usbdev, _DABUSB_IF, 0) < 0)
@@ -648,10 +649,10 @@ static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm
648 if (s->remove_pending) 649 if (s->remove_pending)
649 return -EIO; 650 return -EIO;
650 651
651 down (&s->mutex); 652 mutex_lock(&s->mutex);
652 653
653 if (!s->usbdev) { 654 if (!s->usbdev) {
654 up (&s->mutex); 655 mutex_unlock(&s->mutex);
655 return -EIO; 656 return -EIO;
656 } 657 }
657 658
@@ -691,7 +692,7 @@ static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm
691 ret = -ENOIOCTLCMD; 692 ret = -ENOIOCTLCMD;
692 break; 693 break;
693 } 694 }
694 up (&s->mutex); 695 mutex_unlock(&s->mutex);
695 return ret; 696 return ret;
696} 697}
697 698
@@ -737,7 +738,7 @@ static int dabusb_probe (struct usb_interface *intf,
737 738
738 s = &dabusb[intf->minor]; 739 s = &dabusb[intf->minor];
739 740
740 down (&s->mutex); 741 mutex_lock(&s->mutex);
741 s->remove_pending = 0; 742 s->remove_pending = 0;
742 s->usbdev = usbdev; 743 s->usbdev = usbdev;
743 s->devnum = intf->minor; 744 s->devnum = intf->minor;
@@ -760,7 +761,7 @@ static int dabusb_probe (struct usb_interface *intf,
760 } 761 }
761 dbg("bound to interface: %d", intf->altsetting->desc.bInterfaceNumber); 762 dbg("bound to interface: %d", intf->altsetting->desc.bInterfaceNumber);
762 usb_set_intfdata (intf, s); 763 usb_set_intfdata (intf, s);
763 up (&s->mutex); 764 mutex_unlock(&s->mutex);
764 765
765 retval = usb_register_dev(intf, &dabusb_class); 766 retval = usb_register_dev(intf, &dabusb_class);
766 if (retval) { 767 if (retval) {
@@ -771,7 +772,7 @@ static int dabusb_probe (struct usb_interface *intf,
771 return 0; 772 return 0;
772 773
773 reject: 774 reject:
774 up (&s->mutex); 775 mutex_unlock(&s->mutex);
775 s->usbdev = NULL; 776 s->usbdev = NULL;
776 return -ENODEV; 777 return -ENODEV;
777} 778}
@@ -828,7 +829,7 @@ static int __init dabusb_init (void)
828 for (u = 0; u < NRDABUSB; u++) { 829 for (u = 0; u < NRDABUSB; u++) {
829 pdabusb_t s = &dabusb[u]; 830 pdabusb_t s = &dabusb[u];
830 memset (s, 0, sizeof (dabusb_t)); 831 memset (s, 0, sizeof (dabusb_t));
831 init_MUTEX (&s->mutex); 832 mutex_init (&s->mutex);
832 s->usbdev = NULL; 833 s->usbdev = NULL;
833 s->total_buffer_size = buffers; 834 s->total_buffer_size = buffers;
834 init_waitqueue_head (&s->wait); 835 init_waitqueue_head (&s->wait);