aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/media/stv680.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/media/stv680.c')
-rw-r--r--drivers/usb/media/stv680.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/usb/media/stv680.c b/drivers/usb/media/stv680.c
index b497a6a0a206..9636da20748d 100644
--- a/drivers/usb/media/stv680.c
+++ b/drivers/usb/media/stv680.c
@@ -67,6 +67,7 @@
#include <linux/errno.h>
#include <linux/videodev.h>
#include <linux/usb.h>
+#include <linux/mutex.h>
#include "stv680.h"
@@ -317,12 +318,11 @@ static int stv_init (struct usb_stv *stv680)
unsigned char *buffer;
unsigned long int bufsize;
- buffer = kmalloc (40, GFP_KERNEL);
+ buffer = kzalloc (40, GFP_KERNEL);
if (buffer == NULL) {
PDEBUG (0, "STV(e): Out of (small buf) memory");
return -1;
}
- memset (buffer, 0, 40);
udelay (100);
/* set config 1, interface 0, alternate 0 */
@@ -1258,22 +1258,22 @@ static int stv680_mmap (struct file *file, struct vm_area_struct *vma)
unsigned long size = vma->vm_end-vma->vm_start;
unsigned long page, pos;
- down (&stv680->lock);
+ mutex_lock(&stv680->lock);
if (stv680->udev == NULL) {
- up (&stv680->lock);
+ mutex_unlock(&stv680->lock);
return -EIO;
}
if (size > (((STV680_NUMFRAMES * stv680->maxframesize) + PAGE_SIZE - 1)
& ~(PAGE_SIZE - 1))) {
- up (&stv680->lock);
+ mutex_unlock(&stv680->lock);
return -EINVAL;
}
pos = (unsigned long) stv680->fbuf;
while (size > 0) {
page = vmalloc_to_pfn((void *)pos);
if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
- up (&stv680->lock);
+ mutex_unlock(&stv680->lock);
return -EAGAIN;
}
start += PAGE_SIZE;
@@ -1283,7 +1283,7 @@ static int stv680_mmap (struct file *file, struct vm_area_struct *vma)
else
size = 0;
}
- up (&stv680->lock);
+ mutex_unlock(&stv680->lock);
return 0;
}
@@ -1387,14 +1387,12 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id
goto error;
}
/* We found one */
- if ((stv680 = kmalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) {
+ if ((stv680 = kzalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) {
PDEBUG (0, "STV(e): couldn't kmalloc stv680 struct.");
retval = -ENOMEM;
goto error;
}
- memset (stv680, 0, sizeof (*stv680));
-
stv680->udev = dev;
stv680->camera_name = camera_name;
@@ -1409,7 +1407,7 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id
memcpy (stv680->vdev->name, stv680->camera_name, strlen (stv680->camera_name));
init_waitqueue_head (&stv680->wq);
- init_MUTEX (&stv680->lock);
+ mutex_init (&stv680->lock);
wmb ();
if (video_register_device (stv680->vdev, VFL_TYPE_GRABBER, video_nr) == -1) {