10 #endif /*CAN_WITH_RTL*/
12 /*#define __NO_VERSION__*/
13 /*#include <linux/module.h>*/
15 #include <linux/version.h>
16 #include <linux/wait.h>
17 #include <linux/list.h>
19 #include <linux/ioport.h>
20 #include <linux/delay.h>
21 #include <linux/sched.h>
22 #include <linux/interrupt.h>
23 #include <asm/errno.h>
26 #include <asm/atomic.h>
28 #include <asm/uaccess.h>
30 #include "lincan_config.h"
33 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))
34 #define CAN_ENABLE_KERN_FASYNC
36 #define CAN_ENABLE_PCI_SUPPORT
38 #ifdef CONFIG_OC_LINCANVME
39 #define CAN_ENABLE_VME_SUPPORT
43 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
44 #include <linux/malloc.h>
46 #include <linux/slab.h>
49 #ifdef CAN_ENABLE_PCI_SUPPORT
50 #include "linux/pci.h"
51 #endif /*CAN_ENABLE_PCI_SUPPORT*/
53 /* Next is not sctrictly correct, because of 2.3.0, 2.3.1, 2.3.2
54 kernels need next definitions too */
55 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,19)) /* may need correction */
56 #define wait_queue_head_t struct wait_queue *
57 #define wait_queue_t struct wait_queue
58 #define init_waitqueue_head(queue_head) (*queue_head=NULL)
59 #define init_waitqueue_entry(qentry,qtask) \
60 (qentry->next=NULL,qentry->task=qtask)
61 #define DECLARE_WAIT_QUEUE_HEAD(name) \
62 struct wait_queue * name=NULL
63 #define DECLARE_WAITQUEUE(wait, current) \
64 struct wait_queue wait = { current, NULL }
65 #define init_MUTEX(sem) (*sem=MUTEX)
66 #define DECLARE_MUTEX(name) struct semaphore name=MUTEX
69 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)) && !defined(DECLARE_TASKLET)
70 #define tasklet_struct tq_struct
71 #define DECLARE_TASKLET(_name, _func, _data) \
72 struct tq_struct _name = { sync: 0, routine: _func, data: (void*)_data }
74 /* void tasklet_init(struct tasklet_struct *t, void (*func)(unsigned long), unsigned long data); */
75 #define tasklet_init(_tasklet, _func, _data) \
77 /* (_tasklet)->next=NULL; */ \
78 /* Above not needed for 2.2.x and buggy for 2.4.x */ \
80 (_tasklet)->routine=_func; \
81 (_tasklet)->data=(void*)_data; \
84 /* void tasklet_schedule(struct tasklet_struct *t) */
85 #define tasklet_schedule(_tasklet) \
87 queue_task(_tasklet,&tq_immediate); \
88 mark_bh(IMMEDIATE_BH); \
91 /* void tasklet_kill(struct tasklet_struct *t); */
92 #define tasklet_kill(_tasklet) \
98 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,7)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
101 (MINOR(file->f_dentry->d_inode->i_rdev))
103 #else /* Linux kernel < 2.5.7 or >= 2.6.0 */
106 (minor(file->f_dentry->d_inode->i_rdev))
108 #endif /* Linux kernel < 2.5.7 or >= 2.6.0 */
111 #if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68)) && !defined(IRQ_RETVAL))
112 typedef void can_irqreturn_t;
114 #define CAN_IRQ_HANDLED
115 #define CAN_IRQ_RETVAL(x)
117 typedef irqreturn_t can_irqreturn_t;
118 #define CAN_IRQ_NONE IRQ_NONE
119 #define CAN_IRQ_HANDLED IRQ_HANDLED
120 #define CAN_IRQ_RETVAL IRQ_RETVAL
121 #endif /* <=2.5.67 */
122 #else /*CAN_WITH_RTL*/
123 typedef int can_irqreturn_t;
124 #define CAN_IRQ_NONE 0
125 #define CAN_IRQ_HANDLED 1
126 #define CAN_IRQ_RETVAL(x) ((x) != 0)
127 #endif /*CAN_WITH_RTL*/
129 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,33))
130 #define can_synchronize_irq(irqnum) synchronize_irq()
132 #define can_synchronize_irq synchronize_irq
135 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
136 #define del_timer_sync del_timer
140 /* Standard LINUX kernel */
142 #define can_spinlock_t spinlock_t
143 #define can_spin_irqflags_t unsigned long
144 #define can_spin_lock spin_lock
145 #define can_spin_unlock spin_unlock
146 #define can_spin_lock_irqsave spin_lock_irqsave
147 #define can_spin_unlock_irqrestore spin_unlock_irqrestore
148 #define can_spin_lock_init spin_lock_init
150 #if defined(CONFIG_PREEMPT) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
151 #define can_preempt_disable preempt_disable
152 #define can_preempt_enable preempt_enable
153 #else /*CONFIG_PREEMPT*/
154 #define can_preempt_disable() do { } while (0)
155 #define can_preempt_enable() do { } while (0)
156 #endif /*CONFIG_PREEMPT*/
158 #define can_enable_irq enable_irq
159 #define can_disable_irq disable_irq
161 #define can_printk printk
163 #else /*CAN_WITH_RTL*/
165 #define can_spinlock_t rtl_spinlock_t
166 #define can_spin_irqflags_t rtl_irqstate_t
167 #define can_spin_lock rtl_spin_lock
168 #define can_spin_unlock rtl_spin_unlock
169 #define can_spin_lock_irqsave rtl_spin_lock_irqsave
170 #define can_spin_unlock_irqrestore rtl_spin_unlock_irqrestore
171 #define can_spin_lock_init rtl_spin_lock_init
173 #define can_preempt_disable() do { } while (0)
174 #define can_preempt_enable() do { } while (0)
176 #define can_enable_irq rtl_hard_enable_irq
177 #define can_disable_irq rtl_hard_disable_irq
179 #define can_printk rtl_printf
182 * terrible hack to test rtl_file private_data concept, ugh !!!
183 * this would result in crash on architectures, where
184 * sizeof(int) < sizeof(void *)
186 #define can_set_rtl_file_private_data(fptr, p) do{ fptr->f_minor=(long)(p); } while(0)
187 #define can_get_rtl_file_private_data(fptr) ((void*)((fptr)->f_minor))
189 extern can_spinlock_t can_irq_manipulation_lock;
191 #endif /*CAN_WITH_RTL*/
193 #endif /*_CAN_SYSDEP_H*/