29427d47dd71a8c622186e184b99e74fcd7c03c1
[lttng-modules.git] / wrapper / irqdesc.c
1 /* SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1)
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
14 #if (defined(CONFIG_KALLSYMS) \
15 && (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)))
16
17 #include <linux/kallsyms.h>
18 #include <linux/interrupt.h>
19 #include <linux/irqnr.h>
20 #include <wrapper/kallsyms.h>
21 #include <wrapper/irqdesc.h>
22
23 static
24 struct irq_desc *(*irq_to_desc_sym)(unsigned int irq);
25
26 struct irq_desc *wrapper_irq_to_desc(unsigned int irq)
27 {
28 if (!irq_to_desc_sym)
29 irq_to_desc_sym = (void *) kallsyms_lookup_funcptr("irq_to_desc");
30 if (irq_to_desc_sym) {
31 return irq_to_desc_sym(irq);
32 } else {
33 printk_once(KERN_WARNING "LTTng: irq_to_desc symbol lookup failed.\n");
34 return NULL;
35 }
36 }
37
38 #else
39
40 #include <linux/interrupt.h>
41 #include <linux/irqnr.h>
42
43 struct irq_desc *wrapper_irq_to_desc(unsigned int irq)
44 {
45 return irq_to_desc(irq);
46 }
47
48 #endif
This page took 0.030529 seconds and 3 git commands to generate.