diff options
-rw-r--r-- | Documentation/video4linux/v4l2-framework.txt | 14 | ||||
-rw-r--r-- | drivers/media/radio/dsbr100.c | 1 | ||||
-rw-r--r-- | drivers/media/radio/radio-keene.c | 1 |
3 files changed, 9 insertions, 7 deletions
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index 659b2ba12a4f..e3dfc268d9c1 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt | |||
@@ -182,11 +182,11 @@ static int __devinit drv_probe(struct pci_dev *pdev, | |||
182 | } | 182 | } |
183 | 183 | ||
184 | If you have multiple device nodes then it can be difficult to know when it is | 184 | If you have multiple device nodes then it can be difficult to know when it is |
185 | safe to unregister v4l2_device. For this purpose v4l2_device has refcounting | 185 | safe to unregister v4l2_device for hotpluggable devices. For this purpose |
186 | support. The refcount is increased whenever video_register_device is called and | 186 | v4l2_device has refcounting support. The refcount is increased whenever |
187 | it is decreased whenever that device node is released. When the refcount reaches | 187 | video_register_device is called and it is decreased whenever that device node |
188 | zero, then the v4l2_device release() callback is called. You can do your final | 188 | is released. When the refcount reaches zero, then the v4l2_device release() |
189 | cleanup there. | 189 | callback is called. You can do your final cleanup there. |
190 | 190 | ||
191 | If other device nodes (e.g. ALSA) are created, then you can increase and | 191 | If other device nodes (e.g. ALSA) are created, then you can increase and |
192 | decrease the refcount manually as well by calling: | 192 | decrease the refcount manually as well by calling: |
@@ -197,6 +197,10 @@ or: | |||
197 | 197 | ||
198 | int v4l2_device_put(struct v4l2_device *v4l2_dev); | 198 | int v4l2_device_put(struct v4l2_device *v4l2_dev); |
199 | 199 | ||
200 | Since the initial refcount is 1 you also need to call v4l2_device_put in the | ||
201 | disconnect() callback (for USB devices) or in the remove() callback (for e.g. | ||
202 | PCI devices), otherwise the refcount will never reach 0. | ||
203 | |||
200 | struct v4l2_subdev | 204 | struct v4l2_subdev |
201 | ------------------ | 205 | ------------------ |
202 | 206 | ||
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c index f36905b63645..bf813a63ab2a 100644 --- a/drivers/media/radio/dsbr100.c +++ b/drivers/media/radio/dsbr100.c | |||
@@ -481,7 +481,6 @@ static void usb_dsbr100_disconnect(struct usb_interface *intf) | |||
481 | { | 481 | { |
482 | struct dsbr100_device *radio = usb_get_intfdata(intf); | 482 | struct dsbr100_device *radio = usb_get_intfdata(intf); |
483 | 483 | ||
484 | v4l2_device_get(&radio->v4l2_dev); | ||
485 | mutex_lock(&radio->v4l2_lock); | 484 | mutex_lock(&radio->v4l2_lock); |
486 | usb_set_intfdata(intf, NULL); | 485 | usb_set_intfdata(intf, NULL); |
487 | video_unregister_device(&radio->videodev); | 486 | video_unregister_device(&radio->videodev); |
diff --git a/drivers/media/radio/radio-keene.c b/drivers/media/radio/radio-keene.c index 26a2b7a0304e..5f33047d0d43 100644 --- a/drivers/media/radio/radio-keene.c +++ b/drivers/media/radio/radio-keene.c | |||
@@ -148,7 +148,6 @@ static void usb_keene_disconnect(struct usb_interface *intf) | |||
148 | { | 148 | { |
149 | struct keene_device *radio = to_keene_dev(usb_get_intfdata(intf)); | 149 | struct keene_device *radio = to_keene_dev(usb_get_intfdata(intf)); |
150 | 150 | ||
151 | v4l2_device_get(&radio->v4l2_dev); | ||
152 | mutex_lock(&radio->lock); | 151 | mutex_lock(&radio->lock); |
153 | usb_set_intfdata(intf, NULL); | 152 | usb_set_intfdata(intf, NULL); |
154 | video_unregister_device(&radio->vdev); | 153 | video_unregister_device(&radio->vdev); |