]> rtime.felk.cvut.cz Git - lincan.git/commitdiff
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 00ac7c3ea9b43bec2fed349120675c29c248be38..f72943a4516bebc7134eb2904cd5efb1aa05dd65 100644 (file)
@@ -71,8 +71,10 @@ int m437_request_io(struct candevice_t *candev)
                return -ENODEV;
 
        }
                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);
 
        /* remap the chip and pointers on objects */
        can_base_addr_fixup(candev, remap_addr);
index e0217619d886f333eb8d5b63c1b2ca8ca17840fd..7e8181f3e264affa523d1772158b7ef7dbb314e1 100644 (file)
@@ -324,8 +324,10 @@ int init_module(void)
         {
            #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0))
                char dev_name[32];
         {
            #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;
                struct class_device *this_dev;
+           #else
+               struct device *this_dev;
            #endif
                int dev_minor;
                for(i=0;i<MAX_TOT_MSGOBJS;i++) {
            #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
                      #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);
                        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(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]);
                        }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);
                        }
                      #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
                    #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));
                        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
                }
                }
            #endif
                }
index 98fbb80716f576d397094a354130410efc847482..a85183091047a6d11aac40ee9b660da7cbb28583 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
 
 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;
 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 | 
        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;
 
        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 (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;
                return -ENODEV;
 
        return 0;