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 @@
67#include <linux/errno.h> 67#include <linux/errno.h>
68#include <linux/videodev.h> 68#include <linux/videodev.h>
69#include <linux/usb.h> 69#include <linux/usb.h>
70#include <linux/mutex.h>
70 71
71#include "stv680.h" 72#include "stv680.h"
72 73
@@ -317,12 +318,11 @@ static int stv_init (struct usb_stv *stv680)
317 unsigned char *buffer; 318 unsigned char *buffer;
318 unsigned long int bufsize; 319 unsigned long int bufsize;
319 320
320 buffer = kmalloc (40, GFP_KERNEL); 321 buffer = kzalloc (40, GFP_KERNEL);
321 if (buffer == NULL) { 322 if (buffer == NULL) {
322 PDEBUG (0, "STV(e): Out of (small buf) memory"); 323 PDEBUG (0, "STV(e): Out of (small buf) memory");
323 return -1; 324 return -1;
324 } 325 }
325 memset (buffer, 0, 40);
326 udelay (100); 326 udelay (100);
327 327
328 /* set config 1, interface 0, alternate 0 */ 328 /* set config 1, interface 0, alternate 0 */
@@ -1258,22 +1258,22 @@ static int stv680_mmap (struct file *file, struct vm_area_struct *vma)
1258 unsigned long size = vma->vm_end-vma->vm_start; 1258 unsigned long size = vma->vm_end-vma->vm_start;
1259 unsigned long page, pos; 1259 unsigned long page, pos;
1260 1260
1261 down (&stv680->lock); 1261 mutex_lock(&stv680->lock);
1262 1262
1263 if (stv680->udev == NULL) { 1263 if (stv680->udev == NULL) {
1264 up (&stv680->lock); 1264 mutex_unlock(&stv680->lock);
1265 return -EIO; 1265 return -EIO;
1266 } 1266 }
1267 if (size > (((STV680_NUMFRAMES * stv680->maxframesize) + PAGE_SIZE - 1) 1267 if (size > (((STV680_NUMFRAMES * stv680->maxframesize) + PAGE_SIZE - 1)
1268 & ~(PAGE_SIZE - 1))) { 1268 & ~(PAGE_SIZE - 1))) {
1269 up (&stv680->lock); 1269 mutex_unlock(&stv680->lock);
1270 return -EINVAL; 1270 return -EINVAL;
1271 } 1271 }
1272 pos = (unsigned long) stv680->fbuf; 1272 pos = (unsigned long) stv680->fbuf;
1273 while (size > 0) { 1273 while (size > 0) {
1274 page = vmalloc_to_pfn((void *)pos); 1274 page = vmalloc_to_pfn((void *)pos);
1275 if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) { 1275 if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
1276 up (&stv680->lock); 1276 mutex_unlock(&stv680->lock);
1277 return -EAGAIN; 1277 return -EAGAIN;
1278 } 1278 }
1279 start += PAGE_SIZE; 1279 start += PAGE_SIZE;
@@ -1283,7 +1283,7 @@ static int stv680_mmap (struct file *file, struct vm_area_struct *vma)
1283 else 1283 else
1284 size = 0; 1284 size = 0;
1285 } 1285 }
1286 up (&stv680->lock); 1286 mutex_unlock(&stv680->lock);
1287 1287
1288 return 0; 1288 return 0;
1289} 1289}
@@ -1387,14 +1387,12 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id
1387 goto error; 1387 goto error;
1388 } 1388 }
1389 /* We found one */ 1389 /* We found one */
1390 if ((stv680 = kmalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) { 1390 if ((stv680 = kzalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) {
1391 PDEBUG (0, "STV(e): couldn't kmalloc stv680 struct."); 1391 PDEBUG (0, "STV(e): couldn't kmalloc stv680 struct.");
1392 retval = -ENOMEM; 1392 retval = -ENOMEM;
1393 goto error; 1393 goto error;
1394 } 1394 }
1395 1395
1396 memset (stv680, 0, sizeof (*stv680));
1397
1398 stv680->udev = dev; 1396 stv680->udev = dev;
1399 stv680->camera_name = camera_name; 1397 stv680->camera_name = camera_name;
1400 1398
@@ -1409,7 +1407,7 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id
1409 1407
1410 memcpy (stv680->vdev->name, stv680->camera_name, strlen (stv680->camera_name)); 1408 memcpy (stv680->vdev->name, stv680->camera_name, strlen (stv680->camera_name));
1411 init_waitqueue_head (&stv680->wq); 1409 init_waitqueue_head (&stv680->wq);
1412 init_MUTEX (&stv680->lock); 1410 mutex_init (&stv680->lock);
1413 wmb (); 1411 wmb ();
1414 1412
1415 if (video_register_device (stv680->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { 1413 if (video_register_device (stv680->vdev, VFL_TYPE_GRABBER, video_nr) == -1) {