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 | |
4a7d870a | 7 | * modules. This export was added to the 3.4 kernels and removed in 5.11. |
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 | 14 | |
4a7d870a MJ |
15 | #if (defined(CONFIG_KALLSYMS) && \ |
16 | ((LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0)) || \ | |
17 | (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)))) | |
c337ddc2 MD |
18 | |
19 | #include <linux/kallsyms.h> | |
20 | #include <linux/interrupt.h> | |
21 | #include <linux/irqnr.h> | |
5a2f5e92 MD |
22 | #include <wrapper/kallsyms.h> |
23 | #include <wrapper/irqdesc.h> | |
c337ddc2 MD |
24 | |
25 | static | |
26 | struct irq_desc *(*irq_to_desc_sym)(unsigned int irq); | |
27 | ||
28 | struct irq_desc *wrapper_irq_to_desc(unsigned int irq) | |
29 | { | |
30 | if (!irq_to_desc_sym) | |
1e543e7c | 31 | irq_to_desc_sym = (void *) kallsyms_lookup_funcptr("irq_to_desc"); |
c337ddc2 MD |
32 | if (irq_to_desc_sym) { |
33 | return irq_to_desc_sym(irq); | |
34 | } else { | |
e36de50d | 35 | printk_once(KERN_WARNING "LTTng: irq_to_desc symbol lookup failed.\n"); |
c337ddc2 MD |
36 | return NULL; |
37 | } | |
38 | } | |
1c999280 | 39 | EXPORT_SYMBOL_GPL(wrapper_irq_to_desc); |
c337ddc2 MD |
40 | |
41 | #else | |
42 | ||
43 | #include <linux/interrupt.h> | |
44 | #include <linux/irqnr.h> | |
45 | ||
46 | struct irq_desc *wrapper_irq_to_desc(unsigned int irq) | |
47 | { | |
48 | return irq_to_desc(irq); | |
49 | } | |
1c999280 | 50 | EXPORT_SYMBOL_GPL(wrapper_irq_to_desc); |
c337ddc2 MD |
51 | |
52 | #endif |