Commit | Line | Data |
---|---|---|
c337ddc2 | 1 | /* |
886d51a3 | 2 | * wrapper/irqdesc.c |
c337ddc2 MD |
3 | * |
4 | * wrapper around irq_to_desc. Using KALLSYMS to get its address when | |
5 | * available, else we need to have a kernel that exports this function to GPL | |
f98d5dee | 6 | * modules. This export was added to the 3.4 kernels. |
c337ddc2 | 7 | * |
886d51a3 MD |
8 | * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
9 | * | |
10 | * This library is free software; you can redistribute it and/or | |
11 | * modify it under the terms of the GNU Lesser General Public | |
12 | * License as published by the Free Software Foundation; only | |
13 | * version 2.1 of the License. | |
14 | * | |
15 | * This library is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | * Lesser General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU Lesser General Public | |
21 | * License along with this library; if not, write to the Free Software | |
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
c337ddc2 MD |
23 | */ |
24 | ||
f98d5dee MD |
25 | #include <lttng-kernel-version.h> |
26 | ||
27 | #if (defined(CONFIG_KALLSYMS) \ | |
28 | && (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))) | |
c337ddc2 MD |
29 | |
30 | #include <linux/kallsyms.h> | |
31 | #include <linux/interrupt.h> | |
32 | #include <linux/irqnr.h> | |
5a2f5e92 MD |
33 | #include <wrapper/kallsyms.h> |
34 | #include <wrapper/irqdesc.h> | |
c337ddc2 MD |
35 | |
36 | static | |
37 | struct irq_desc *(*irq_to_desc_sym)(unsigned int irq); | |
38 | ||
39 | struct irq_desc *wrapper_irq_to_desc(unsigned int irq) | |
40 | { | |
41 | if (!irq_to_desc_sym) | |
42 | irq_to_desc_sym = (void *) kallsyms_lookup_funcptr("irq_to_desc"); | |
43 | if (irq_to_desc_sym) { | |
44 | return irq_to_desc_sym(irq); | |
45 | } else { | |
e36de50d | 46 | printk_once(KERN_WARNING "LTTng: irq_to_desc symbol lookup failed.\n"); |
c337ddc2 MD |
47 | return NULL; |
48 | } | |
49 | } | |
50 | ||
51 | #else | |
52 | ||
53 | #include <linux/interrupt.h> | |
54 | #include <linux/irqnr.h> | |
55 | ||
56 | struct irq_desc *wrapper_irq_to_desc(unsigned int irq) | |
57 | { | |
58 | return irq_to_desc(irq); | |
59 | } | |
60 | ||
61 | #endif |