aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2009-11-27 11:57:22 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-15 21:17:55 -0500
commit957b4aa9f786cf04585a690a2e4c3dc867ce80e9 (patch)
treef99f1350ab853529cdf586225f44490d8bcf1e34 /drivers/media
parent0fda5d4420fe1d6a19189386b6bc6532c97a7e0e (diff)
V4L/DVB (13552): v4l: Replace video_is_unregistered with video_is_registered
Replace the video_is_unregistered function by a video_is_registered function. The V4L2_FL_UNREGISTERED flag is replaced by a V4L2_FL_REGISTERED flag. This change makes the video_is_registered function return coherent results when called on an initialize but not yet registered video_device instance. The function can now be used instead of checking video_device::minor. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/hdpvr/hdpvr-video.c2
-rw-r--r--drivers/media/video/v4l2-dev.c18
2 files changed, 10 insertions, 10 deletions
diff --git a/drivers/media/video/hdpvr/hdpvr-video.c b/drivers/media/video/hdpvr/hdpvr-video.c
index b5439cabb381..fdd782039e9d 100644
--- a/drivers/media/video/hdpvr/hdpvr-video.c
+++ b/drivers/media/video/hdpvr/hdpvr-video.c
@@ -523,7 +523,7 @@ static unsigned int hdpvr_poll(struct file *filp, poll_table *wait)
523 523
524 mutex_lock(&dev->io_mutex); 524 mutex_lock(&dev->io_mutex);
525 525
526 if (video_is_unregistered(dev->video_dev)) { 526 if (!video_is_registered(dev->video_dev)) {
527 mutex_unlock(&dev->io_mutex); 527 mutex_unlock(&dev->io_mutex);
528 return -EIO; 528 return -EIO;
529 } 529 }
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index aa3e0f9aa3bf..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 }
@@ -555,6 +554,7 @@ static int __video_register_device(struct video_device *vdev, int type, int nr,
555 name_base, nr, video_device_node_name(vdev)); 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}