Staging: add heci driver
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / heci / kcompat.h
blob339b3ae22c044bd0535228a2966ee1f8c328c2db
1 /*
2 * Part of Intel(R) Manageability Engine Interface Linux driver
4 * Copyright (c) 2003 - 2008 Intel Corp.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer,
12 * without modification.
13 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14 * substantially similar to the "NO WARRANTY" disclaimer below
15 * ("Disclaimer") and any redistribution must be conditioned upon
16 * including a substantially similar Disclaimer requirement for further
17 * binary redistribution.
18 * 3. Neither the names of the above-listed copyright holders nor the names
19 * of any contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * Alternatively, this software may be distributed under the terms of the
23 * GNU General Public License ("GPL") version 2 as published by the Free
24 * Software Foundation.
26 * NO WARRANTY
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
35 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
36 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGES.
41 #ifndef _KCOMPAT_H_
42 #define _KCOMPAT_H_
44 #include <linux/version.h>
45 #include <linux/init.h>
46 #include <linux/types.h>
47 #include <linux/errno.h>
48 #include <linux/module.h>
49 #include <linux/interrupt.h>
50 #include <asm/io.h>
52 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27))
53 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
54 #define device_create(cls, parent, devt, devpar, fmt...) class_device_create(cls, parent, devt, NULL, ## fmt)
55 #define HECI_DEVICE_CREATE(cls, parent, devt, devpar, fmt...) class_device_create(cls, parent, devt, NULL, ## fmt)
56 #define device_destroy class_device_destroy
57 #else
58 #define HECI_DEVICE_CREATE(cls, parent, devt, devpar, fmt...) device_create(cls, parent, devt, ## fmt)
59 #endif
60 #endif
63 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23))
64 #define HECI_TASK_NONFREEZABLE current->flags |= PF_NOFREEZE;
65 #endif
68 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17))
69 #include <asm/uaccess.h>
70 #else
71 #include <linux/uaccess.h>
72 #endif
74 /*****************************************************************************/
75 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20))
76 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 28))
77 #undef INIT_WORK
78 #define INIT_WORK(_work, _func) \
79 do { \
80 INIT_LIST_HEAD(&(_work)->entry); \
81 (_work)->pending = 0; \
82 (_work)->func = (void (*)(void *))_func; \
83 (_work)->data = _work; \
84 init_timer(&(_work)->timer); \
85 } while (0)
86 #undef PREPARE_WORK
87 #define PREPARE_WORK(_work, _func) \
88 do { \
89 (_work)->func = (void (*)(void *))_func; \
90 (_work)->data = _work; \
91 } while (0)
93 #endif
95 #ifndef round_jiffies
96 #define round_jiffies(x) x
97 #endif
99 #endif /* < 2.6.20 */
102 /*****************************************************************************/
103 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
105 #ifndef IRQF_PROBE_SHARED
106 #ifdef SA_PROBEIRQ
107 #define IRQF_PROBE_SHARED SA_PROBEIRQ
108 #else
109 #define IRQF_PROBE_SHARED 0
110 #endif
111 #endif
113 #ifndef IRQF_SHARED
114 #define IRQF_SHARED SA_SHIRQ
115 #endif
117 #ifndef ARRAY_SIZE
118 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
119 #endif
121 #endif /* < 2.6.18 */
124 /*****************************************************************************/
125 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19))
127 #if (!(defined(RHEL_MAJOR) && (RHEL_MAJOR == 5)))
128 #if (!(defined(RHEL_VERSION) && (RHEL_VERSION == 4) && (RHEL_UPDATE >= 5)))
129 typedef irqreturn_t (*irq_handler_t)(int, void*, struct pt_regs *);
130 #endif
131 #endif
133 typedef irqreturn_t (*new_handler_t)(int, void*);
134 static inline irqreturn_t _kc_request_irq(unsigned int irq,
135 new_handler_t handler,
136 unsigned long flags,
137 const char *devname,
138 void *dev_id)
140 irq_handler_t new_handler = (irq_handler_t) handler;
141 return request_irq(irq, new_handler, flags, devname, dev_id);
144 #undef request_irq
145 #define request_irq(irq, handler, flags, devname, dev_id) _kc_request_irq((irq), (handler), (flags), (devname), (dev_id))
147 #endif
150 #endif