]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
V4L/DVB (11044): v4l2-device: add v4l2_device_disconnect
authorHans Verkuil <hverkuil@xs4all.nl>
Sat, 14 Mar 2009 11:28:45 +0000 (08:28 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 30 Mar 2009 15:43:22 +0000 (12:43 -0300)
Call v4l2_device_disconnect when the parent of a hotpluggable device
disconnects. This ensures that you do not have a pointer to a device that
is no longer present.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Documentation/video4linux/CARDLIST.bttv
Documentation/video4linux/v4l2-framework.txt
drivers/media/video/v4l2-device.c
include/media/v4l2-device.h

index f11c583295e9a9e88519002e6f759a95625ead26..e17750473e089d6428414e3bddd3635e3f601d58 100644 (file)
 156 -> IVCE-8784                                           [0000:f050,0001:f050,0002:f050,0003:f050]
 157 -> Geovision GV-800(S) (master)                        [800a:763d]
 158 -> Geovision GV-800(S) (slave)                         [800b:763d,800c:763d,800d:763d]
-159 -> ProVideo PV183                                      [1830:1540,1831:1540,1832:1540,1833:1540,1834:1540,1835:1540,1836:1540,1837:1540]
index 4207590b2ac853cccbae4014209a4d0a2388e29d..a31177390e551a5873a28121901dc904bebacee0 100644 (file)
@@ -105,6 +105,17 @@ You unregister with:
 
 Unregistering will also automatically unregister all subdevs from the device.
 
+If you have a hotpluggable device (e.g. a USB device), then when a disconnect
+happens the parent device becomes invalid. Since v4l2_device has a pointer to
+that parent device it has to be cleared as well to mark that the parent is
+gone. To do this call:
+
+       v4l2_device_disconnect(struct v4l2_device *v4l2_dev);
+
+This does *not* unregister the subdevs, so you still need to call the
+v4l2_device_unregister() function for that. If your driver is not hotpluggable,
+then there is no need to call v4l2_device_disconnect().
+
 Sometimes you need to iterate over all devices registered by a specific
 driver. This is usually the case if multiple device drivers use the same
 hardware. E.g. the ivtvfb driver is a framebuffer driver that uses the ivtv
index b3dcb845437926946c6c08ac6e76527b81db758c..94aa485ade52efb9b87a01871366b8363a39143b 100644 (file)
@@ -49,19 +49,26 @@ int v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev)
 }
 EXPORT_SYMBOL_GPL(v4l2_device_register);
 
+void v4l2_device_disconnect(struct v4l2_device *v4l2_dev)
+{
+       if (v4l2_dev->dev) {
+               dev_set_drvdata(v4l2_dev->dev, NULL);
+               v4l2_dev->dev = NULL;
+       }
+}
+EXPORT_SYMBOL_GPL(v4l2_device_disconnect);
+
 void v4l2_device_unregister(struct v4l2_device *v4l2_dev)
 {
        struct v4l2_subdev *sd, *next;
 
        if (v4l2_dev == NULL)
                return;
-       if (v4l2_dev->dev)
-               dev_set_drvdata(v4l2_dev->dev, NULL);
+       v4l2_device_disconnect(v4l2_dev);
+
        /* Unregister subdevs */
        list_for_each_entry_safe(sd, next, &v4l2_dev->subdevs, list)
                v4l2_device_unregister_subdev(sd);
-
-       v4l2_dev->dev = NULL;
 }
 EXPORT_SYMBOL_GPL(v4l2_device_unregister);
 
index 3d8e96f6ceb30716d29c6f6e83793e26f1aef2e8..0dd3e8e8653e136d28b97154d35c9cdb7f074b09 100644 (file)
@@ -53,7 +53,11 @@ struct v4l2_device {
    dev may be NULL in rare cases (ISA devices). In that case you
    must fill in the v4l2_dev->name field before calling this function. */
 int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev);
-/* Set v4l2_dev->dev->driver_data to NULL and unregister all sub-devices */
+/* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
+   Since the parent disappears this ensures that v4l2_dev doesn't have an
+   invalid parent pointer. */
+void v4l2_device_disconnect(struct v4l2_device *v4l2_dev);
+/* Unregister all sub-devices and any other resources related to v4l2_dev. */
 void v4l2_device_unregister(struct v4l2_device *v4l2_dev);
 
 /* Register a subdev with a v4l2 device. While registered the subdev module