V4L/DVB (8430): videodev: move some functions from v4l2-dev.h to v4l2-common.h or...
[linux-2.6-block.git] / drivers / media / video / soc_camera.c
index 38a89f1331644c48cfd7c44a1f23ca86dfa24957..b01749088472c1294c8b8f798d3081647f7bdb4e 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/vmalloc.h>
 
 #include <media/v4l2-common.h>
+#include <media/v4l2-ioctl.h>
 #include <media/v4l2-dev.h>
 #include <media/videobuf-core.h>
 #include <media/soc_camera.h>
@@ -183,7 +184,6 @@ static int soc_camera_open(struct inode *inode, struct file *file)
        struct soc_camera_device *icd;
        struct soc_camera_host *ici;
        struct soc_camera_file *icf;
-       spinlock_t *lock;
        int ret;
 
        icf = vmalloc(sizeof(*icf));
@@ -194,7 +194,7 @@ static int soc_camera_open(struct inode *inode, struct file *file)
        mutex_lock(&video_lock);
 
        vdev = video_devdata(file);
-       icd = container_of(vdev->dev, struct soc_camera_device, dev);
+       icd = container_of(vdev->parent, struct soc_camera_device, dev);
        ici = to_soc_camera_host(icd->dev.parent);
 
        if (!try_module_get(icd->ops->owner)) {
@@ -210,13 +210,6 @@ static int soc_camera_open(struct inode *inode, struct file *file)
        }
 
        icf->icd = icd;
-
-       icf->lock = ici->ops->spinlock_alloc(icf);
-       if (!icf->lock) {
-               ret = -ENOMEM;
-               goto esla;
-       }
-
        icd->use_count++;
 
        /* Now we really have to activate the camera */
@@ -234,17 +227,12 @@ static int soc_camera_open(struct inode *inode, struct file *file)
        file->private_data = icf;
        dev_dbg(&icd->dev, "camera device open\n");
 
-       ici->ops->init_videobuf(&icf->vb_vidq, icf->lock, icd);
+       ici->ops->init_videobuf(&icf->vb_vidq, icd);
 
        return 0;
 
        /* All errors are entered with the video_lock held */
 eiciadd:
-       lock = icf->lock;
-       icf->lock = NULL;
-       if (ici->ops->spinlock_free)
-               ici->ops->spinlock_free(lock);
-esla:
        module_put(ici->ops->owner);
 emgi:
        module_put(icd->ops->owner);
@@ -260,22 +248,18 @@ static int soc_camera_close(struct inode *inode, struct file *file)
        struct soc_camera_device *icd = icf->icd;
        struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
        struct video_device *vdev = icd->vdev;
-       spinlock_t *lock = icf->lock;
 
        mutex_lock(&video_lock);
        icd->use_count--;
        if (!icd->use_count)
                ici->ops->remove(icd);
-       icf->lock = NULL;
-       if (ici->ops->spinlock_free)
-               ici->ops->spinlock_free(lock);
        module_put(icd->ops->owner);
        module_put(ici->ops->owner);
        mutex_unlock(&video_lock);
 
        vfree(icf);
 
-       dev_dbg(vdev->dev, "camera device close\n");
+       dev_dbg(vdev->parent, "camera device close\n");
 
        return 0;
 }
@@ -288,7 +272,7 @@ static ssize_t soc_camera_read(struct file *file, char __user *buf,
        struct video_device *vdev = icd->vdev;
        int err = -EINVAL;
 
-       dev_err(vdev->dev, "camera device read not implemented\n");
+       dev_err(vdev->parent, "camera device read not implemented\n");
 
        return err;
 }
@@ -764,21 +748,6 @@ static void dummy_release(struct device *dev)
 {
 }
 
-static spinlock_t *spinlock_alloc(struct soc_camera_file *icf)
-{
-       spinlock_t *lock = kmalloc(sizeof(spinlock_t), GFP_KERNEL);
-
-       if (lock)
-               spin_lock_init(lock);
-
-       return lock;
-}
-
-static void spinlock_free(spinlock_t *lock)
-{
-       kfree(lock);
-}
-
 int soc_camera_host_register(struct soc_camera_host *ici)
 {
        int ret;
@@ -808,11 +777,6 @@ int soc_camera_host_register(struct soc_camera_host *ici)
        if (ret)
                goto edevr;
 
-       if (!ici->ops->spinlock_alloc) {
-               ici->ops->spinlock_alloc = spinlock_alloc;
-               ici->ops->spinlock_free = spinlock_free;
-       }
-
        scan_add_host(ici);
 
        return 0;
@@ -914,7 +878,7 @@ int soc_camera_video_start(struct soc_camera_device *icd)
 
        strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name));
        /* Maybe better &ici->dev */
-       vdev->dev               = &icd->dev;
+       vdev->parent            = &icd->dev;
        vdev->type              = VID_TYPE_CAPTURE;
        vdev->current_norm      = V4L2_STD_UNKNOWN;
        vdev->fops              = &soc_camera_fops;
@@ -952,7 +916,7 @@ int soc_camera_video_start(struct soc_camera_device *icd)
 
        err = video_register_device(vdev, VFL_TYPE_GRABBER, vdev->minor);
        if (err < 0) {
-               dev_err(vdev->dev, "video_register_device failed\n");
+               dev_err(vdev->parent, "video_register_device failed\n");
                goto evidregd;
        }
        icd->vdev = vdev;