summaryrefslogtreecommitdiff
path: root/linux/drivers
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2008-07-17 18:45:00 +0200
committerHans Verkuil <hverkuil@xs4all.nl>2008-07-17 18:45:00 +0200
commitad2b972483262f7b5865dbfc824303de2c82b3aa (patch)
treef57077fd117283d8bd03d1fa93e38fd08de14c82 /linux/drivers
parent7b7b6e145e1bf05cdf3e5d82e8f30b288ad9e15a (diff)
downloadmediapointer-dvb-s2-ad2b972483262f7b5865dbfc824303de2c82b3aa.tar.gz
mediapointer-dvb-s2-ad2b972483262f7b5865dbfc824303de2c82b3aa.tar.bz2
videodev: add support for kernels < 2.6.19
From: Hans Verkuil <hverkuil@xs4all.nl> Add the necessary compatibility code to handle the struct device/struct class_device differences. It was too much work (with uncertain benefits) to convert several drivers to handle kernels <2.6.19, so they are not built on these older kernels. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Diffstat (limited to 'linux/drivers')
-rw-r--r--linux/drivers/media/video/videodev.c80
1 files changed, 68 insertions, 12 deletions
diff --git a/linux/drivers/media/video/videodev.c b/linux/drivers/media/video/videodev.c
index a3010740a..fa6f44fdb 100644
--- a/linux/drivers/media/video/videodev.c
+++ b/linux/drivers/media/video/videodev.c
@@ -376,6 +376,7 @@ EXPORT_SYMBOL(v4l_printk_ioctl);
* sysfs stuff
*/
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
static ssize_t show_index(struct device *cd,
struct device_attribute *attr, char *buf)
{
@@ -392,6 +393,30 @@ static ssize_t show_name(struct device *cd,
return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name);
}
+static struct device_attribute video_device_attrs[] = {
+ __ATTR(name, S_IRUGO, show_name, NULL),
+ __ATTR(index, S_IRUGO, show_index, NULL),
+ __ATTR_NULL
+};
+#else
+static ssize_t show_index(struct class_device *cd, char *buf)
+{
+ struct video_device *vfd = container_of(cd, struct video_device,
+ class_dev);
+ return sprintf(buf, "%i\n", vfd->index);
+}
+
+static ssize_t show_name(struct class_device *cd, char *buf)
+{
+ struct video_device *vfd = container_of(cd, struct video_device,
+ class_dev);
+ return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name);
+}
+
+static CLASS_DEVICE_ATTR(index, S_IRUGO, show_index, NULL);
+static CLASS_DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
+#endif
+
struct video_device *video_device_alloc(void)
{
struct video_device *vfd;
@@ -407,7 +432,11 @@ void video_device_release(struct video_device *vfd)
}
EXPORT_SYMBOL(video_device_release);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
+static void video_release(struct class_device *cd)
+#else
static void video_release(struct device *cd)
+#endif
{
struct video_device *vfd = container_of(cd, struct video_device,
class_dev);
@@ -420,16 +449,14 @@ static void video_release(struct device *cd)
vfd->release(vfd);
}
-static struct device_attribute video_device_attrs[] = {
- __ATTR(name, S_IRUGO, show_name, NULL),
- __ATTR(index, S_IRUGO, show_index, NULL),
- __ATTR_NULL
-};
-
static struct class video_class = {
.name = VIDEO_NAME,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
+ .release = video_release,
+#else
.dev_attrs = video_device_attrs,
.dev_release = video_release,
+#endif
};
/*
@@ -2188,8 +2215,7 @@ int video_register_device_index(struct video_device *vfd, int type, int nr,
ret = 0;
#endif
if (ret < 0) {
- printk(KERN_ERR "%s: get_index failed\n",
- __func__);
+ printk(KERN_ERR "%s: get_index failed\n", __func__);
goto fail_minor;
}
@@ -2200,17 +2226,43 @@ int video_register_device_index(struct video_device *vfd, int type, int nr,
/* sysfs class */
memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev));
- if (vfd->dev)
- vfd->class_dev.parent = vfd->dev;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
vfd->class_dev.class = &video_class;
vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
+ if (vfd->dev)
+ vfd->class_dev.dev = vfd->dev;
+ sprintf(vfd->class_dev.class_id, "%s%d", name_base, i - base);
+ ret = class_device_register(&vfd->class_dev);
+#else
+ if (vfd->dev)
+ vfd->class_dev.parent = vfd->dev;
sprintf(vfd->class_dev.bus_id, "%s%d", name_base, i - base);
ret = device_register(&vfd->class_dev);
+#endif
+ if (ret < 0) {
+ printk(KERN_ERR "%s: device_register failed\n", __func__);
+ goto fail_minor;
+ }
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
+ ret = class_device_create_file(&vfd->class_dev,
+ &class_device_attr_name);
if (ret < 0) {
- printk(KERN_ERR "%s: device_register failed\n",
- __func__);
+ printk(KERN_ERR "%s: class_device_create_file 'name' failed\n",
+ __func__);
+ class_device_unregister(&vfd->class_dev);
goto fail_minor;
}
+ ret = class_device_create_file(&vfd->class_dev,
+ &class_device_attr_index);
+ if (ret < 0) {
+ printk(KERN_ERR "%s: class_device_create_file 'index' failed\n",
+ __func__);
+ class_device_unregister(&vfd->class_dev);
+ goto fail_minor;
+ }
+#endif
#if 1 /* keep */
/* needed until all drivers are fixed */
@@ -2245,7 +2297,11 @@ void video_unregister_device(struct video_device *vfd)
panic("videodev: bad unregister");
video_device[vfd->minor]=NULL;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
+ class_device_unregister(&vfd->class_dev);
+#else
device_unregister(&vfd->class_dev);
+#endif
mutex_unlock(&videodev_lock);
}
EXPORT_SYMBOL(video_unregister_device);