]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/proc.c
The first enhanced version of Linux CAN-bus driver for OCERA project
[lincan.git] / lincan / src / proc.c
index 401148e8fdd2a00bda59a4e793fd6c030ab9fabf..79309e0e35affbe900df17959b6da583c85438fe 100644 (file)
 #include <linux/modversions.h>
 #endif
 
+#include <linux/version.h>
 #include <linux/kernel.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
 #include <linux/malloc.h>
+#else
+#include <linux/slab.h>
+#endif
 #include <linux/proc_fs.h>
 #include <linux/version.h>
 
@@ -31,7 +36,7 @@ int remove_channel_from_procdir(void);
 int add_object_to_procdir(void);
 int remove_object_from_procdir(void);
 
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,2,19))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0))
 static int candev_readlink(struct proc_dir_entry *de, char *page);
 #endif
 
@@ -45,7 +50,7 @@ struct canproc_t *base=&can_proc_base;
 /* The following functions are needed only for kernel version 2.2. Kernel
  * version 2.4 already defines them for us.
  */
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,2,19))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0))
 static void can_fill_inode(struct inode *inode, int fill)
 {
        if (fill)
@@ -96,7 +101,7 @@ int can_remove_proc_entry(struct proc_dir_entry *del, struct proc_dir_entry *par
  */
 int can_init_procdir(void)
 {
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,2,19))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0))
        base->can_proc_entry = new_can_proc_entry(0, "can", S_IFDIR | S_IRUGO | 
                                        S_IXUGO, 0, &proc_root);
 #else
@@ -118,7 +123,7 @@ int can_delete_procdir(void)
 {
        if (remove_channel_from_procdir()) 
                return -ENODEV;
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,2,19))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0))
        if (can_remove_proc_entry(base->can_proc_entry, &proc_root)) 
                return -ENODEV;
 #else
@@ -144,7 +149,7 @@ int add_channel_to_procdir(void)
 
                sprintf(base->channel[cc]->ch_name, "channel%d",cc);
                                                
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,2,19))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0))
                base->channel[cc]->ch_entry = new_can_proc_entry(0, 
                                                base->channel[cc]->ch_name,
                                                S_IFDIR | S_IRUGO | S_IXUGO, 0, 
@@ -171,7 +176,7 @@ int remove_channel_from_procdir(void)
        
        while (cc != 0) {
                cc--;
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,2,19))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0))
                if (can_remove_proc_entry(base->channel[cc]->ch_entry,
                                                        base->can_proc_entry))
                        return -ENODEV;
@@ -210,7 +215,7 @@ int add_object_to_procdir(void)
                sprintf(base->channel[cc]->object[i]->obj_name,"object%d",i);
                sprintf(base->channel[cc]->object[i]->lnk_name,"dev");
                                                                
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,2,19))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0))
                base->channel[cc]->object[i]->obj_entry=new_can_proc_entry(
                                0, base->channel[cc]->object[i]->obj_name,
                                S_IFDIR | S_IRUGO | S_IXUGO, 0, 
@@ -258,7 +263,7 @@ int remove_object_from_procdir(void)
                obj=1;
 
        for (i=0; i<obj; i++) {
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,2,19))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0))
                if (can_remove_proc_entry( base->channel[cc]->object[i]->lnk,
                                base->channel[cc]->object[i]->obj_entry))       
                        return -ENODEV;
@@ -277,7 +282,7 @@ int remove_object_from_procdir(void)
        return 0;
 }
 
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,2,19))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0))
 static int candev_readlink(struct proc_dir_entry *de, char *page)
 {
        int i=0, nchip=0, nobj=0;