Updates to compile with 2.6.26 Linux kernel.
authorppisa <ppisa>
Thu, 17 Jul 2008 00:50:45 +0000 (00:50 +0000)
committerppisa <ppisa>
Thu, 17 Jul 2008 00:50:45 +0000 (00:50 +0000)
lincan/src/m437.c
lincan/src/main.c
lincan/src/proc.c

index 00ac7c3..f72943a 100644 (file)
@@ -71,8 +71,10 @@ int m437_request_io(struct candevice_t *candev)
                return -ENODEV;
 
        }
-       CANMSG("M437 Registered IO-memory: 0x%lx - 0x%lx\n", candev->io_addr, candev->io_addr + IO_RANGE - 1);
-       CANMSG("M437 IO-memory: 0x%lx  Remapped to: 0x%lx\n", candev->io_addr, remap_addr);
+       CANMSG("M437 Registered IO-memory: 0x%lx - 0x%lx\n",
+               candev->io_addr, candev->io_addr + IO_RANGE - 1);
+       CANMSG("M437 IO-memory: 0x%lx  Remapped to: 0x%lx\n",
+               (unsigned long)candev->io_addr, (unsigned long)remap_addr);
 
        /* remap the chip and pointers on objects */
        can_base_addr_fixup(candev, remap_addr);
index e021761..7e8181f 100644 (file)
@@ -324,8 +324,10 @@ int init_module(void)
         {
            #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0))
                char dev_name[32];
-           #else
+           #elif  LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25) /* >= 2.6.15 */
                struct class_device *this_dev;
+           #else
+               struct device *this_dev;
            #endif
                int dev_minor;
                for(i=0;i<MAX_TOT_MSGOBJS;i++) {
@@ -340,14 +342,18 @@ int init_module(void)
                    #else
                      #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,14))
                        this_dev=class_device_create(can_class, MKDEV(major, dev_minor), NULL,  "can%d", dev_minor);
-                     #else /* >= 2.6.15 */
+                     #elif  LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25) /* >= 2.6.15 */
                        this_dev=class_device_create(can_class, NULL, MKDEV(major, dev_minor), NULL,  "can%d", dev_minor);
-                     #endif /* >= 2.6.15 */
+                     #else /* >= 2.6.26 */
+                       this_dev=device_create_drvdata(can_class, NULL, MKDEV(major, dev_minor), objects_p[i],  "can%d", dev_minor);
+                     #endif /* >= 2.6.26 */
                        if(IS_ERR(this_dev)){
                                CANMSG("problem to create device \"can%d\" in the class \"can\"\n", dev_minor);
+                     #if  LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
                        }else{
                                /*this_dev->class_data=objects_p[i];*/
                                class_set_devdata(this_dev,objects_p[i]);
+                     #endif /* <= 2.6.25 */
                        }
                      #ifdef CONFIG_DEVFS_FS
                        devfs_mk_cdev(MKDEV(major, dev_minor), S_IFCHR | S_IRUGO | S_IWUGO, "can%d", dev_minor);
@@ -418,7 +424,11 @@ void cleanup_module(void)
                    #ifdef CONFIG_DEVFS_FS
                        devfs_remove("can%d", dev_minor);
                    #endif
+                   #if  LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
                        class_device_destroy(can_class, MKDEV(major, dev_minor));
+                   #else /* >= 2.6.26 */
+                       device_destroy(can_class, MKDEV(major, dev_minor));
+                   #endif /* >= 2.6.26 */
                }
            #endif
                }
index 98fbb80..a851830 100644 (file)
@@ -25,6 +25,12 @@ int remove_object_from_procdir(int chip_nr);
 static int can_proc_readlink(struct proc_dir_entry *ent, char *page);
 #endif
 
+#if  LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
+#define CAN_PROC_ROOT (&proc_root)
+#else /* >= 2.6.26 */
+#define CAN_PROC_ROOT (NULL)
+#endif /* >= 2.6.26 */
+
 static int cc=0; /* static counter for each CAN chip */
 
 static struct canproc_t can_proc_base;
@@ -150,7 +156,7 @@ int can_init_procdir(void)
        int board;
        struct candevice_t *candev;
        base->can_proc_entry = can_create_proc_entry("can", S_IFDIR | S_IRUGO | 
-                                       S_IXUGO, &proc_root);
+                                       S_IXUGO, CAN_PROC_ROOT);
        if (base->can_proc_entry == NULL)
                return -ENODEV;
 
@@ -168,7 +174,7 @@ int can_delete_procdir(void)
        if (remove_channel_from_procdir()) 
                return -ENODEV;
        /* name: "can" */
-       if (can_remove_proc_entry(base->can_proc_entry, &proc_root)) 
+       if (can_remove_proc_entry(base->can_proc_entry, CAN_PROC_ROOT)) 
                return -ENODEV;
 
        return 0;