changeset 11:b904131a3807

Allow to build with kernel 2.6.27.git and 2.6.28-rc9
author AngelCarpintero
date Mon, 22 Dec 2008 04:32:52 +0000
parents bce647a9dd4b
children bc21025dcf6d
files Makefile vloopback.c
diffstat 2 files changed, 51 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Mon Oct 13 00:26:10 2008 +0000
+++ b/Makefile	Mon Dec 22 04:32:52 2008 +0000
@@ -29,6 +29,12 @@
 all: 
 	$(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules
 
+
+current: clean svn all
+
+svn:
+	svn update
+
 install:
 	install -d $(DEST)
 	install -m 644 -c $(MODULENAME).ko $(DEST)
--- a/vloopback.c	Mon Oct 13 00:26:10 2008 +0000
+++ b/vloopback.c	Mon Dec 22 04:32:52 2008 +0000
@@ -146,9 +146,12 @@
  *            Added compat_iotcl32 init in fopsl, replace tabs by 4 spaces in source code,
  *            add number of buffers as module param.
  *
- * 13.10.09    (Stephan Berberig & Angel Carpintero)
+ * 13.10.08    (Stephan Berberig & Angel Carpintero)
  *            Release to work on 2.6.27 , allow v4l_compat_ioctl32 work in 2.6.27 and a little cleanup 
  *            in Makefile.
+ *
+ * 22.12.08    (Angel Carpintero)
+ *            Allow build with kernel 2.6.28 and 2.6.27.git ( struct video_dev has not priv member anymore).          
  */
 
 
@@ -170,6 +173,12 @@
  #include <media/v4l2-ioctl.h>
 #endif
 
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)
+ #define vd_private_data dev.driver_data
+#else
+ #define vd_private_data priv
+#endif
+
 #include <linux/videodev.h>
 #include <linux/vmalloc.h>
 #include <linux/wait.h>
@@ -222,7 +231,7 @@
 
 struct vloopback_pipe {
     struct video_device *vloopin;
-     struct video_device *vloopout;
+    struct video_device *vloopout;
     char *buffer;
     unsigned long buflength;
     unsigned int width, height;
@@ -370,7 +379,8 @@
 static int vloopback_open(struct inode *inod, struct file *f)
 {    
     struct video_device *loopdev = video_devdata(f);
-    priv_ptr ptr = (priv_ptr)loopdev->priv;
+    priv_ptr ptr = (priv_ptr)loopdev->vd_private_data; 
+    //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev);
     int nr = ptr->pipenr;
 
     if (debug > LOG_NODEBUG)
@@ -423,7 +433,8 @@
 static int vloopback_release(struct inode * inod, struct file *f)
 {
     struct video_device *loopdev = video_devdata(f);
-    priv_ptr ptr = (priv_ptr)loopdev->priv;
+    priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
+    //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev);
     int nr = ptr->pipenr;
 
     if (debug > LOG_NODEBUG)
@@ -476,7 +487,8 @@
                size_t count, loff_t *offset)
 {
     struct video_device *loopdev = video_devdata(f);
-    priv_ptr ptr = (priv_ptr)loopdev->priv;
+    priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
+    //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev);
     int nr = ptr->pipenr;
     unsigned long realcount = count;
 
@@ -527,7 +539,8 @@
                loff_t *offset)
 {
     struct video_device *loopdev = video_devdata(f);
-    priv_ptr ptr = (priv_ptr)loopdev->priv;
+    priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
+    //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev);
     int nr = ptr->pipenr;
     unsigned long realcount = count;
 
@@ -609,7 +622,8 @@
 static int vloopback_mmap(struct file *f, struct vm_area_struct *vma)
 {
     struct video_device *loopdev = video_devdata(f);
-    priv_ptr ptr = (priv_ptr)loopdev->priv;
+    priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
+    //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev);
     int nr = ptr->pipenr;
     unsigned long start = (unsigned long)vma->vm_start;
     long size = vma->vm_end - vma->vm_start;
@@ -681,7 +695,8 @@
            unsigned long arg)
 {
     struct video_device *loopdev = video_devdata(f);
-    priv_ptr ptr = (priv_ptr)loopdev->priv;
+    priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
+    //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev);
     int nr = ptr->pipenr;
     int i;
 
@@ -1077,7 +1092,8 @@
 static unsigned int vloopback_poll(struct file *f, struct poll_table_struct *wait)
 {
     struct video_device *loopdev = video_devdata(f);
-    priv_ptr ptr = (priv_ptr)loopdev->priv;
+    priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
+    //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev);
     int nr = ptr->pipenr;
 
     if (debug > LOG_NODEBUG)
@@ -1153,9 +1169,11 @@
     if (loops[nr]->vloopin == NULL)
         return -ENOMEM;
     *loops[nr]->vloopin = vloopback_template;
-    loops[nr]->vloopin->priv = kmalloc(sizeof(struct vloopback_private),
-                                       GFP_KERNEL);
-    if (loops[nr]->vloopin->priv == NULL) {
+
+    loops[nr]->vloopin->vd_private_data = kmalloc(sizeof(struct vloopback_private),
+                                                  GFP_KERNEL);
+
+    if (loops[nr]->vloopin->vd_private_data == NULL) {
         kfree(loops[nr]->vloopin);
         return -ENOMEM;
     }
@@ -1163,23 +1181,23 @@
     loops[nr]->vloopout = video_device_alloc();
 
     if (loops[nr]->vloopout == NULL) {
-        kfree(loops[nr]->vloopin->priv);
+        kfree(loops[nr]->vloopin->vd_private_data);
         kfree(loops[nr]->vloopin);
         return -ENOMEM;
     }
     *loops[nr]->vloopout = vloopback_template;
-    loops[nr]->vloopout->priv = kmalloc(sizeof(struct vloopback_private),
-                                        GFP_KERNEL);
+    loops[nr]->vloopout->vd_private_data = kmalloc(sizeof(struct vloopback_private),
+                                                   GFP_KERNEL);
 
-    if (loops[nr]->vloopout->priv == NULL) {
-        kfree(loops[nr]->vloopin->priv);
+    if (loops[nr]->vloopout->vd_private_data == NULL) {
+        kfree(loops[nr]->vloopin->vd_private_data);
         kfree(loops[nr]->vloopin);
         kfree(loops[nr]->vloopout);
         return -ENOMEM;
     }
 
-    ((priv_ptr)loops[nr]->vloopin->priv)->pipenr = nr;
-    ((priv_ptr)loops[nr]->vloopout->priv)->pipenr = nr;
+    ((priv_ptr)loops[nr]->vloopin->vd_private_data)->pipenr = nr;
+    ((priv_ptr)loops[nr]->vloopout->vd_private_data)->pipenr = nr;
     loops[nr]->invalid_ioctl = 0; /* tibit */
     loops[nr]->buffer = NULL;
     loops[nr]->width = 0;
@@ -1192,8 +1210,8 @@
     loops[nr]->ropen = 0;
     loops[nr]->frame = 0;
     
-    ((priv_ptr)loops[nr]->vloopin->priv)->in = 1;
-    ((priv_ptr)loops[nr]->vloopout->priv)->in = 0;
+    ((priv_ptr)loops[nr]->vloopin->vd_private_data)->in = 1;
+    ((priv_ptr)loops[nr]->vloopout->vd_private_data)->in = 0;
     sprintf(loops[nr]->vloopin->name, "Video loopback %d input", nr);
     sprintf(loops[nr]->vloopout->name, "Video loopback %d output", nr);
 
@@ -1211,9 +1229,9 @@
     
     if ((ret == -1 ) || ( ret == -23 )) {
         info("error registering device %s", loops[nr]->vloopin->name);
-        kfree(loops[nr]->vloopin->priv);
+        kfree(loops[nr]->vloopin->vd_private_data);
         kfree(loops[nr]->vloopin);
-        kfree(loops[nr]->vloopout->priv);
+        kfree(loops[nr]->vloopout->vd_private_data);
         kfree(loops[nr]->vloopout);
         kfree(loops[nr]);
         loops[nr] = NULL;
@@ -1224,9 +1242,9 @@
     
     if ((ret ==-1) || (ret == -23)) {
         info("error registering device %s", loops[nr]->vloopout->name);
-        kfree(loops[nr]->vloopin->priv);
+        kfree(loops[nr]->vloopin->vd_private_data);
         video_unregister_device(loops[nr]->vloopin);
-        kfree(loops[nr]->vloopout->priv);
+        kfree(loops[nr]->vloopout->vd_private_data);
         kfree(loops[nr]->vloopout);
         kfree(loops[nr]);
         loops[nr] = NULL;
@@ -1337,9 +1355,9 @@
 
     for (i = 0; i < nr_o_pipes; i++) {
         if (loops[i]) {
-            kfree(loops[i]->vloopin->priv);
+            kfree(loops[i]->vloopin->vd_private_data);
             video_unregister_device(loops[i]->vloopin);
-            kfree(loops[i]->vloopout->priv);
+            kfree(loops[i]->vloopout->vd_private_data);
             video_unregister_device(loops[i]->vloopout);
             
             if (loops[i]->buffer)