]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/main.c
Fixes for SMP kernels and build for 2.2.xx and 2.6.xx kernels
[lincan.git] / lincan / src / main.c
index d04c39cf2520b4b6bd65151bf69ce453e3e98ae8..d52cabf469702c79f0e82f94a04d4f4c393dc246 100644 (file)
@@ -41,6 +41,7 @@
 /*#undef CONFIG_DEVFS_FS*/
 
 #ifdef CONFIG_DEVFS_FS
+#include <linux/devfs_fs_kernel.h>
 #include <linux/miscdevice.h>
 #endif
 
@@ -101,8 +102,10 @@ struct canhardware_t *hardware_p=&canhardware;
 struct chip_t *chips_p[MAX_TOT_CHIPS];
 struct msgobj_t *objects_p[MAX_TOT_MSGOBJS];
 #ifdef CONFIG_DEVFS_FS
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,60))
 devfs_handle_t  devfs_handles[MAX_TOT_MSGOBJS];
 #endif
+#endif
 
 /* Pointers to dynamically allocated memory are maintained in a linked list
  * to ease memory deallocation.
@@ -205,11 +208,15 @@ int init_module(void)
                for(i=0;i<MAX_TOT_MSGOBJS;i++) {
                        if(!objects_p[i]) continue;
                        dev_minor=objects_p[i]->minor;
+                   #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,50))
                        sprintf (dev_name, "can%d", dev_minor);
                        devfs_handles[i]=devfs_register(NULL, dev_name,
                                DEVFS_FL_DEFAULT, major, dev_minor,
                                S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
                                &can_fops, (void*)objects_p[i]);
+                   #else
+                       devfs_mk_cdev(MKDEV(major, dev_minor), S_IFCHR | S_IRUGO | S_IWUGO, "can%d", dev_minor);
+                   #endif
                }
         }
 #endif
@@ -257,8 +264,16 @@ void cleanup_module(void)
 
 #ifdef CONFIG_DEVFS_FS
                for(i=0;i<MAX_TOT_MSGOBJS;i++) {
+           #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,50))
                        if(devfs_handles[i])
                                devfs_unregister(devfs_handles[i]);
+           #else
+               int dev_minor;
+                       if(!objects_p[i]) continue;
+                       dev_minor=objects_p[i]->minor;
+               if(minor>=0)
+                       devfs_remove("can%d", dev_minor);
+           #endif
                }
 #endif
         i=0;