diff options
-rw-r--r-- | drivers/media/video/hdpvr/hdpvr-video.c | 2 | ||||
-rw-r--r-- | drivers/media/video/v4l2-dev.c | 18 | ||||
-rw-r--r-- | include/media/v4l2-dev.h | 18 |
3 files changed, 18 insertions, 20 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); | |||
593 | void video_unregister_device(struct video_device *vdev) | 593 | void 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 | } |
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index 9135f57351f6..2dee93892ea2 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h | |||
@@ -28,10 +28,10 @@ struct v4l2_ioctl_callbacks; | |||
28 | struct video_device; | 28 | struct video_device; |
29 | struct v4l2_device; | 29 | struct v4l2_device; |
30 | 30 | ||
31 | /* Flag to mark the video_device struct as unregistered. | 31 | /* Flag to mark the video_device struct as registered. |
32 | Drivers can set this flag if they want to block all future | 32 | Drivers can clear this flag if they want to block all future |
33 | device access. It is set by video_unregister_device. */ | 33 | device access. It is cleared by video_unregister_device. */ |
34 | #define V4L2_FL_UNREGISTERED (0) | 34 | #define V4L2_FL_REGISTERED (0) |
35 | 35 | ||
36 | struct v4l2_file_operations { | 36 | struct v4l2_file_operations { |
37 | struct module *owner; | 37 | struct module *owner; |
@@ -96,9 +96,7 @@ struct video_device | |||
96 | /* Register video devices. Note that if video_register_device fails, | 96 | /* Register video devices. Note that if video_register_device fails, |
97 | the release() callback of the video_device structure is *not* called, so | 97 | the release() callback of the video_device structure is *not* called, so |
98 | the caller is responsible for freeing any data. Usually that means that | 98 | the caller is responsible for freeing any data. Usually that means that |
99 | you call video_device_release() on failure. | 99 | you call video_device_release() on failure. */ |
100 | |||
101 | Also note that vdev->minor is set to -1 if the registration failed. */ | ||
102 | int __must_check video_register_device(struct video_device *vdev, int type, int nr); | 100 | int __must_check video_register_device(struct video_device *vdev, int type, int nr); |
103 | 101 | ||
104 | /* Same as video_register_device, but no warning is issued if the desired | 102 | /* Same as video_register_device, but no warning is issued if the desired |
@@ -106,7 +104,7 @@ int __must_check video_register_device(struct video_device *vdev, int type, int | |||
106 | int __must_check video_register_device_no_warn(struct video_device *vdev, int type, int nr); | 104 | int __must_check video_register_device_no_warn(struct video_device *vdev, int type, int nr); |
107 | 105 | ||
108 | /* Unregister video devices. Will do nothing if vdev == NULL or | 106 | /* Unregister video devices. Will do nothing if vdev == NULL or |
109 | vdev->minor < 0. */ | 107 | video_is_registered() returns false. */ |
110 | void video_unregister_device(struct video_device *vdev); | 108 | void video_unregister_device(struct video_device *vdev); |
111 | 109 | ||
112 | /* helper functions to alloc/release struct video_device, the | 110 | /* helper functions to alloc/release struct video_device, the |
@@ -146,9 +144,9 @@ static inline const char *video_device_node_name(struct video_device *vdev) | |||
146 | return dev_name(&vdev->dev); | 144 | return dev_name(&vdev->dev); |
147 | } | 145 | } |
148 | 146 | ||
149 | static inline int video_is_unregistered(struct video_device *vdev) | 147 | static inline int video_is_registered(struct video_device *vdev) |
150 | { | 148 | { |
151 | return test_bit(V4L2_FL_UNREGISTERED, &vdev->flags); | 149 | return test_bit(V4L2_FL_REGISTERED, &vdev->flags); |
152 | } | 150 | } |
153 | 151 | ||
154 | #endif /* _V4L2_DEV_H */ | 152 | #endif /* _V4L2_DEV_H */ |