Commit 65d9ff9c authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB (11390): 2-dev.c: return 0 for NULL open and release callbacks

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: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarAlexey Klimov <klimov.linux@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent dfa76fa2
...@@ -229,7 +229,7 @@ static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm) ...@@ -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) static int v4l2_open(struct inode *inode, struct file *filp)
{ {
struct video_device *vdev; struct video_device *vdev;
int ret; int ret = 0;
/* Check if the video device is available */ /* Check if the video device is available */
mutex_lock(&videodev_lock); mutex_lock(&videodev_lock);
...@@ -243,7 +243,9 @@ static int v4l2_open(struct inode *inode, struct file *filp) ...@@ -243,7 +243,9 @@ static int v4l2_open(struct inode *inode, struct file *filp)
/* and increase the device refcount */ /* and increase the device refcount */
video_get(vdev); video_get(vdev);
mutex_unlock(&videodev_lock); 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 */ /* decrease the refcount in case of an error */
if (ret) if (ret)
video_put(vdev); video_put(vdev);
...@@ -254,7 +256,10 @@ static int v4l2_open(struct inode *inode, struct file *filp) ...@@ -254,7 +256,10 @@ static int v4l2_open(struct inode *inode, struct file *filp)
static int v4l2_release(struct inode *inode, struct file *filp) static int v4l2_release(struct inode *inode, struct file *filp)
{ {
struct video_device *vdev = video_devdata(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() /* decrease the refcount unconditionally since the release()
return value is ignored. */ return value is ignored. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment