1 /* drivers/message/fusion/linux_compat.h */
3 #ifndef FUSION_LINUX_COMPAT_H
4 #define FUSION_LINUX_COMPAT_H
5 /*{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
7 #include <linux/version.h>
8 #include <linux/config.h>
9 #include <linux/kernel.h>
10 #include <linux/pci.h>
12 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
15 #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
18 #define SET_NICE(current,x) do {(current)->nice = (x);} while (0)
20 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
21 # if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18)
22 typedef unsigned int dma_addr_t;
25 # if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,42)
26 typedef unsigned int dma_addr_t;
30 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18)
31 /*{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
33 /* This block snipped from lk-2.2.18/include/linux/init.h { */
35 * Used for initialization calls..
37 typedef int (*initcall_t)(void);
38 typedef void (*exitcall_t)(void);
40 #define __init_call __attribute__ ((unused,__section__ (".initcall.init")))
41 #define __exit_call __attribute__ ((unused,__section__ (".exitcall.exit")))
43 extern initcall_t __initcall_start, __initcall_end;
45 #define __initcall(fn) \
46 static initcall_t __initcall_##fn __init_call = fn
47 #define __exitcall(fn) \
48 static exitcall_t __exitcall_##fn __exit_call = fn
51 /* These macros create a dummy inline: gcc 2.9x does not count alias
52 as usage, hence the `unused function' warning when __init functions
53 are declared static. We use the dummy __*_module_inline functions
54 both to kill the warning and check the type of the init/cleanup
56 typedef int (*__init_module_func_t)(void);
57 typedef void (*__cleanup_module_func_t)(void);
58 #define module_init(x) \
59 int init_module(void) __attribute__((alias(#x))); \
60 static inline __init_module_func_t __init_module_inline(void) \
62 #define module_exit(x) \
63 void cleanup_module(void) __attribute__((alias(#x))); \
64 static inline __cleanup_module_func_t __cleanup_module_inline(void) \
68 #define module_init(x) __initcall(x);
69 #define module_exit(x) __exitcall(x);
71 /* } block snipped from lk-2.2.18/include/linux/init.h */
73 /* This block snipped from lk-2.2.18/include/linux/sched.h { */
75 * Used prior to schedule_timeout calls..
77 #define __set_current_state(state_value) do { current->state = state_value; } while (0)
79 #define set_current_state(state_value) do { __set_current_state(state_value); mb(); } while (0)
81 #define set_current_state(state_value) __set_current_state(state_value)
83 /* } block snipped from lk-2.2.18/include/linux/sched.h */
85 /* procfs compat stuff... */
86 #define proc_mkdir(x,y) create_proc_entry(x, S_IFDIR, y)
88 /* MUTEX compat stuff... */
89 #define DECLARE_MUTEX(name) struct semaphore name=MUTEX
90 #define DECLARE_MUTEX_LOCKED(name) struct semaphore name=MUTEX_LOCKED
91 #define init_MUTEX(x) *(x)=MUTEX
92 #define init_MUTEX_LOCKED(x) *(x)=MUTEX_LOCKED
95 #define DECLARE_WAIT_QUEUE_HEAD(name) \
96 struct wait_queue * (name) = NULL
97 #define DECLARE_WAITQUEUE(name, task) \
98 struct wait_queue (name) = { (task), NULL }
100 #if defined(__sparc__) && defined(__sparc_v9__)
101 /* The sparc64 ioremap implementation is wrong in 2.2.x,
102 * but fixing it would break all of the drivers which
103 * workaround it. Fixed in 2.3.x onward. -DaveM
105 #define ARCH_IOREMAP(base) ((unsigned long) (base))
107 #define ARCH_IOREMAP(base) ioremap(base)
110 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
111 #else /* LINUX_VERSION_CODE must be >= KERNEL_VERSION(2,2,18) */
113 /* No ioremap bugs in >2.3.x kernels. */
114 #define ARCH_IOREMAP(base) ioremap(base)
116 /*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
117 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18) */
122 * #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10)
123 * here, but MODULE_LICENSE defined in 2.4.9-6 and 2.4.9-13
126 #ifndef MODULE_LICENSE
127 #define MODULE_LICENSE(license)
131 /* PCI/driver subsystem { */
132 #define PCI_BASEADDR_FLAGS(idx) resource[idx].flags
133 #define PCI_BASEADDR_START(idx) resource[idx].start
134 #define PCI_BASEADDR_SIZE(dev,idx) (dev)->resource[idx].end - (dev)->resource[idx].start + 1
136 /* Compatability for the 2.3.x PCI DMA API. */
137 #ifndef PCI_DMA_BIDIRECTIONAL
138 /*{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
140 #define PCI_DMA_BIDIRECTIONAL 0
141 #define PCI_DMA_TODEVICE 1
142 #define PCI_DMA_FROMDEVICE 2
143 #define PCI_DMA_NONE 3
146 #include <asm/page.h>
147 /* Pure 2^n version of get_order */
148 static __inline__ int __get_order(unsigned long size)
152 size = (size-1) >> (PAGE_SHIFT-1);
162 #define pci_alloc_consistent(hwdev, size, dma_handle) \
163 ({ void *__ret = (void *)__get_free_pages(GFP_ATOMIC, __get_order(size)); \
164 if (__ret != NULL) { \
165 memset(__ret, 0, size); \
166 *(dma_handle) = virt_to_bus(__ret); \
171 #define pci_free_consistent(hwdev, size, vaddr, dma_handle) \
172 free_pages((unsigned long)vaddr, __get_order(size))
174 #define pci_map_single(hwdev, ptr, size, direction) \
177 #define pci_unmap_single(hwdev, dma_addr, size, direction) \
178 do { /* Nothing to do */ } while (0)
180 #define pci_map_sg(hwdev, sg, nents, direction) (nents)
181 #define pci_unmap_sg(hwdev, sg, nents, direction) \
182 do { /* Nothing to do */ } while(0)
184 #define sg_dma_address(sg) (virt_to_bus((sg)->address))
185 #define sg_dma_len(sg) ((sg)->length)
187 /*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
188 #endif /* PCI_DMA_BIDIRECTIONAL */
191 #define mpt_work_struct work_struct
192 #define MPT_INIT_WORK(_task, _func, _data) INIT_WORK(_task, _func, _data)
193 #define mpt_sync_irq(_irq) synchronize_irq(_irq)
195 /*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
196 #endif /* _LINUX_COMPAT_H */