aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2009-12-09 06:40:05 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-22 03:53:18 -0400
commit95db3a60e0652a52df145aacade1a88c5acef659 (patch)
tree7b8a14a964684ecd49667125e5429360e41c11d5 /drivers
parente02188c90f6ef61f0844c42508fe603c5d4fa42b (diff)
[media] v4l: Add a media_device pointer to the v4l2_device structure
The pointer will later be used to register/unregister media entities when registering/unregistering a v4l2_subdev or a video_device. With the introduction of media devices, device drivers need to store a pointer to a driver-specific structure in the device's drvdata. v4l2_device can't claim ownership of the drvdata anymore. To maintain compatibility with drivers that rely on v4l2_device storing a pointer to itself in the device's drvdata, v4l2_device_register() will keep doing so if the drvdata is NULL. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/v4l2-device.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c
index 8c0ad8b372d8..cfbd8a38991d 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -47,9 +47,8 @@ int v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev)
47 if (!v4l2_dev->name[0]) 47 if (!v4l2_dev->name[0])
48 snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), "%s %s", 48 snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), "%s %s",
49 dev->driver->name, dev_name(dev)); 49 dev->driver->name, dev_name(dev));
50 if (dev_get_drvdata(dev)) 50 if (!dev_get_drvdata(dev))
51 v4l2_warn(v4l2_dev, "Non-NULL drvdata on register\n"); 51 dev_set_drvdata(dev, v4l2_dev);
52 dev_set_drvdata(dev, v4l2_dev);
53 return 0; 52 return 0;
54} 53}
55EXPORT_SYMBOL_GPL(v4l2_device_register); 54EXPORT_SYMBOL_GPL(v4l2_device_register);
@@ -72,10 +71,12 @@ EXPORT_SYMBOL_GPL(v4l2_device_set_name);
72 71
73void v4l2_device_disconnect(struct v4l2_device *v4l2_dev) 72void v4l2_device_disconnect(struct v4l2_device *v4l2_dev)
74{ 73{
75 if (v4l2_dev->dev) { 74 if (v4l2_dev->dev == NULL)
75 return;
76
77 if (dev_get_drvdata(v4l2_dev->dev) == v4l2_dev)
76 dev_set_drvdata(v4l2_dev->dev, NULL); 78 dev_set_drvdata(v4l2_dev->dev, NULL);
77 v4l2_dev->dev = NULL; 79 v4l2_dev->dev = NULL;
78 }
79} 80}
80EXPORT_SYMBOL_GPL(v4l2_device_disconnect); 81EXPORT_SYMBOL_GPL(v4l2_device_disconnect);
81 82