Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | None | 0 0
  1. #include <linux/module.h>   /* Needed by all modules */
  2. #include <linux/kernel.h>   /* Needed for KERN_INFO */
  3. #include <linux/interrupt.h>
  4.  
  5. unsigned int irq = 20;
  6. //exported by linux/arch/arm/mach-imx/tzic.c
  7. unsigned long tzic_domain_irq(unsigned long const hwirq);
  8. void          tzic_end_sw_irq(unsigned long const irq);
  9.  
  10. static irqreturn_t handler(int irq, void *dev_id)
  11. {
  12.     printk(KERN_INFO "handler!\n");
  13.     /* end software interrupt */
  14.     tzic_end_sw_irq(irq);
  15.     return IRQ_HANDLED;
  16. }
  17.  
  18.  
  19. int init_module(void)
  20. {
  21.     int err;
  22.  
  23.     irq = tzic_domain_irq(irq);
  24.     printk(KERN_INFO "irq: %d",irq);
  25.     if( ( err = request_irq(irq, handler, 0, "trapps", NULL) ) )
  26.     {  
  27.         printk(KERN_ERR "error: %d!",err);
  28.     } else {
  29.         printk(KERN_INFO "successfully requested irq %d\n",irq);
  30.     }  
  31.  
  32.     return err;
  33. }
  34.  
  35. void cleanup_module(void)
  36. {
  37.     printk(KERN_INFO "Goodbye world 1.\n");
  38.     free_irq(irq, NULL);
  39. }
  40.  
  41. MODULE_LICENSE("GPL");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement