Issue
Good night,
I am trying to code some simple linux module that registers an existent shared IRQ line.
By looking at /proc/interrupts
, I can see that the line I want to use has the irq_no
=17.
For reference here is the output. As we can see the b43
driver module has already registered on the line, but the flags in the linux kernel code indicate that it is a shared line.
CPU0 CPU1
0: 334476 345390 IO-APIC-edge timer
1: 28 26 IO-APIC-edge i8042
8: 0 1 IO-APIC-edge rtc0
9: 0 1 IO-APIC-fasteoi acpi
12: 1623 153 IO-APIC-edge i8042
14: 0 0 IO-APIC-edge ata_piix
15: 0 0 IO-APIC-edge ata_piix
16: 152 129 IO-APIC-fasteoi nouveau
17: 46543 40167 IO-APIC-fasteoi b43
18: 6129 5015 IO-APIC-fasteoi ata_piix
19: 48 28 IO-APIC-fasteoi firewire_ohci, yenta
20: 1 1 IO-APIC-fasteoi ehci_hcd:usb2, uhci_hcd:usb3, uhci_hcd:usb5
21: 0 0 IO-APIC-fasteoi uhci_hcd:usb4, uhci_hcd:usb6
22: 47 34 IO-APIC-fasteoi ehci_hcd:usb1, uhci_hcd:usb7
44: 129 138 PCI-MSI-edge hda_intel
45: 2 1 PCI-MSI-edge eth0
NMI: 0 0 Non-maskable interrupts
LOC: 227794 229233 Local timer interrupts
SPU: 0 0 Spurious interrupts
PMI: 0 0 Performance monitoring interrupts
IWI: 0 0 IRQ work interrupts
RES: 244428 258417 Rescheduling interrupts
CAL: 340 462 Function call interrupts
TLB: 1056 916 TLB shootdowns
TRM: 0 0 Thermal event interrupts
THR: 0 0 Threshold APIC interrupts
MCE: 0 0 Machine check exceptions
MCP: 15 15 Machine check polls
ERR: 0
MIS: 0
I am trying to do the following:
static int __init ptdk_init(void)
{
printk(KERN_INFO "starting the kernel listener to the firmware module.\n");
ptdk_could_not_register = request_threaded_irq(17, (irq_handler_t) ptdk_irq_handler,
(irq_handler_t) ptdk_threaded_irq_handler, IRQF_SHARED, "ptdk", dummy);
if (ptdk_could_not_register != 0) {
printk(KERN_INFO "Could not request an irq for 17. %d", ptdk_could_not_register);
}
return 0;
}
The dummy
is a simple dev_id
in order to register a cookie so the shared interrupt can free the line with context. (It is required a unique id to request a shared IRQ).
It just follows the following structure:
typedef struct{
int i;
} ptdk_dummy_device;
So this should in principle work. But when trying to register the IRQ it returns -22
which is -EINVAL
.
Am I missing something important? No other guide seems to give me any solutions. Thank you for your time and patience.
Solution
I was able to solve this as I was trying to make the cookie ID not a valid pointer.
Working code:
ptdk_could_not_register = request_threaded_irq(17, (irq_handler_t) ptdk_irq_handler,
(irq_handler_t) ptdk_threaded_irq_handler, IRQF_SHARED, "ptdk", &dummy);
Please, see the now &dummy.
Answered By - as43z Answer Checked By - Marilyn (WPSolving Volunteer)