Yuri
Yuri

Reputation: 1219

Why first interrupt occurs at registration?

I am using GPIO interrupts in kernel module and every time I got interrupt at first registration (at request_irq()).

Registering irq code:

at91_set_gpio_input(AT91_PIN_PB12, 0);
at91_set_pulldown(AT91_PIN_PB12, 1);
at91_set_deglitch(AT91_PIN_PB12, 1);
request_irq(gpio_to_irq(AT91_PIN_PB12), &interrupt_handler, IRQF_TRIGGER_FALLING, "irqname", NULL)

Console log:

# cat /proc/interrupts | grep irqname 
                           <----- the "irqname" interrupt is not registred 
# insmod testmodule.ko
# cat /proc/interrupts | grep irqname
 76:         1      GPIO  irqname <------Why first interrupt hapened at registration
# rmmod testmodule
# insmod testmodule.ko
# cat /proc/interrupts | grep irqname
 76:         1      GPIO  irqname
# rmmod testmodule
# insmod testmodule.ko
# cat /proc/interrupts | grep irqname
 76:         1      GPIO  irqname
# rmmod testmodule

Upvotes: 1

Views: 138

Answers (1)

John
John

Reputation: 449

There is less code to figure why exactly.

One of the possible case can be that, You were enabling the interrupt lines and registers before doing request_irq.

Please make sure you disable all the interrupt registers/lines before doing request_irq (i believe you do this in the driver's probe callback function) and then enable them when the device's open method gets called.

Upvotes: 1

Related Questions