Commit | Line | Data |
---|---|---|
b7cdc182 | 1 | /* SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only) |
9f36eaed | 2 | * |
886d51a3 | 3 | * wrapper/irqdesc.c |
c337ddc2 MD |
4 | * |
5 | * wrapper around irq_to_desc. Using KALLSYMS to get its address when | |
6 | * available, else we need to have a kernel that exports this function to GPL | |
0bbde272 | 7 | * modules. This export was added to the 3.4 kernels. |
c337ddc2 | 8 | * |
886d51a3 | 9 | * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
c337ddc2 MD |
10 | */ |
11 | ||
2df37e95 | 12 | #include <lttng/kernel-version.h> |
0193412d | 13 | #include <linux/module.h> |
0bbde272 MD |
14 | |
15 | #if (defined(CONFIG_KALLSYMS) \ | |
16 | && (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))) | |
c337ddc2 MD |
17 | |
18 | #include <linux/kallsyms.h> | |
19 | #include <linux/interrupt.h> | |
20 | #include <linux/irqnr.h> | |
5a2f5e92 MD |
21 | #include <wrapper/kallsyms.h> |
22 | #include <wrapper/irqdesc.h> | |
c337ddc2 MD |
23 | |
24 | static | |
25 | struct irq_desc *(*irq_to_desc_sym)(unsigned int irq); | |
26 | ||
27 | struct irq_desc *wrapper_irq_to_desc(unsigned int irq) | |
28 | { | |
29 | if (!irq_to_desc_sym) | |
1e543e7c | 30 | irq_to_desc_sym = (void *) kallsyms_lookup_funcptr("irq_to_desc"); |
c337ddc2 MD |
31 | if (irq_to_desc_sym) { |
32 | return irq_to_desc_sym(irq); | |
33 | } else { | |
e36de50d | 34 | printk_once(KERN_WARNING "LTTng: irq_to_desc symbol lookup failed.\n"); |
c337ddc2 MD |
35 | return NULL; |
36 | } | |
37 | } | |
1c999280 | 38 | EXPORT_SYMBOL_GPL(wrapper_irq_to_desc); |
c337ddc2 MD |
39 | |
40 | #else | |
41 | ||
42 | #include <linux/interrupt.h> | |
43 | #include <linux/irqnr.h> | |
44 | ||
45 | struct irq_desc *wrapper_irq_to_desc(unsigned int irq) | |
46 | { | |
47 | return irq_to_desc(irq); | |
48 | } | |
1c999280 | 49 | EXPORT_SYMBOL_GPL(wrapper_irq_to_desc); |
c337ddc2 MD |
50 | |
51 | #endif |