aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/videodev.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2007-10-08 15:26:13 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 23:03:14 -0400
commit54bd5b66c87d14e250f108aad1228b905d6882f6 (patch)
tree2ecb78046819e2c9da176a74e4e9fbc8097031be /drivers/media/video/videodev.c
parentd4cae5a50021271b9ef4e5e39e71e177d12fa8cb (diff)
V4L/DVB (6293): V4L: convert struct class_device to struct device
The currently used "struct class_device" will be removed from the kernel. Here is a patch that converts all users in drivers/media/video/ to struct device. Reviewed-by: Thierry Merle <thierry.merle@free.fr> Reviewed-by: Mike Isely <isely@pobox.com> Reviewed-by: Luca Risolia <luca.risolia@studio.unibo.it> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/videodev.c')
-rw-r--r--drivers/media/video/videodev.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 0334b9aaf12a..0fbe8a1a91b3 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -54,15 +54,14 @@
54 * sysfs stuff 54 * sysfs stuff
55 */ 55 */
56 56
57static ssize_t show_name(struct class_device *cd, char *buf) 57static ssize_t show_name(struct device *cd,
58 struct device_attribute *attr, char *buf)
58{ 59{
59 struct video_device *vfd = container_of(cd, struct video_device, 60 struct video_device *vfd = container_of(cd, struct video_device,
60 class_dev); 61 class_dev);
61 return sprintf(buf,"%.*s\n",(int)sizeof(vfd->name),vfd->name); 62 return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name);
62} 63}
63 64
64static CLASS_DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
65
66struct video_device *video_device_alloc(void) 65struct video_device *video_device_alloc(void)
67{ 66{
68 struct video_device *vfd; 67 struct video_device *vfd;
@@ -76,10 +75,9 @@ void video_device_release(struct video_device *vfd)
76 kfree(vfd); 75 kfree(vfd);
77} 76}
78 77
79static void video_release(struct class_device *cd) 78static void video_release(struct device *cd)
80{ 79{
81 struct video_device *vfd = container_of(cd, struct video_device, 80 struct video_device *vfd = container_of(cd, struct video_device, class_dev);
82 class_dev);
83 81
84#if 1 82#if 1
85 /* needed until all drivers are fixed */ 83 /* needed until all drivers are fixed */
@@ -89,9 +87,15 @@ static void video_release(struct class_device *cd)
89 vfd->release(vfd); 87 vfd->release(vfd);
90} 88}
91 89
90static struct device_attribute video_device_attrs[] = {
91 __ATTR(name, S_IRUGO, show_name, NULL),
92 __ATTR_NULL
93};
94
92static struct class video_class = { 95static struct class video_class = {
93 .name = VIDEO_NAME, 96 .name = VIDEO_NAME,
94 .release = video_release, 97 .dev_attrs = video_device_attrs,
98 .dev_release = video_release,
95}; 99};
96 100
97/* 101/*
@@ -1753,22 +1757,16 @@ int video_register_device(struct video_device *vfd, int type, int nr)
1753 /* sysfs class */ 1757 /* sysfs class */
1754 memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev)); 1758 memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev));
1755 if (vfd->dev) 1759 if (vfd->dev)
1756 vfd->class_dev.dev = vfd->dev; 1760 vfd->class_dev.parent = vfd->dev;
1757 vfd->class_dev.class = &video_class; 1761 vfd->class_dev.class = &video_class;
1758 vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor); 1762 vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
1759 sprintf(vfd->class_dev.class_id, "%s%d", name_base, i - base); 1763 sprintf(vfd->class_dev.bus_id, "%s%d", name_base, i - base);
1760 ret = class_device_register(&vfd->class_dev); 1764 ret = device_register(&vfd->class_dev);
1761 if (ret < 0) { 1765 if (ret < 0) {
1762 printk(KERN_ERR "%s: class_device_register failed\n", 1766 printk(KERN_ERR "%s: device_register failed\n",
1763 __FUNCTION__); 1767 __FUNCTION__);
1764 goto fail_minor; 1768 goto fail_minor;
1765 } 1769 }
1766 ret = class_device_create_file(&vfd->class_dev, &class_device_attr_name);
1767 if (ret < 0) {
1768 printk(KERN_ERR "%s: class_device_create_file 'name' failed\n",
1769 __FUNCTION__);
1770 goto fail_classdev;
1771 }
1772 1770
1773#if 1 1771#if 1
1774 /* needed until all drivers are fixed */ 1772 /* needed until all drivers are fixed */
@@ -1779,8 +1777,6 @@ int video_register_device(struct video_device *vfd, int type, int nr)
1779#endif 1777#endif
1780 return 0; 1778 return 0;
1781 1779
1782fail_classdev:
1783 class_device_unregister(&vfd->class_dev);
1784fail_minor: 1780fail_minor:
1785 mutex_lock(&videodev_lock); 1781 mutex_lock(&videodev_lock);
1786 video_device[vfd->minor] = NULL; 1782 video_device[vfd->minor] = NULL;
@@ -1804,7 +1800,7 @@ void video_unregister_device(struct video_device *vfd)
1804 panic("videodev: bad unregister"); 1800 panic("videodev: bad unregister");
1805 1801
1806 video_device[vfd->minor]=NULL; 1802 video_device[vfd->minor]=NULL;
1807 class_device_unregister(&vfd->class_dev); 1803 device_unregister(&vfd->class_dev);
1808 mutex_unlock(&videodev_lock); 1804 mutex_unlock(&videodev_lock);
1809} 1805}
1810 1806