Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[pandora-kernel.git] / drivers / media / video / cx88 / cx88-blackbird.c
index 660b2a9..417d1d5 100644 (file)
@@ -1057,7 +1057,7 @@ static int mpeg_open(struct file *file)
 
        dprintk( 1, "%s\n", __func__);
 
-       lock_kernel();
+       mutex_lock(&dev->core->lock);
 
        /* Make sure we can acquire the hardware */
        drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD);
@@ -1065,7 +1065,7 @@ static int mpeg_open(struct file *file)
                err = drv->request_acquire(drv);
                if(err != 0) {
                        dprintk(1,"%s: Unable to acquire hardware, %d\n", __func__, err);
-                       unlock_kernel();
+                       mutex_unlock(&dev->core->lock);;
                        return err;
                }
        }
@@ -1073,7 +1073,7 @@ static int mpeg_open(struct file *file)
        if (!atomic_read(&dev->core->mpeg_users) && blackbird_initialize_codec(dev) < 0) {
                if (drv)
                        drv->request_release(drv);
-               unlock_kernel();
+               mutex_unlock(&dev->core->lock);
                return -EINVAL;
        }
        dprintk(1, "open dev=%s\n", video_device_node_name(vdev));
@@ -1083,7 +1083,7 @@ static int mpeg_open(struct file *file)
        if (NULL == fh) {
                if (drv)
                        drv->request_release(drv);
-               unlock_kernel();
+               mutex_unlock(&dev->core->lock);
                return -ENOMEM;
        }
        file->private_data = fh;
@@ -1094,15 +1094,14 @@ static int mpeg_open(struct file *file)
                            V4L2_BUF_TYPE_VIDEO_CAPTURE,
                            V4L2_FIELD_INTERLACED,
                            sizeof(struct cx88_buffer),
-                           fh);
+                           fh, NULL);
 
        /* FIXME: locking against other video device */
        cx88_set_scale(dev->core, dev->width, dev->height,
                        fh->mpegq.field);
-       unlock_kernel();
 
        atomic_inc(&dev->core->mpeg_users);
-
+       mutex_unlock(&dev->core->lock);
        return 0;
 }
 
@@ -1120,8 +1119,11 @@ static int mpeg_release(struct file *file)
        videobuf_stop(&fh->mpegq);
 
        videobuf_mmap_free(&fh->mpegq);
+
+       mutex_lock(&dev->core->lock);
        file->private_data = NULL;
        kfree(fh);
+       mutex_unlock(&dev->core->lock);
 
        /* Make sure we release the hardware */
        drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD);