diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-03-14 07:28:45 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:43:22 -0400 |
commit | ae6cfaace120f4330715b56265ce0e4a710e1276 (patch) | |
tree | ed01c11218132e92ce8fe4872fe26c572c3c8842 /drivers/media/video/v4l2-device.c | |
parent | 6273fda6e32e2cd9a478545d0cbc15ac497b1f4b (diff) |
V4L/DVB (11044): v4l2-device: add v4l2_device_disconnect
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>
Diffstat (limited to 'drivers/media/video/v4l2-device.c')
-rw-r--r-- | drivers/media/video/v4l2-device.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c index b3dcb8454379..94aa485ade52 100644 --- a/drivers/media/video/v4l2-device.c +++ b/drivers/media/video/v4l2-device.c | |||
@@ -49,19 +49,26 @@ int v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev) | |||
49 | } | 49 | } |
50 | EXPORT_SYMBOL_GPL(v4l2_device_register); | 50 | EXPORT_SYMBOL_GPL(v4l2_device_register); |
51 | 51 | ||
52 | void v4l2_device_disconnect(struct v4l2_device *v4l2_dev) | ||
53 | { | ||
54 | if (v4l2_dev->dev) { | ||
55 | dev_set_drvdata(v4l2_dev->dev, NULL); | ||
56 | v4l2_dev->dev = NULL; | ||
57 | } | ||
58 | } | ||
59 | EXPORT_SYMBOL_GPL(v4l2_device_disconnect); | ||
60 | |||
52 | void v4l2_device_unregister(struct v4l2_device *v4l2_dev) | 61 | void v4l2_device_unregister(struct v4l2_device *v4l2_dev) |
53 | { | 62 | { |
54 | struct v4l2_subdev *sd, *next; | 63 | struct v4l2_subdev *sd, *next; |
55 | 64 | ||
56 | if (v4l2_dev == NULL) | 65 | if (v4l2_dev == NULL) |
57 | return; | 66 | return; |
58 | if (v4l2_dev->dev) | 67 | v4l2_device_disconnect(v4l2_dev); |
59 | dev_set_drvdata(v4l2_dev->dev, NULL); | 68 | |
60 | /* Unregister subdevs */ | 69 | /* Unregister subdevs */ |
61 | list_for_each_entry_safe(sd, next, &v4l2_dev->subdevs, list) | 70 | list_for_each_entry_safe(sd, next, &v4l2_dev->subdevs, list) |
62 | v4l2_device_unregister_subdev(sd); | 71 | v4l2_device_unregister_subdev(sd); |
63 | |||
64 | v4l2_dev->dev = NULL; | ||
65 | } | 72 | } |
66 | EXPORT_SYMBOL_GPL(v4l2_device_unregister); | 73 | EXPORT_SYMBOL_GPL(v4l2_device_unregister); |
67 | 74 | ||