Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Dummy IRQ handler driver.
0004  *
0005  * This module only registers itself as a handler that is specified to it
0006  * by the 'irq' parameter.
0007  *
0008  * The sole purpose of this module is to help with debugging of systems on
0009  * which spurious IRQs would happen on disabled IRQ vector.
0010  *
0011  * Copyright (C) 2013 Jiri Kosina
0012  */
0013 
0014 #include <linux/module.h>
0015 #include <linux/irq.h>
0016 #include <linux/interrupt.h>
0017 
0018 static int irq = -1;
0019 
0020 static irqreturn_t dummy_interrupt(int irq, void *dev_id)
0021 {
0022     static int count = 0;
0023 
0024     if (count == 0) {
0025         printk(KERN_INFO "dummy-irq: interrupt occurred on IRQ %d\n",
0026                 irq);
0027         count++;
0028     }
0029 
0030     return IRQ_NONE;
0031 }
0032 
0033 static int __init dummy_irq_init(void)
0034 {
0035     if (irq < 0) {
0036         printk(KERN_ERR "dummy-irq: no IRQ given.  Use irq=N\n");
0037         return -EIO;
0038     }
0039     if (request_irq(irq, &dummy_interrupt, IRQF_SHARED, "dummy_irq", &irq)) {
0040         printk(KERN_ERR "dummy-irq: cannot register IRQ %d\n", irq);
0041         return -EIO;
0042     }
0043     printk(KERN_INFO "dummy-irq: registered for IRQ %d\n", irq);
0044     return 0;
0045 }
0046 
0047 static void __exit dummy_irq_exit(void)
0048 {
0049     printk(KERN_INFO "dummy-irq unloaded\n");
0050     free_irq(irq, &irq);
0051 }
0052 
0053 module_init(dummy_irq_init);
0054 module_exit(dummy_irq_exit);
0055 
0056 MODULE_LICENSE("GPL");
0057 MODULE_AUTHOR("Jiri Kosina");
0058 module_param_hw(irq, uint, irq, 0444);
0059 MODULE_PARM_DESC(irq, "The IRQ to register for");
0060 MODULE_DESCRIPTION("Dummy IRQ handler driver");