fix: include module.h for EXPORT_SYMBOL_GPL
[lttng-modules.git] / src / wrapper / irqdesc.c
1 /* SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
2 *
3 * wrapper/irqdesc.c
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
7 * modules. This export was added to the 3.4 kernels.
8 *
9 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 */
11
12 #include <lttng/kernel-version.h>
13 #include <linux/module.h>
14
15 #if (defined(CONFIG_KALLSYMS) \
16 && (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)))
17
18 #include <linux/kallsyms.h>
19 #include <linux/interrupt.h>
20 #include <linux/irqnr.h>
21 #include <wrapper/kallsyms.h>
22 #include <wrapper/irqdesc.h>
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)
30 irq_to_desc_sym = (void *) kallsyms_lookup_funcptr("irq_to_desc");
31 if (irq_to_desc_sym) {
32 return irq_to_desc_sym(irq);
33 } else {
34 printk_once(KERN_WARNING "LTTng: irq_to_desc symbol lookup failed.\n");
35 return NULL;
36 }
37 }
38 EXPORT_SYMBOL_GPL(wrapper_irq_to_desc);
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 }
49 EXPORT_SYMBOL_GPL(wrapper_irq_to_desc);
50
51 #endif
This page took 0.0291709999999999 seconds and 4 git commands to generate.