aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/media/dabusb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/media/dabusb.c')
-rw-r--r--drivers/usb/media/dabusb.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c
index 18d8eaf408d5..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"
@@ -217,12 +218,11 @@ static int dabusb_alloc_buffers (pdabusb_t s)
217 pipesize, packets, transfer_buffer_length); 218 pipesize, packets, transfer_buffer_length);
218 219
219 while (buffers < (s->total_buffer_size << 10)) { 220 while (buffers < (s->total_buffer_size << 10)) {
220 b = (pbuff_t) kmalloc (sizeof (buff_t), GFP_KERNEL); 221 b = (pbuff_t) kzalloc (sizeof (buff_t), GFP_KERNEL);
221 if (!b) { 222 if (!b) {
222 err("kmalloc(sizeof(buff_t))==NULL"); 223 err("kzalloc(sizeof(buff_t))==NULL");
223 goto err; 224 goto err;
224 } 225 }
225 memset (b, 0, sizeof (buff_t));
226 b->s = s; 226 b->s = s;
227 b->purb = usb_alloc_urb(packets, GFP_KERNEL); 227 b->purb = usb_alloc_urb(packets, GFP_KERNEL);
228 if (!b->purb) { 228 if (!b->purb) {
@@ -571,7 +571,7 @@ static ssize_t dabusb_read (struct file *file, char __user *buf, size_t count, l
571 s->readptr = 0; 571 s->readptr = 0;
572 } 572 }
573 } 573 }
574 err: //up(&s->mutex); 574 err: //mutex_unlock(&s->mutex);
575 return ret; 575 return ret;
576} 576}
577 577
@@ -586,10 +586,10 @@ static int dabusb_open (struct inode *inode, struct file *file)
586 s = &dabusb[devnum - DABUSB_MINOR]; 586 s = &dabusb[devnum - DABUSB_MINOR];
587 587
588 dbg("dabusb_open"); 588 dbg("dabusb_open");
589 down (&s->mutex); 589 mutex_lock(&s->mutex);
590 590
591 while (!s->usbdev || s->opened) { 591 while (!s->usbdev || s->opened) {
592 up (&s->mutex); 592 mutex_unlock(&s->mutex);
593 593
594 if (file->f_flags & O_NONBLOCK) { 594 if (file->f_flags & O_NONBLOCK) {
595 return -EBUSY; 595 return -EBUSY;
@@ -599,15 +599,15 @@ static int dabusb_open (struct inode *inode, struct file *file)
599 if (signal_pending (current)) { 599 if (signal_pending (current)) {
600 return -EAGAIN; 600 return -EAGAIN;
601 } 601 }
602 down (&s->mutex); 602 mutex_lock(&s->mutex);
603 } 603 }
604 if (usb_set_interface (s->usbdev, _DABUSB_IF, 1) < 0) { 604 if (usb_set_interface (s->usbdev, _DABUSB_IF, 1) < 0) {
605 up(&s->mutex); 605 mutex_unlock(&s->mutex);
606 err("set_interface failed"); 606 err("set_interface failed");
607 return -EINVAL; 607 return -EINVAL;
608 } 608 }
609 s->opened = 1; 609 s->opened = 1;
610 up (&s->mutex); 610 mutex_unlock(&s->mutex);
611 611
612 file->f_pos = 0; 612 file->f_pos = 0;
613 file->private_data = s; 613 file->private_data = s;
@@ -621,10 +621,10 @@ static int dabusb_release (struct inode *inode, struct file *file)
621 621
622 dbg("dabusb_release"); 622 dbg("dabusb_release");
623 623
624 down (&s->mutex); 624 mutex_lock(&s->mutex);
625 dabusb_stop (s); 625 dabusb_stop (s);
626 dabusb_free_buffers (s); 626 dabusb_free_buffers (s);
627 up (&s->mutex); 627 mutex_unlock(&s->mutex);
628 628
629 if (!s->remove_pending) { 629 if (!s->remove_pending) {
630 if (usb_set_interface (s->usbdev, _DABUSB_IF, 0) < 0) 630 if (usb_set_interface (s->usbdev, _DABUSB_IF, 0) < 0)
@@ -649,10 +649,10 @@ static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm
649 if (s->remove_pending) 649 if (s->remove_pending)
650 return -EIO; 650 return -EIO;
651 651
652 down (&s->mutex); 652 mutex_lock(&s->mutex);
653 653
654 if (!s->usbdev) { 654 if (!s->usbdev) {
655 up (&s->mutex); 655 mutex_unlock(&s->mutex);
656 return -EIO; 656 return -EIO;
657 } 657 }
658 658
@@ -692,7 +692,7 @@ static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm
692 ret = -ENOIOCTLCMD; 692 ret = -ENOIOCTLCMD;
693 break; 693 break;
694 } 694 }
695 up (&s->mutex); 695 mutex_unlock(&s->mutex);
696 return ret; 696 return ret;
697} 697}
698 698
@@ -738,7 +738,7 @@ static int dabusb_probe (struct usb_interface *intf,
738 738
739 s = &dabusb[intf->minor]; 739 s = &dabusb[intf->minor];
740 740
741 down (&s->mutex); 741 mutex_lock(&s->mutex);
742 s->remove_pending = 0; 742 s->remove_pending = 0;
743 s->usbdev = usbdev; 743 s->usbdev = usbdev;
744 s->devnum = intf->minor; 744 s->devnum = intf->minor;
@@ -761,7 +761,7 @@ static int dabusb_probe (struct usb_interface *intf,
761 } 761 }
762 dbg("bound to interface: %d", intf->altsetting->desc.bInterfaceNumber); 762 dbg("bound to interface: %d", intf->altsetting->desc.bInterfaceNumber);
763 usb_set_intfdata (intf, s); 763 usb_set_intfdata (intf, s);
764 up (&s->mutex); 764 mutex_unlock(&s->mutex);
765 765
766 retval = usb_register_dev(intf, &dabusb_class); 766 retval = usb_register_dev(intf, &dabusb_class);
767 if (retval) { 767 if (retval) {
@@ -772,7 +772,7 @@ static int dabusb_probe (struct usb_interface *intf,
772 return 0; 772 return 0;
773 773
774 reject: 774 reject:
775 up (&s->mutex); 775 mutex_unlock(&s->mutex);
776 s->usbdev = NULL; 776 s->usbdev = NULL;
777 return -ENODEV; 777 return -ENODEV;
778} 778}
@@ -829,7 +829,7 @@ static int __init dabusb_init (void)
829 for (u = 0; u < NRDABUSB; u++) { 829 for (u = 0; u < NRDABUSB; u++) {
830 pdabusb_t s = &dabusb[u]; 830 pdabusb_t s = &dabusb[u];
831 memset (s, 0, sizeof (dabusb_t)); 831 memset (s, 0, sizeof (dabusb_t));
832 init_MUTEX (&s->mutex); 832 mutex_init (&s->mutex);
833 s->usbdev = NULL; 833 s->usbdev = NULL;
834 s->total_buffer_size = buffers; 834 s->total_buffer_size = buffers;
835 init_waitqueue_head (&s->wait); 835 init_waitqueue_head (&s->wait);