]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (11390): 2-dev.c: return 0 for NULL open and release callbacks
authorHans Verkuil <hverkuil@xs4all.nl>
Sun, 29 Mar 2009 23:19:38 +0000 (20:19 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 7 Apr 2009 00:44:30 +0000 (21:44 -0300)
Patch allows v4l2_open and v4l2_release functions return 0 if open and
release driver callbacks set to NULL. This will be used in radio
drivers.

--

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Alexey Klimov <klimov.linux@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/v4l2-dev.c

index 91228b3df07d92f639804c89d1a98953829f6bd9..31eac66411d736e4330119900e111aa921e841e4 100644 (file)
@@ -229,7 +229,7 @@ static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm)
 static int v4l2_open(struct inode *inode, struct file *filp)
 {
        struct video_device *vdev;
-       int ret;
+       int ret = 0;
 
        /* Check if the video device is available */
        mutex_lock(&videodev_lock);
@@ -243,7 +243,9 @@ static int v4l2_open(struct inode *inode, struct file *filp)
        /* and increase the device refcount */
        video_get(vdev);
        mutex_unlock(&videodev_lock);
-       ret = vdev->fops->open(filp);
+       if (vdev->fops->open)
+               ret = vdev->fops->open(filp);
+
        /* decrease the refcount in case of an error */
        if (ret)
                video_put(vdev);
@@ -254,7 +256,10 @@ static int v4l2_open(struct inode *inode, struct file *filp)
 static int v4l2_release(struct inode *inode, struct file *filp)
 {
        struct video_device *vdev = video_devdata(filp);
-       int ret = vdev->fops->release(filp);
+       int ret = 0;
+
+       if (vdev->fops->release)
+               vdev->fops->release(filp);
 
        /* decrease the refcount unconditionally since the release()
           return value is ignored. */