Fix: uprobes: make uprobe_register() return struct uprobe * (v6.12)
[lttng-modules.git] / src / wrapper / irqdesc.c
CommitLineData
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 15#if (defined(CONFIG_KALLSYMS) && \
c58ee879 16 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,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
24static
25struct irq_desc *(*irq_to_desc_sym)(unsigned int irq);
26
27struct 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 31 if (irq_to_desc_sym) {
92e2c5fe
MD
32 struct irq_ibt_state irq_ibt_state;
33 struct irq_desc *ret;
34
35 irq_ibt_state = wrapper_irq_ibt_save();
36 ret = irq_to_desc_sym(irq);
37 wrapper_irq_ibt_restore(irq_ibt_state);
38 return ret;
c337ddc2 39 } else {
e36de50d 40 printk_once(KERN_WARNING "LTTng: irq_to_desc symbol lookup failed.\n");
c337ddc2
MD
41 return NULL;
42 }
43}
1c999280 44EXPORT_SYMBOL_GPL(wrapper_irq_to_desc);
c337ddc2
MD
45
46#else
47
48#include <linux/interrupt.h>
49#include <linux/irqnr.h>
50
51struct irq_desc *wrapper_irq_to_desc(unsigned int irq)
52{
53 return irq_to_desc(irq);
54}
1c999280 55EXPORT_SYMBOL_GPL(wrapper_irq_to_desc);
c337ddc2
MD
56
57#endif
This page took 0.066076 seconds and 4 git commands to generate.