Merge branch 'master' of /pub/scm/linux/kernel/git/torvalds/linux-2.6
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / irqdesc.h
blob979c68cc74584c7072ce8b59f33a7dd1a53f453e
1 #ifndef _LINUX_IRQDESC_H
2 #define _LINUX_IRQDESC_H
4 /*
5 * Core internal functions to deal with irq descriptors
7 * This include will move to kernel/irq once we cleaned up the tree.
8 * For now it's included from <linux/irq.h>
9 */
11 struct proc_dir_entry;
12 struct timer_rand_state;
13 /**
14 * struct irq_desc - interrupt descriptor
15 * @irq_data: per irq and chip data passed down to chip functions
16 * @timer_rand_state: pointer to timer rand state struct
17 * @kstat_irqs: irq stats per cpu
18 * @handle_irq: highlevel irq-events handler [if NULL, __do_IRQ()]
19 * @action: the irq action chain
20 * @status: status information
21 * @depth: disable-depth, for nested irq_disable() calls
22 * @wake_depth: enable depth, for multiple set_irq_wake() callers
23 * @irq_count: stats field to detect stalled irqs
24 * @last_unhandled: aging timer for unhandled count
25 * @irqs_unhandled: stats field for spurious unhandled interrupts
26 * @lock: locking for SMP
27 * @pending_mask: pending rebalanced interrupts
28 * @threads_active: number of irqaction threads currently running
29 * @wait_for_threads: wait queue for sync_irq to wait for threaded handlers
30 * @dir: /proc/irq/ procfs entry
31 * @name: flow handler name for /proc/interrupts output
33 struct irq_desc {
35 #ifdef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
36 struct irq_data irq_data;
37 #else
39 * This union will go away, once we fixed the direct access to
40 * irq_desc all over the place. The direct fields are a 1:1
41 * overlay of irq_data.
43 union {
44 struct irq_data irq_data;
45 struct {
46 unsigned int irq;
47 unsigned int node;
48 struct irq_chip *chip;
49 void *handler_data;
50 void *chip_data;
51 struct msi_desc *msi_desc;
52 #ifdef CONFIG_SMP
53 cpumask_var_t affinity;
54 #endif
57 #endif
59 struct timer_rand_state *timer_rand_state;
60 unsigned int *kstat_irqs;
61 irq_flow_handler_t handle_irq;
62 struct irqaction *action; /* IRQ action list */
63 unsigned int status; /* IRQ status */
65 unsigned int depth; /* nested irq disables */
66 unsigned int wake_depth; /* nested wake enables */
67 unsigned int irq_count; /* For detecting broken IRQs */
68 unsigned long last_unhandled; /* Aging timer for unhandled count */
69 unsigned int irqs_unhandled;
70 raw_spinlock_t lock;
71 #ifdef CONFIG_SMP
72 const struct cpumask *affinity_hint;
73 #ifdef CONFIG_GENERIC_PENDING_IRQ
74 cpumask_var_t pending_mask;
75 #endif
76 #endif
77 atomic_t threads_active;
78 wait_queue_head_t wait_for_threads;
79 #ifdef CONFIG_PROC_FS
80 struct proc_dir_entry *dir;
81 #endif
82 const char *name;
83 } ____cacheline_internodealigned_in_smp;
85 #ifndef CONFIG_SPARSE_IRQ
86 extern struct irq_desc irq_desc[NR_IRQS];
87 #endif
89 /* Will be removed once the last users in power and sh are gone */
90 extern struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node);
91 static inline struct irq_desc *move_irq_desc(struct irq_desc *desc, int node)
93 return desc;
96 #ifdef CONFIG_GENERIC_HARDIRQS
98 #define get_irq_desc_chip(desc) ((desc)->irq_data.chip)
99 #define get_irq_desc_chip_data(desc) ((desc)->irq_data.chip_data)
100 #define get_irq_desc_data(desc) ((desc)->irq_data.handler_data)
101 #define get_irq_desc_msi(desc) ((desc)->irq_data.msi_desc)
104 * Monolithic do_IRQ implementation.
106 #ifndef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
107 extern unsigned int __do_IRQ(unsigned int irq);
108 #endif
111 * Architectures call this to let the generic IRQ layer
112 * handle an interrupt. If the descriptor is attached to an
113 * irqchip-style controller then we call the ->handle_irq() handler,
114 * and it calls __do_IRQ() if it's attached to an irqtype-style controller.
116 static inline void generic_handle_irq_desc(unsigned int irq, struct irq_desc *desc)
118 #ifdef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
119 desc->handle_irq(irq, desc);
120 #else
121 if (likely(desc->handle_irq))
122 desc->handle_irq(irq, desc);
123 else
124 __do_IRQ(irq);
125 #endif
128 static inline void generic_handle_irq(unsigned int irq)
130 generic_handle_irq_desc(irq, irq_to_desc(irq));
133 /* Test to see if a driver has successfully requested an irq */
134 static inline int irq_has_action(unsigned int irq)
136 struct irq_desc *desc = irq_to_desc(irq);
137 return desc->action != NULL;
140 static inline int irq_balancing_disabled(unsigned int irq)
142 struct irq_desc *desc;
144 desc = irq_to_desc(irq);
145 return desc->status & IRQ_NO_BALANCING_MASK;
148 /* caller has locked the irq_desc and both params are valid */
149 static inline void __set_irq_handler_unlocked(int irq,
150 irq_flow_handler_t handler)
152 struct irq_desc *desc;
154 desc = irq_to_desc(irq);
155 desc->handle_irq = handler;
157 #endif
159 #endif