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>
31 #define CAN_ENABLE_KERN_FASYNC
32 #define CAN_ENABLE_PCI_SUPPORT
34 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
35 #include <linux/malloc.h>
37 #include <linux/slab.h>
40 #ifdef CAN_ENABLE_PCI_SUPPORT
41 #include "linux/pci.h"
42 #endif /*CAN_ENABLE_PCI_SUPPORT*/
44 /* Next is not sctrictly correct, because of 2.3.0, 2.3.1, 2.3.2
45 kernels need next definitions too */
46 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,19)) /* may need correction */
47 #define wait_queue_head_t struct wait_queue *
48 #define wait_queue_t struct wait_queue
49 #define init_waitqueue_head(queue_head) (*queue_head=NULL)
50 #define init_waitqueue_entry(qentry,qtask) \
51 (qentry->next=NULL,qentry->task=qtask)
52 #define DECLARE_WAIT_QUEUE_HEAD(name) \
53 struct wait_queue * name=NULL
54 #define DECLARE_WAITQUEUE(wait, current) \
55 struct wait_queue wait = { current, NULL }
56 #define init_MUTEX(sem) (*sem=MUTEX)
57 #define DECLARE_MUTEX(name) struct semaphore name=MUTEX
61 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,7)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
64 (MINOR(file->f_dentry->d_inode->i_rdev))
66 #else /* Linux kernel < 2.5.7 or >= 2.6.0 */
69 (minor(file->f_dentry->d_inode->i_rdev))
71 #endif /* Linux kernel < 2.5.7 or >= 2.6.0 */
74 #if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68)) && !defined(IRQ_RETVAL))
75 typedef void can_irqreturn_t;
77 #define CAN_IRQ_HANDLED
78 #define CAN_IRQ_RETVAL(x)
80 typedef irqreturn_t can_irqreturn_t;
81 #define CAN_IRQ_NONE IRQ_NONE
82 #define CAN_IRQ_HANDLED IRQ_HANDLED
83 #define CAN_IRQ_RETVAL IRQ_RETVAL
85 #else /*CAN_WITH_RTL*/
86 typedef int can_irqreturn_t;
87 #define CAN_IRQ_NONE 0
88 #define CAN_IRQ_HANDLED 1
89 #define CAN_IRQ_RETVAL(x) ((x) != 0)
90 #endif /*CAN_WITH_RTL*/
92 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,33))
93 #define can_synchronize_irq(irqnum) synchronize_irq()
95 #define can_synchronize_irq synchronize_irq
98 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
99 #define del_timer_sync del_timer
103 /* Standard LINUX kernel */
105 #define can_spinlock_t spinlock_t
106 #define can_spin_irqflags_t unsigned long
107 #define can_spin_lock spin_lock
108 #define can_spin_unlock spin_unlock
109 #define can_spin_lock_irqsave spin_lock_irqsave
110 #define can_spin_unlock_irqrestore spin_unlock_irqrestore
111 #define can_spin_lock_init spin_lock_init
113 #if defined(CONFIG_PREEMPT) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
114 #define can_preempt_disable preempt_disable
115 #define can_preempt_enable preempt_enable
116 #else /*CONFIG_PREEMPT*/
117 #define can_preempt_disable() do { } while (0)
118 #define can_preempt_enable() do { } while (0)
119 #endif /*CONFIG_PREEMPT*/
121 #define can_enable_irq enable_irq
122 #define can_disable_irq disable_irq
124 #define can_printk printk
126 #else /*CAN_WITH_RTL*/
128 #define can_spinlock_t rtl_spinlock_t
129 #define can_spin_irqflags_t rtl_irqstate_t
130 #define can_spin_lock rtl_spin_lock
131 #define can_spin_unlock rtl_spin_unlock
132 #define can_spin_lock_irqsave rtl_spin_lock_irqsave
133 #define can_spin_unlock_irqrestore rtl_spin_unlock_irqrestore
134 #define can_spin_lock_init rtl_spin_lock_init
136 #define can_preempt_disable() do { } while (0)
137 #define can_preempt_enable() do { } while (0)
139 #define can_enable_irq rtl_hard_enable_irq
140 #define can_disable_irq rtl_hard_disable_irq
142 #define can_printk rtl_printf
145 * terrible hack to test rtl_file private_data concept, ugh !!!
146 * this would result in crash on architectures, where
147 * sizeof(int) < sizeof(void *)
149 #define can_set_rtl_file_private_data(fptr, p) do{ fptr->f_minor=(long)(p); } while(0)
150 #define can_get_rtl_file_private_data(fptr) ((void*)((fptr)->f_minor))
152 #endif /*CAN_WITH_RTL*/
154 #endif /*_CAN_SYSDEP_H*/