+
+
+static int can_proc_readlink(struct proc_dir_entry *ent, char *page)
+{
+ char *link_dest = (char*)ent->data;
+
+ strcpy(page, link_dest);
+ return strlen(link_dest);
+}
+
+
+
+/* This compatibility version of proc_symlink does not store local copy of destination */
+static inline struct proc_dir_entry *can_proc_symlink(const char *name,
+ struct proc_dir_entry *parent, const char *dest)
+{
+ struct proc_dir_entry *entry;
+
+
+ entry = can_create_proc_entry(name, S_IFLNK | S_IRUGO | S_IWUGO | S_IXUGO, parent);
+ if (entry == NULL)
+ return NULL;
+ entry->readlink_proc = can_proc_readlink;
+ entry->data = dest;
+ return entry;
+}
+
+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
+
+struct proc_dir_entry *can_create_proc_read_entry(const char *name,
+ mode_t mode, struct proc_dir_entry *parent,
+ read_proc_t *read_proc, void * data)
+{
+ return create_proc_read_entry(name, mode, parent, read_proc, data);
+}
+
+struct proc_dir_entry *can_proc_mkdir_mode(const char *name, umode_t mode,
+ struct proc_dir_entry *parent)
+{
+ return create_proc_entry(name, S_IFDIR | mode, parent);
+}
+
+/* This does not fully follow linux 2.4 and 2.6 prototype to simplify 2.2.x compatibility */
+/* The newer kernels use entry name instead of pointer to the entry */
+static int can_proc_remove(struct proc_dir_entry *del)
+{
+ if(!del) return -ENODEV;
+ remove_proc_entry(del->name, del->parent);
+ return 0;
+}
+
+static inline struct proc_dir_entry *can_proc_symlink(const char *name,
+ struct proc_dir_entry *parent, const char *dest)
+{
+ return proc_symlink(name, parent, dest);
+}
+
+#else /* Linux kernel 3.10+ */
+
+#include <linux/seq_file.h>
+
+static int can_status_proc_show(struct seq_file *m, void *v)
+{
+ seq_printf(m, "dummy CAN can_create_proc_read_entry implementation\n");
+ return 0;
+}
+
+static int can_status_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, can_status_proc_show, PDE_DATA(inode));
+}
+
+static const struct file_operations can_status_proc_fops = {
+ .owner = THIS_MODULE,
+ .open = can_status_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+struct proc_dir_entry *can_create_proc_read_entry(const char *name,
+ mode_t mode, struct proc_dir_entry *parent,
+ void *read_proc, void * data)
+{
+ /*return proc_read_entry(name, mode, parent, read_proc, data);*/
+ return proc_create_data(name, mode, parent, &can_status_proc_fops, data);
+}
+
+struct proc_dir_entry *can_proc_mkdir_mode(const char *name, umode_t mode,
+ struct proc_dir_entry *parent)
+{
+ return proc_mkdir_mode(name, mode, parent);
+}
+
+static int can_proc_remove(struct proc_dir_entry *del)
+{
+ if(!del) return -ENODEV;
+ proc_remove(del);
+ return 0;
+}
+
+static inline struct proc_dir_entry *can_proc_symlink(const char *name,
+ struct proc_dir_entry *parent, const char *dest)
+{
+ return proc_symlink(name, parent, dest);
+}
+
+#endif /* Functions required for kernel 2.2 */