summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/v4l2-device.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-03-14 12:28:45 +0100
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-14 12:28:45 +0100
commit48beb6bb3e66daddf4c339f5c02710a060d3a0be (patch)
tree6af556d0d546f47fd7bd64db2daafb5b2b6e74ea /linux/drivers/media/video/v4l2-device.c
parent0f2ea07a22d87dcff3529fd787f8b41ed665bb28 (diff)
downloadmediapointer-dvb-s2-48beb6bb3e66daddf4c339f5c02710a060d3a0be.tar.gz
mediapointer-dvb-s2-48beb6bb3e66daddf4c339f5c02710a060d3a0be.tar.bz2
v4l2-device: add v4l2_device_disconnect
From: Hans Verkuil <hverkuil@xs4all.nl> 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. Priority: normal Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'linux/drivers/media/video/v4l2-device.c')
-rw-r--r--linux/drivers/media/video/v4l2-device.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/linux/drivers/media/video/v4l2-device.c b/linux/drivers/media/video/v4l2-device.c
index 35e42e947..2cb81c210 100644
--- a/linux/drivers/media/video/v4l2-device.c
+++ b/linux/drivers/media/video/v4l2-device.c
@@ -50,19 +50,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);