irq.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (C) 2004-2006 Atmel Corporation
  3. *
  4. * Based on arch/i386/kernel/irq.c
  5. * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This file contains the code used by various IRQ handling routines:
  12. * asking for different IRQ's should be done through these routines
  13. * instead of just grabbing them. Thus setups with different IRQ numbers
  14. * shouldn't result in any weird surprises, and installing new handlers
  15. * should be easier.
  16. *
  17. * IRQ's are in fact implemented a bit like signal handlers for the kernel.
  18. * Naturally it's not a 1:1 relation, but there are similarities.
  19. */
  20. #include <linux/interrupt.h>
  21. #include <linux/irq.h>
  22. #include <linux/kernel_stat.h>
  23. #include <linux/proc_fs.h>
  24. #include <linux/seq_file.h>
  25. #include <linux/sysdev.h>
  26. /*
  27. * 'what should we do if we get a hw irq event on an illegal vector'.
  28. * each architecture has to answer this themselves.
  29. */
  30. void ack_bad_irq(unsigned int irq)
  31. {
  32. printk("unexpected IRQ %u\n", irq);
  33. }
  34. #ifdef CONFIG_PROC_FS
  35. int show_interrupts(struct seq_file *p, void *v)
  36. {
  37. int i = *(loff_t *)v, cpu;
  38. struct irqaction *action;
  39. unsigned long flags;
  40. if (i == 0) {
  41. seq_puts(p, " ");
  42. for_each_online_cpu(cpu)
  43. seq_printf(p, "CPU%d ", cpu);
  44. seq_putc(p, '\n');
  45. }
  46. if (i < NR_IRQS) {
  47. spin_lock_irqsave(&irq_desc[i].lock, flags);
  48. action = irq_desc[i].action;
  49. if (!action)
  50. goto unlock;
  51. seq_printf(p, "%3d: ", i);
  52. for_each_online_cpu(cpu)
  53. seq_printf(p, "%10u ", kstat_cpu(cpu).irqs[i]);
  54. seq_printf(p, " %8s", irq_desc[i].chip->name ? : "-");
  55. seq_printf(p, " %s", action->name);
  56. for (action = action->next; action; action = action->next)
  57. seq_printf(p, ", %s", action->name);
  58. seq_putc(p, '\n');
  59. unlock:
  60. spin_unlock_irqrestore(&irq_desc[i].lock, flags);
  61. }
  62. return 0;
  63. }
  64. #endif