From 4dc78b4651f006bf0404c8ec7db85651bcee7c2e Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Sat, 1 Oct 2011 18:28:56 +0200 Subject: [PATCH] Adjust LinCAN sources to compile for 3.x Linux kernel. Signed-off-by: Pavel Pisa --- lincan/include/ioctl.h | 2 +- lincan/src/ioctl.c | 2 +- lincan/src/kthread.c | 4 +++- lincan/src/main.c | 13 ++++++++++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lincan/include/ioctl.h b/lincan/include/ioctl.h index 4318758..90f3e7d 100644 --- a/lincan/include/ioctl.h +++ b/lincan/include/ioctl.h @@ -32,7 +32,7 @@ /* Publication of enhanced or derived LinCAN files is required although. */ /**************************************************************************/ -int can_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); +long can_ioctl(struct file *file, unsigned int cmd, unsigned long arg); int can_ioctl_query(struct canuser_t *canuser, unsigned long what); int can_ioctl_remote_read(struct canuser_t *canuser, struct canmsg_t *rtr_msg, unsigned long rtr_id, int options); diff --git a/lincan/src/ioctl.c b/lincan/src/ioctl.c index 2d410f1..e6dee36 100644 --- a/lincan/src/ioctl.c +++ b/lincan/src/ioctl.c @@ -37,7 +37,7 @@ #include "../include/main.h" #include "../include/ioctl.h" -int can_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) +long can_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int i=0; unsigned short channel=0; diff --git a/lincan/src/kthread.c b/lincan/src/kthread.c index a1563ce..d92a1a9 100644 --- a/lincan/src/kthread.c +++ b/lincan/src/kthread.c @@ -27,7 +27,9 @@ #include #endif -#include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) + #include +#endif #include "../include/kthread.h" diff --git a/lincan/src/main.c b/lincan/src/main.c index 5cc522e..c2c8b1e 100644 --- a/lincan/src/main.c +++ b/lincan/src/main.c @@ -200,6 +200,13 @@ devfs_handle_t devfs_handles[MAX_TOT_MSGOBJS]; #endif #endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) +static int can_oldapi_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) +{ + return can_ioctl(file, cmd, arg); +} +#endif /* 2.6.36 */ + /* Pointers to dynamically allocated memory are maintained in a linked list * to ease memory deallocation. */ @@ -213,7 +220,11 @@ struct file_operations can_fops= read: can_read, write: can_write, poll: can_poll, - ioctl: can_ioctl, + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) + ioctl: can_oldapi_ioctl, + #else /* Linux 3.x */ + unlocked_ioctl: can_ioctl, + #endif /* Linux 3.x */ open: can_open, release: can_close, #ifdef CAN_ENABLE_KERN_FASYNC -- 2.39.2