aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/v4l2-dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/v4l2-dev.c')
-rw-r--r--drivers/media/video/v4l2-dev.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 500cbe9891ac..709069916068 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -189,7 +189,7 @@ static ssize_t v4l2_read(struct file *filp, char __user *buf,
189 189
190 if (!vdev->fops->read) 190 if (!vdev->fops->read)
191 return -EINVAL; 191 return -EINVAL;
192 if (video_is_unregistered(vdev)) 192 if (!video_is_registered(vdev))
193 return -EIO; 193 return -EIO;
194 return vdev->fops->read(filp, buf, sz, off); 194 return vdev->fops->read(filp, buf, sz, off);
195} 195}
@@ -201,7 +201,7 @@ static ssize_t v4l2_write(struct file *filp, const char __user *buf,
201 201
202 if (!vdev->fops->write) 202 if (!vdev->fops->write)
203 return -EINVAL; 203 return -EINVAL;
204 if (video_is_unregistered(vdev)) 204 if (!video_is_registered(vdev))
205 return -EIO; 205 return -EIO;
206 return vdev->fops->write(filp, buf, sz, off); 206 return vdev->fops->write(filp, buf, sz, off);
207} 207}
@@ -210,7 +210,7 @@ static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll)
210{ 210{
211 struct video_device *vdev = video_devdata(filp); 211 struct video_device *vdev = video_devdata(filp);
212 212
213 if (!vdev->fops->poll || video_is_unregistered(vdev)) 213 if (!vdev->fops->poll || !video_is_registered(vdev))
214 return DEFAULT_POLLMASK; 214 return DEFAULT_POLLMASK;
215 return vdev->fops->poll(filp, poll); 215 return vdev->fops->poll(filp, poll);
216} 216}
@@ -250,7 +250,7 @@ static unsigned long v4l2_get_unmapped_area(struct file *filp,
250 250
251 if (!vdev->fops->get_unmapped_area) 251 if (!vdev->fops->get_unmapped_area)
252 return -ENOSYS; 252 return -ENOSYS;
253 if (video_is_unregistered(vdev)) 253 if (!video_is_registered(vdev))
254 return -ENODEV; 254 return -ENODEV;
255 return vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags); 255 return vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags);
256} 256}
@@ -260,8 +260,7 @@ static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm)
260{ 260{
261 struct video_device *vdev = video_devdata(filp); 261 struct video_device *vdev = video_devdata(filp);
262 262
263 if (!vdev->fops->mmap || 263 if (!vdev->fops->mmap || !video_is_registered(vdev))
264 video_is_unregistered(vdev))
265 return -ENODEV; 264 return -ENODEV;
266 return vdev->fops->mmap(filp, vm); 265 return vdev->fops->mmap(filp, vm);
267} 266}
@@ -277,7 +276,7 @@ static int v4l2_open(struct inode *inode, struct file *filp)
277 vdev = video_devdata(filp); 276 vdev = video_devdata(filp);
278 /* return ENODEV if the video device has been removed 277 /* return ENODEV if the video device has been removed
279 already or if it is not registered anymore. */ 278 already or if it is not registered anymore. */
280 if (vdev == NULL || video_is_unregistered(vdev)) { 279 if (vdev == NULL || !video_is_registered(vdev)) {
281 mutex_unlock(&videodev_lock); 280 mutex_unlock(&videodev_lock);
282 return -ENODEV; 281 return -ENODEV;
283 } 282 }
@@ -551,10 +550,11 @@ static int __video_register_device(struct video_device *vdev, int type, int nr,
551 vdev->dev.release = v4l2_device_release; 550 vdev->dev.release = v4l2_device_release;
552 551
553 if (nr != -1 && nr != vdev->num && warn_if_nr_in_use) 552 if (nr != -1 && nr != vdev->num && warn_if_nr_in_use)
554 printk(KERN_WARNING "%s: requested %s%d, got %s%d\n", 553 printk(KERN_WARNING "%s: requested %s%d, got %s\n", __func__,
555 __func__, name_base, nr, name_base, vdev->num); 554 name_base, nr, video_device_node_name(vdev));
556 555
557 /* Part 5: Activate this minor. The char device can now be used. */ 556 /* Part 5: Activate this minor. The char device can now be used. */
557 set_bit(V4L2_FL_REGISTERED, &vdev->flags);
558 mutex_lock(&videodev_lock); 558 mutex_lock(&videodev_lock);
559 video_device[vdev->minor] = vdev; 559 video_device[vdev->minor] = vdev;
560 mutex_unlock(&videodev_lock); 560 mutex_unlock(&videodev_lock);
@@ -593,11 +593,11 @@ EXPORT_SYMBOL(video_register_device_no_warn);
593void video_unregister_device(struct video_device *vdev) 593void video_unregister_device(struct video_device *vdev)
594{ 594{
595 /* Check if vdev was ever registered at all */ 595 /* Check if vdev was ever registered at all */
596 if (!vdev || vdev->minor < 0) 596 if (!vdev || !video_is_registered(vdev))
597 return; 597 return;
598 598
599 mutex_lock(&videodev_lock); 599 mutex_lock(&videodev_lock);
600 set_bit(V4L2_FL_UNREGISTERED, &vdev->flags); 600 clear_bit(V4L2_FL_REGISTERED, &vdev->flags);
601 mutex_unlock(&videodev_lock); 601 mutex_unlock(&videodev_lock);
602 device_unregister(&vdev->dev); 602 device_unregister(&vdev->dev);
603} 603}