mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-27 12:04:27 +01:00
irq attempt
This commit is contained in:
@@ -9,6 +9,10 @@ TODO: get handler running multiple times on some existing interrupt from /proc/i
|
|||||||
|
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
|
||||||
|
static int irq = 0;
|
||||||
|
module_param_named(i, irq, int, S_IRUSR);
|
||||||
|
MODULE_PARM_DESC(i, "irq line number");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value from kernel docs:*
|
* Return value from kernel docs:*
|
||||||
*
|
*
|
||||||
@@ -17,28 +21,32 @@ MODULE_LICENSE("GPL");
|
|||||||
* @IRQ_HANDLED interrupt was handled by this device
|
* @IRQ_HANDLED interrupt was handled by this device
|
||||||
* @IRQ_WAKE_THREAD handler requests to wake the handler thread
|
* @IRQ_WAKE_THREAD handler requests to wake the handler thread
|
||||||
*/
|
*/
|
||||||
static irqreturn_t handler(int i, void *v)
|
static irqreturn_t handler(int irq, void *v)
|
||||||
{
|
{
|
||||||
pr_info("handler %llu\n", (unsigned long long)jiffies);
|
pr_info("handler irq = %d jiffies = %llx\n", irq, (unsigned long long)jiffies);
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int myinit(void)
|
static int myinit(void)
|
||||||
{
|
{
|
||||||
irqreturn_t r;
|
int ret;
|
||||||
r = request_irq(
|
|
||||||
1,
|
for (int i = 0; i < 128; ++i) {
|
||||||
handler,
|
ret = request_irq(
|
||||||
IRQF_SHARED,
|
i,
|
||||||
"myirqhandler0",
|
handler,
|
||||||
0
|
IRQF_SHARED,
|
||||||
);
|
"myirqhandler0",
|
||||||
pr_info("request_irq %llu\n", (unsigned long long)r);
|
NULL
|
||||||
|
);
|
||||||
|
pr_info("request_irq irq = %d ret = %d\n", i, ret);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void myexit(void)
|
static void myexit(void)
|
||||||
{
|
{
|
||||||
|
free_irq(irq, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(myinit)
|
module_init(myinit)
|
||||||
|
|||||||
Reference in New Issue
Block a user