2 * Part of Intel(R) Manageability Engine Interface Linux driver
4 * Copyright (c) 2003 - 2008 Intel Corp.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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.
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>
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
58 #define HECI_DEVICE_CREATE(cls, parent, devt, devpar, fmt...) device_create(cls, parent, devt, ## fmt)
63 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23))
64 #define HECI_TASK_NONFREEZABLE current->flags |= PF_NOFREEZE;
68 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17))
69 #include <asm/uaccess.h>
71 #include <linux/uaccess.h>
74 /*****************************************************************************/
75 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20))
76 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 28))
78 #define INIT_WORK(_work, _func) \
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); \
87 #define PREPARE_WORK(_work, _func) \
89 (_work)->func = (void (*)(void *))_func; \
90 (_work)->data = _work; \
96 #define round_jiffies(x) x
102 /*****************************************************************************/
103 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
105 #ifndef IRQF_PROBE_SHARED
107 #define IRQF_PROBE_SHARED SA_PROBEIRQ
109 #define IRQF_PROBE_SHARED 0
114 #define IRQF_SHARED SA_SHIRQ
118 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
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
*);
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
,
140 irq_handler_t new_handler
= (irq_handler_t
) handler
;
141 return request_irq(irq
, new_handler
, flags
, devname
, dev_id
);
145 #define request_irq(irq, handler, flags, devname, dev_id) _kc_request_irq((irq), (handler), (flags), (devname), (dev_id))