]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/main.c
Updates to compile with 2.6.26 Linux kernel.
[lincan.git] / lincan / src / main.c
index 274d5739b2e01f66827b586b5cb3ef3ed6acb7c8..7e8181f3e264affa523d1772158b7ef7dbb314e1 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);
@@ -384,11 +390,8 @@ int init_module(void)
                canqueue_rtl_done();
                #endif /*CAN_WITH_RTL*/
 
-               res=unregister_chrdev(major,DEVICE_NAME);
-               if (res<0)
-                       CANMSG("Error unloading CAN driver, error: %d\n",res);
-               else
-                       CANMSG("No CAN devices or driver setup error.\n");
+               unregister_chrdev(major,DEVICE_NAME);
+               CANMSG("No CAN devices or driver setup error.\n");
 
        register_error:
                if ( can_del_mem_list() ) 
@@ -399,7 +402,9 @@ int init_module(void)
 
 void cleanup_module(void)
 {
-       int res=0,i=0;
+#if defined(CONFIG_DEVFS_FS) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
+       int i=0;
+#endif
 
 #ifdef CONFIG_PROC_FS
        if (can_delete_procdir())
@@ -419,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
                }
@@ -439,7 +448,5 @@ void cleanup_module(void)
        if ( can_del_mem_list() ) 
                CANMSG("Error deallocating memory\n");
 
-       res=unregister_chrdev(major,DEVICE_NAME);
-       if (res<0)
-               CANMSG("Error unregistering CAN driver, error: %d\n",res);
+       unregister_chrdev(major,DEVICE_NAME);
 }