summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/videodev.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drivers/media/video/videodev.c')
-rw-r--r--linux/drivers/media/video/videodev.c58
1 files changed, 46 insertions, 12 deletions
diff --git a/linux/drivers/media/video/videodev.c b/linux/drivers/media/video/videodev.c
index 7bf527c59..f1ef7431f 100644
--- a/linux/drivers/media/video/videodev.c
+++ b/linux/drivers/media/video/videodev.c
@@ -58,14 +58,17 @@
* sysfs stuff
*/
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
static ssize_t show_name(struct class_device *cd, char *buf)
+#else
+static ssize_t show_name(struct device *cd,
+ struct device_attribute *attr, char *buf)
+#endif
{
struct video_device *vfd = container_of(cd, struct video_device,
- class_dev);
- return sprintf(buf,"%.*s\n",(int)sizeof(vfd->name),vfd->name);
+ class_dev);
+ return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name);
}
-
-static CLASS_DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
static ssize_t show_dev(struct class_device *cd, char *buf)
{
@@ -75,7 +78,7 @@ static ssize_t show_dev(struct class_device *cd, char *buf)
return print_dev_t(buf,dev);
}
-static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);
+static DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);
#endif
struct video_device *video_device_alloc(void)
@@ -91,10 +94,18 @@ void video_device_release(struct video_device *vfd)
kfree(vfd);
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
static void video_release(struct class_device *cd)
+#else
+static void video_release(struct device *cd)
+#endif
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
struct video_device *vfd = container_of(cd, struct video_device,
class_dev);
+#else
+ struct video_device *vfd = container_of(cd, struct video_device, class_dev);
+#endif
#if 1 /* keep */
/* needed until all drivers are fixed */
@@ -104,9 +115,21 @@ static void video_release(struct class_device *cd)
vfd->release(vfd);
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
+static struct device_attribute video_device_attrs[] = {
+ __ATTR(name, S_IRUGO, show_name, NULL),
+ __ATTR_NULL
+};
+#endif
+
static struct class video_class = {
.name = VIDEO_NAME,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
.release = video_release,
+#else
+ .dev_attrs = video_device_attrs,
+ .dev_release = video_release,
+#endif
};
/*
@@ -1775,31 +1798,44 @@ int video_register_device(struct video_device *vfd, int type, int nr)
/* sysfs class */
memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev));
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
if (vfd->dev)
vfd->class_dev.dev = vfd->dev;
+#else
+ if (vfd->dev)
+ vfd->class_dev.parent = vfd->dev;
+#endif
vfd->class_dev.class = &video_class;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
sprintf(vfd->class_dev.class_id, "%s%d", name_base, i - base);
- ret = class_device_register(&vfd->class_dev);
+#else
+ sprintf(vfd->class_dev.bus_id, "%s%d", name_base, i - base);
+#endif
+ ret = device_register(&vfd->class_dev);
if (ret < 0) {
- printk(KERN_ERR "%s: class_device_register failed\n",
+ printk(KERN_ERR "%s: device_register failed\n",
__FUNCTION__);
goto fail_minor;
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
ret = class_device_create_file(&vfd->class_dev, &class_device_attr_name);
if (ret < 0) {
printk(KERN_ERR "%s: class_device_create_file 'name' failed\n",
__FUNCTION__);
- goto fail_classdev;
+ class_device_unregister(&vfd->class_dev);
+ goto fail_minor;
}
+#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
ret = class_device_create_file(&vfd->class_dev, &class_device_attr_dev);
if (ret < 0) {
printk(KERN_ERR "%s: class_device_create_file 'dev' failed\n",
__FUNCTION__);
- goto fail_classdev;
+ class_device_unregister(&vfd->class_dev);
+ goto fail_minor;
}
#endif
@@ -1812,8 +1848,6 @@ int video_register_device(struct video_device *vfd, int type, int nr)
#endif
return 0;
-fail_classdev:
- class_device_unregister(&vfd->class_dev);
fail_minor:
mutex_lock(&videodev_lock);
video_device[vfd->minor] = NULL;
@@ -1837,7 +1871,7 @@ void video_unregister_device(struct video_device *vfd)
panic("videodev: bad unregister");
video_device[vfd->minor]=NULL;
- class_device_unregister(&vfd->class_dev);
+ device_unregister(&vfd->class_dev);
mutex_unlock(&videodev_lock);
}