fix: genirq: Restrict export of irq_to_desc() (v5.11)
[lttng-modules.git] / wrapper / irqdesc.c
CommitLineData
9f36eaed
MJ
1/* SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1)
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
e12ef7ee 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
a47f2a37 12#include <lttng-kernel-version.h>
f0883e02 13#include <linux/module.h>
a47f2a37 14
e12ef7ee
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
25static
26struct irq_desc *(*irq_to_desc_sym)(unsigned int irq);
27
28struct irq_desc *wrapper_irq_to_desc(unsigned int irq)
29{
30 if (!irq_to_desc_sym)
31 irq_to_desc_sym = (void *) kallsyms_lookup_funcptr("irq_to_desc");
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}
d4d4da49 39EXPORT_SYMBOL_GPL(wrapper_irq_to_desc);
c337ddc2
MD
40
41#else
42
43#include <linux/interrupt.h>
44#include <linux/irqnr.h>
45
46struct irq_desc *wrapper_irq_to_desc(unsigned int irq)
47{
48 return irq_to_desc(irq);
49}
d4d4da49 50EXPORT_SYMBOL_GPL(wrapper_irq_to_desc);
c337ddc2
MD
51
52#endif
This page took 0.042751 seconds and 4 git commands to generate.