blob: 1a239a83f925cbaed7e16c7d100ac2740e428cc5 [file] [log] [blame]
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -07001/*
2 * linux/kernel/irq/chip.c
3 *
4 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar
5 * Copyright (C) 2005-2006, Thomas Gleixner, Russell King
6 *
7 * This file contains the core interrupt handling code, for irq-chip
8 * based architectures.
9 *
10 * Detailed information is available in Documentation/DocBook/genericirq
11 */
12
13#include <linux/irq.h>
Michael Ellerman7fe37302007-04-18 19:39:21 +100014#include <linux/msi.h>
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070015#include <linux/module.h>
16#include <linux/interrupt.h>
17#include <linux/kernel_stat.h>
18
19#include "internals.h"
20
Eric W. Biederman3a16d712006-10-04 02:16:37 -070021/**
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010022 * irq_set_chip - set the irq chip for an irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070023 * @irq: irq number
24 * @chip: pointer to irq chip description structure
25 */
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010026int irq_set_chip(unsigned int irq, struct irq_chip *chip)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070027{
Thomas Gleixnerd3c60042008-10-16 09:55:00 +020028 struct irq_desc *desc = irq_to_desc(irq);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070029 unsigned long flags;
30
Yinghai Lu7d94f7c2008-08-19 20:50:14 -070031 if (!desc) {
Arjan van de Ven261c40c2008-07-25 19:45:37 -070032 WARN(1, KERN_ERR "Trying to install chip for IRQ%d\n", irq);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070033 return -EINVAL;
34 }
35
36 if (!chip)
37 chip = &no_irq_chip;
38
Thomas Gleixner239007b2009-11-17 16:46:45 +010039 raw_spin_lock_irqsave(&desc->lock, flags);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070040 irq_chip_set_defaults(chip);
Thomas Gleixner6b8ff312010-10-01 12:58:38 +020041 desc->irq_data.chip = chip;
Thomas Gleixner239007b2009-11-17 16:46:45 +010042 raw_spin_unlock_irqrestore(&desc->lock, flags);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070043
44 return 0;
45}
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010046EXPORT_SYMBOL(irq_set_chip);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070047
48/**
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010049 * irq_set_type - set the irq trigger type for an irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070050 * @irq: irq number
David Brownell0c5d1eb2008-10-01 14:46:18 -070051 * @type: IRQ_TYPE_{LEVEL,EDGE}_* value - see include/linux/irq.h
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070052 */
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010053int irq_set_irq_type(unsigned int irq, unsigned int type)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070054{
Thomas Gleixnerd3c60042008-10-16 09:55:00 +020055 struct irq_desc *desc = irq_to_desc(irq);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070056 unsigned long flags;
57 int ret = -ENXIO;
58
Yinghai Lu7d94f7c2008-08-19 20:50:14 -070059 if (!desc) {
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070060 printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq);
61 return -ENODEV;
62 }
63
David Brownellf2b662d2008-12-01 14:31:38 -080064 type &= IRQ_TYPE_SENSE_MASK;
David Brownell0c5d1eb2008-10-01 14:46:18 -070065 if (type == IRQ_TYPE_NONE)
66 return 0;
67
Thomas Gleixner43abe432011-02-12 12:10:49 +010068 chip_bus_lock(desc);
Thomas Gleixner239007b2009-11-17 16:46:45 +010069 raw_spin_lock_irqsave(&desc->lock, flags);
Chris Friesen0b3682ba32008-10-20 12:41:58 -060070 ret = __irq_set_trigger(desc, irq, type);
Thomas Gleixner239007b2009-11-17 16:46:45 +010071 raw_spin_unlock_irqrestore(&desc->lock, flags);
Thomas Gleixner43abe432011-02-12 12:10:49 +010072 chip_bus_sync_unlock(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070073 return ret;
74}
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010075EXPORT_SYMBOL(irq_set_irq_type);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070076
77/**
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010078 * irq_set_handler_data - set irq handler data for an irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070079 * @irq: Interrupt number
80 * @data: Pointer to interrupt specific data
81 *
82 * Set the hardware irq controller data for an irq
83 */
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010084int irq_set_handler_data(unsigned int irq, void *data)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070085{
Thomas Gleixnerd3c60042008-10-16 09:55:00 +020086 struct irq_desc *desc = irq_to_desc(irq);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070087 unsigned long flags;
88
Yinghai Lu7d94f7c2008-08-19 20:50:14 -070089 if (!desc) {
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070090 printk(KERN_ERR
91 "Trying to install controller data for IRQ%d\n", irq);
92 return -EINVAL;
93 }
94
Thomas Gleixner239007b2009-11-17 16:46:45 +010095 raw_spin_lock_irqsave(&desc->lock, flags);
Thomas Gleixner6b8ff312010-10-01 12:58:38 +020096 desc->irq_data.handler_data = data;
Thomas Gleixner239007b2009-11-17 16:46:45 +010097 raw_spin_unlock_irqrestore(&desc->lock, flags);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070098 return 0;
99}
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +0100100EXPORT_SYMBOL(irq_set_handler_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700101
102/**
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +0100103 * irq_set_msi_desc - set MSI descriptor data for an irq
Eric W. Biederman5b912c12007-01-28 12:52:03 -0700104 * @irq: Interrupt number
Randy Dunlap472900b2007-02-16 01:28:25 -0800105 * @entry: Pointer to MSI descriptor data
Eric W. Biederman5b912c12007-01-28 12:52:03 -0700106 *
Liuweni24b26d42009-11-04 20:11:05 +0800107 * Set the MSI descriptor entry for an irq
Eric W. Biederman5b912c12007-01-28 12:52:03 -0700108 */
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +0100109int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
Eric W. Biederman5b912c12007-01-28 12:52:03 -0700110{
Thomas Gleixnerd3c60042008-10-16 09:55:00 +0200111 struct irq_desc *desc = irq_to_desc(irq);
Eric W. Biederman5b912c12007-01-28 12:52:03 -0700112 unsigned long flags;
113
Yinghai Lu7d94f7c2008-08-19 20:50:14 -0700114 if (!desc) {
Eric W. Biederman5b912c12007-01-28 12:52:03 -0700115 printk(KERN_ERR
116 "Trying to install msi data for IRQ%d\n", irq);
117 return -EINVAL;
118 }
Yinghai Lu7d94f7c2008-08-19 20:50:14 -0700119
Thomas Gleixner239007b2009-11-17 16:46:45 +0100120 raw_spin_lock_irqsave(&desc->lock, flags);
Thomas Gleixner6b8ff312010-10-01 12:58:38 +0200121 desc->irq_data.msi_desc = entry;
Michael Ellerman7fe37302007-04-18 19:39:21 +1000122 if (entry)
123 entry->irq = irq;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100124 raw_spin_unlock_irqrestore(&desc->lock, flags);
Eric W. Biederman5b912c12007-01-28 12:52:03 -0700125 return 0;
126}
127
128/**
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +0100129 * irq_set_chip_data - set irq chip data for an irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700130 * @irq: Interrupt number
131 * @data: Pointer to chip specific data
132 *
133 * Set the hardware irq chip data for an irq
134 */
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +0100135int irq_set_chip_data(unsigned int irq, void *data)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700136{
Thomas Gleixnerd3c60042008-10-16 09:55:00 +0200137 struct irq_desc *desc = irq_to_desc(irq);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700138 unsigned long flags;
139
Yinghai Lu7d94f7c2008-08-19 20:50:14 -0700140 if (!desc) {
141 printk(KERN_ERR
142 "Trying to install chip data for IRQ%d\n", irq);
143 return -EINVAL;
144 }
145
Thomas Gleixner6b8ff312010-10-01 12:58:38 +0200146 if (!desc->irq_data.chip) {
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700147 printk(KERN_ERR "BUG: bad set_irq_chip_data(IRQ#%d)\n", irq);
148 return -EINVAL;
149 }
150
Thomas Gleixner239007b2009-11-17 16:46:45 +0100151 raw_spin_lock_irqsave(&desc->lock, flags);
Thomas Gleixner6b8ff312010-10-01 12:58:38 +0200152 desc->irq_data.chip_data = data;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100153 raw_spin_unlock_irqrestore(&desc->lock, flags);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700154
155 return 0;
156}
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +0100157EXPORT_SYMBOL(irq_set_chip_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700158
Thomas Gleixnerf303a6d2010-09-28 17:34:01 +0200159struct irq_data *irq_get_irq_data(unsigned int irq)
160{
161 struct irq_desc *desc = irq_to_desc(irq);
162
163 return desc ? &desc->irq_data : NULL;
164}
165EXPORT_SYMBOL_GPL(irq_get_irq_data);
166
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200167/**
168 * set_irq_nested_thread - Set/Reset the IRQ_NESTED_THREAD flag of an irq
169 *
170 * @irq: Interrupt number
171 * @nest: 0 to clear / 1 to set the IRQ_NESTED_THREAD flag
172 *
173 * The IRQ_NESTED_THREAD flag indicates that on
174 * request_threaded_irq() no separate interrupt thread should be
175 * created for the irq as the handler are called nested in the
176 * context of a demultiplexing interrupt handler thread.
177 */
178void set_irq_nested_thread(unsigned int irq, int nest)
179{
180 struct irq_desc *desc = irq_to_desc(irq);
181 unsigned long flags;
182
183 if (!desc)
184 return;
185
Thomas Gleixner239007b2009-11-17 16:46:45 +0100186 raw_spin_lock_irqsave(&desc->lock, flags);
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200187 if (nest)
188 desc->status |= IRQ_NESTED_THREAD;
189 else
190 desc->status &= ~IRQ_NESTED_THREAD;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100191 raw_spin_unlock_irqrestore(&desc->lock, flags);
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200192}
193EXPORT_SYMBOL_GPL(set_irq_nested_thread);
194
Thomas Gleixner46999232011-02-02 21:41:14 +0000195int irq_startup(struct irq_desc *desc)
196{
197 desc->status &= ~(IRQ_MASKED | IRQ_DISABLED);
198 desc->depth = 0;
199
200 if (desc->irq_data.chip->irq_startup)
201 return desc->irq_data.chip->irq_startup(&desc->irq_data);
202
Thomas Gleixner87923472011-02-03 12:27:44 +0100203 irq_enable(desc);
Thomas Gleixner46999232011-02-02 21:41:14 +0000204 return 0;
205}
206
207void irq_shutdown(struct irq_desc *desc)
208{
209 desc->status |= IRQ_MASKED | IRQ_DISABLED;
210 desc->depth = 1;
Thomas Gleixner50f7c032011-02-03 13:23:54 +0100211 if (desc->irq_data.chip->irq_shutdown)
212 desc->irq_data.chip->irq_shutdown(&desc->irq_data);
213 if (desc->irq_data.chip->irq_disable)
214 desc->irq_data.chip->irq_disable(&desc->irq_data);
215 else
216 desc->irq_data.chip->irq_mask(&desc->irq_data);
Thomas Gleixner46999232011-02-02 21:41:14 +0000217}
218
Thomas Gleixner87923472011-02-03 12:27:44 +0100219void irq_enable(struct irq_desc *desc)
220{
Thomas Gleixner50f7c032011-02-03 13:23:54 +0100221 if (desc->irq_data.chip->irq_enable)
222 desc->irq_data.chip->irq_enable(&desc->irq_data);
223 else
224 desc->irq_data.chip->irq_unmask(&desc->irq_data);
225 desc->status &= ~IRQ_MASKED;
Thomas Gleixner87923472011-02-03 12:27:44 +0100226}
227
228void irq_disable(struct irq_desc *desc)
229{
Thomas Gleixner50f7c032011-02-03 13:23:54 +0100230 if (desc->irq_data.chip->irq_disable) {
231 desc->irq_data.chip->irq_disable(&desc->irq_data);
232 desc->status |= IRQ_MASKED;
233 }
Thomas Gleixner89d694b2008-02-18 18:25:17 +0100234}
235
Thomas Gleixnerbd151412010-10-01 15:17:14 +0200236#ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
Thomas Gleixner3876ec92010-09-27 12:44:35 +0000237/* Temporary migration helpers */
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000238static void compat_irq_mask(struct irq_data *data)
239{
240 data->chip->mask(data->irq);
241}
242
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000243static void compat_irq_unmask(struct irq_data *data)
244{
245 data->chip->unmask(data->irq);
246}
247
Thomas Gleixner22a49162010-09-27 12:44:47 +0000248static void compat_irq_ack(struct irq_data *data)
249{
250 data->chip->ack(data->irq);
251}
252
Thomas Gleixner9205e312010-09-27 12:44:50 +0000253static void compat_irq_mask_ack(struct irq_data *data)
254{
255 data->chip->mask_ack(data->irq);
256}
257
Thomas Gleixner0c5c1552010-09-27 12:44:53 +0000258static void compat_irq_eoi(struct irq_data *data)
259{
260 data->chip->eoi(data->irq);
261}
262
Thomas Gleixnerc5f75632010-09-27 12:44:56 +0000263static void compat_irq_enable(struct irq_data *data)
264{
265 data->chip->enable(data->irq);
266}
267
Thomas Gleixnerbc310dd2010-09-27 12:45:02 +0000268static void compat_irq_disable(struct irq_data *data)
269{
270 data->chip->disable(data->irq);
271}
272
273static void compat_irq_shutdown(struct irq_data *data)
274{
275 data->chip->shutdown(data->irq);
276}
277
Thomas Gleixner37e12df2010-09-27 12:45:38 +0000278static unsigned int compat_irq_startup(struct irq_data *data)
279{
280 return data->chip->startup(data->irq);
281}
282
Thomas Gleixnerc96b3b32010-09-27 12:45:41 +0000283static int compat_irq_set_affinity(struct irq_data *data,
284 const struct cpumask *dest, bool force)
285{
286 return data->chip->set_affinity(data->irq, dest);
287}
288
Thomas Gleixnerb2ba2c32010-09-27 12:45:47 +0000289static int compat_irq_set_type(struct irq_data *data, unsigned int type)
290{
291 return data->chip->set_type(data->irq, type);
292}
293
Thomas Gleixner2f7e99b2010-09-27 12:45:50 +0000294static int compat_irq_set_wake(struct irq_data *data, unsigned int on)
295{
296 return data->chip->set_wake(data->irq, on);
297}
298
Thomas Gleixner21e2b8c2010-09-27 12:45:53 +0000299static int compat_irq_retrigger(struct irq_data *data)
300{
301 return data->chip->retrigger(data->irq);
302}
303
Thomas Gleixner3876ec92010-09-27 12:44:35 +0000304static void compat_bus_lock(struct irq_data *data)
305{
306 data->chip->bus_lock(data->irq);
307}
308
309static void compat_bus_sync_unlock(struct irq_data *data)
310{
311 data->chip->bus_sync_unlock(data->irq);
312}
Thomas Gleixnerbd151412010-10-01 15:17:14 +0200313#endif
Thomas Gleixner3876ec92010-09-27 12:44:35 +0000314
Thomas Gleixner89d694b2008-02-18 18:25:17 +0100315/*
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700316 * Fixup enable/disable function pointers
317 */
318void irq_chip_set_defaults(struct irq_chip *chip)
319{
Thomas Gleixnerbd151412010-10-01 15:17:14 +0200320#ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
Thomas Gleixnerc5f75632010-09-27 12:44:56 +0000321 if (chip->enable)
322 chip->irq_enable = compat_irq_enable;
Thomas Gleixnerbc310dd2010-09-27 12:45:02 +0000323 if (chip->disable)
324 chip->irq_disable = compat_irq_disable;
325 if (chip->shutdown)
326 chip->irq_shutdown = compat_irq_shutdown;
Thomas Gleixner37e12df2010-09-27 12:45:38 +0000327 if (chip->startup)
328 chip->irq_startup = compat_irq_startup;
Zhang, Yanminb86432b2006-11-16 01:19:10 -0800329 if (!chip->end)
330 chip->end = dummy_irq_chip.end;
Thomas Gleixner3876ec92010-09-27 12:44:35 +0000331 if (chip->bus_lock)
332 chip->irq_bus_lock = compat_bus_lock;
333 if (chip->bus_sync_unlock)
334 chip->irq_bus_sync_unlock = compat_bus_sync_unlock;
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000335 if (chip->mask)
336 chip->irq_mask = compat_irq_mask;
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000337 if (chip->unmask)
338 chip->irq_unmask = compat_irq_unmask;
Thomas Gleixner22a49162010-09-27 12:44:47 +0000339 if (chip->ack)
340 chip->irq_ack = compat_irq_ack;
Thomas Gleixner9205e312010-09-27 12:44:50 +0000341 if (chip->mask_ack)
342 chip->irq_mask_ack = compat_irq_mask_ack;
Thomas Gleixner0c5c1552010-09-27 12:44:53 +0000343 if (chip->eoi)
344 chip->irq_eoi = compat_irq_eoi;
Thomas Gleixnerc96b3b32010-09-27 12:45:41 +0000345 if (chip->set_affinity)
346 chip->irq_set_affinity = compat_irq_set_affinity;
Thomas Gleixnerb2ba2c32010-09-27 12:45:47 +0000347 if (chip->set_type)
348 chip->irq_set_type = compat_irq_set_type;
Thomas Gleixner2f7e99b2010-09-27 12:45:50 +0000349 if (chip->set_wake)
350 chip->irq_set_wake = compat_irq_set_wake;
Thomas Gleixner21e2b8c2010-09-27 12:45:53 +0000351 if (chip->retrigger)
352 chip->irq_retrigger = compat_irq_retrigger;
Thomas Gleixnerbd151412010-10-01 15:17:14 +0200353#endif
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700354}
355
Thomas Gleixner9205e312010-09-27 12:44:50 +0000356static inline void mask_ack_irq(struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700357{
Thomas Gleixner9205e312010-09-27 12:44:50 +0000358 if (desc->irq_data.chip->irq_mask_ack)
359 desc->irq_data.chip->irq_mask_ack(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700360 else {
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000361 desc->irq_data.chip->irq_mask(&desc->irq_data);
Thomas Gleixner22a49162010-09-27 12:44:47 +0000362 if (desc->irq_data.chip->irq_ack)
363 desc->irq_data.chip->irq_ack(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700364 }
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100365 desc->status |= IRQ_MASKED;
366}
367
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000368static inline void mask_irq(struct irq_desc *desc)
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100369{
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000370 if (desc->irq_data.chip->irq_mask) {
371 desc->irq_data.chip->irq_mask(&desc->irq_data);
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100372 desc->status |= IRQ_MASKED;
373 }
374}
375
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000376static inline void unmask_irq(struct irq_desc *desc)
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100377{
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000378 if (desc->irq_data.chip->irq_unmask) {
379 desc->irq_data.chip->irq_unmask(&desc->irq_data);
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100380 desc->status &= ~IRQ_MASKED;
381 }
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700382}
383
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200384/*
385 * handle_nested_irq - Handle a nested irq from a irq thread
386 * @irq: the interrupt number
387 *
388 * Handle interrupts which are nested into a threaded interrupt
389 * handler. The handler function is called inside the calling
390 * threads context.
391 */
392void handle_nested_irq(unsigned int irq)
393{
394 struct irq_desc *desc = irq_to_desc(irq);
395 struct irqaction *action;
396 irqreturn_t action_ret;
397
398 might_sleep();
399
Thomas Gleixner239007b2009-11-17 16:46:45 +0100400 raw_spin_lock_irq(&desc->lock);
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200401
402 kstat_incr_irqs_this_cpu(irq, desc);
403
404 action = desc->action;
405 if (unlikely(!action || (desc->status & IRQ_DISABLED)))
406 goto out_unlock;
407
408 desc->status |= IRQ_INPROGRESS;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100409 raw_spin_unlock_irq(&desc->lock);
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200410
411 action_ret = action->thread_fn(action->irq, action->dev_id);
412 if (!noirqdebug)
413 note_interrupt(irq, desc, action_ret);
414
Thomas Gleixner239007b2009-11-17 16:46:45 +0100415 raw_spin_lock_irq(&desc->lock);
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200416 desc->status &= ~IRQ_INPROGRESS;
417
418out_unlock:
Thomas Gleixner239007b2009-11-17 16:46:45 +0100419 raw_spin_unlock_irq(&desc->lock);
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200420}
421EXPORT_SYMBOL_GPL(handle_nested_irq);
422
Thomas Gleixnerfe200ae2011-02-07 10:34:30 +0100423static bool irq_check_poll(struct irq_desc *desc)
424{
425 if (!(desc->status & IRQ_POLL_INPROGRESS))
426 return false;
427 return irq_wait_for_poll(desc);
428}
429
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700430/**
431 * handle_simple_irq - Simple and software-decoded IRQs.
432 * @irq: the interrupt number
433 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700434 *
435 * Simple interrupts are either sent from a demultiplexing interrupt
436 * handler or come from hardware, where no interrupt hardware control
437 * is necessary.
438 *
439 * Note: The caller is expected to handle the ack, clear, mask and
440 * unmask issues if necessary.
441 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800442void
David Howells7d12e782006-10-05 14:55:46 +0100443handle_simple_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700444{
445 struct irqaction *action;
446 irqreturn_t action_ret;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700447
Thomas Gleixner239007b2009-11-17 16:46:45 +0100448 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700449
450 if (unlikely(desc->status & IRQ_INPROGRESS))
Thomas Gleixnerfe200ae2011-02-07 10:34:30 +0100451 if (!irq_check_poll(desc))
452 goto out_unlock;
453
Steven Rostedt971e5b35f2007-12-18 18:05:58 +0100454 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200455 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700456
457 action = desc->action;
Steven Rostedt971e5b35f2007-12-18 18:05:58 +0100458 if (unlikely(!action || (desc->status & IRQ_DISABLED)))
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700459 goto out_unlock;
460
461 desc->status |= IRQ_INPROGRESS;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100462 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700463
David Howells7d12e782006-10-05 14:55:46 +0100464 action_ret = handle_IRQ_event(irq, action);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700465 if (!noirqdebug)
David Howells7d12e782006-10-05 14:55:46 +0100466 note_interrupt(irq, desc, action_ret);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700467
Thomas Gleixner239007b2009-11-17 16:46:45 +0100468 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700469 desc->status &= ~IRQ_INPROGRESS;
470out_unlock:
Thomas Gleixner239007b2009-11-17 16:46:45 +0100471 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700472}
473
474/**
475 * handle_level_irq - Level type irq handler
476 * @irq: the interrupt number
477 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700478 *
479 * Level type interrupts are active as long as the hardware line has
480 * the active level. This may require to mask the interrupt and unmask
481 * it after the associated handler has acknowledged the device, so the
482 * interrupt line is back to inactive.
483 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800484void
David Howells7d12e782006-10-05 14:55:46 +0100485handle_level_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700486{
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700487 struct irqaction *action;
488 irqreturn_t action_ret;
489
Thomas Gleixner239007b2009-11-17 16:46:45 +0100490 raw_spin_lock(&desc->lock);
Thomas Gleixner9205e312010-09-27 12:44:50 +0000491 mask_ack_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700492
493 if (unlikely(desc->status & IRQ_INPROGRESS))
Thomas Gleixnerfe200ae2011-02-07 10:34:30 +0100494 if (!irq_check_poll(desc))
495 goto out_unlock;
496
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700497 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200498 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700499
500 /*
501 * If its disabled or no action available
502 * keep it masked and get out of here
503 */
504 action = desc->action;
Thomas Gleixner49663422007-08-12 15:46:34 +0000505 if (unlikely(!action || (desc->status & IRQ_DISABLED)))
Ingo Molnar86998aa2006-09-19 11:14:34 +0200506 goto out_unlock;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700507
508 desc->status |= IRQ_INPROGRESS;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100509 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700510
David Howells7d12e782006-10-05 14:55:46 +0100511 action_ret = handle_IRQ_event(irq, action);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700512 if (!noirqdebug)
David Howells7d12e782006-10-05 14:55:46 +0100513 note_interrupt(irq, desc, action_ret);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700514
Thomas Gleixner239007b2009-11-17 16:46:45 +0100515 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700516 desc->status &= ~IRQ_INPROGRESS;
Thomas Gleixnerb25c3402009-08-13 12:17:22 +0200517
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100518 if (!(desc->status & (IRQ_DISABLED | IRQ_ONESHOT)))
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000519 unmask_irq(desc);
Ingo Molnar86998aa2006-09-19 11:14:34 +0200520out_unlock:
Thomas Gleixner239007b2009-11-17 16:46:45 +0100521 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700522}
Ingo Molnar14819ea2009-01-14 12:34:21 +0100523EXPORT_SYMBOL_GPL(handle_level_irq);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700524
525/**
Ingo Molnar47c2a3a2006-06-29 02:25:03 -0700526 * handle_fasteoi_irq - irq handler for transparent controllers
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700527 * @irq: the interrupt number
528 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700529 *
Ingo Molnar47c2a3a2006-06-29 02:25:03 -0700530 * Only a single callback will be issued to the chip: an ->eoi()
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700531 * call when the interrupt has been serviced. This enables support
532 * for modern forms of interrupt handlers, which handle the flow
533 * details in hardware, transparently.
534 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800535void
David Howells7d12e782006-10-05 14:55:46 +0100536handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700537{
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700538 struct irqaction *action;
539 irqreturn_t action_ret;
540
Thomas Gleixner239007b2009-11-17 16:46:45 +0100541 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700542
543 if (unlikely(desc->status & IRQ_INPROGRESS))
Thomas Gleixnerfe200ae2011-02-07 10:34:30 +0100544 if (!irq_check_poll(desc))
545 goto out;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700546
547 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200548 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700549
550 /*
551 * If its disabled or no action available
Ingo Molnar76d21602007-02-16 01:28:24 -0800552 * then mask it and get out of here:
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700553 */
554 action = desc->action;
Benjamin Herrenschmidt98bb2442006-06-29 02:25:01 -0700555 if (unlikely(!action || (desc->status & IRQ_DISABLED))) {
556 desc->status |= IRQ_PENDING;
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000557 mask_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700558 goto out;
Benjamin Herrenschmidt98bb2442006-06-29 02:25:01 -0700559 }
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700560
561 desc->status |= IRQ_INPROGRESS;
Benjamin Herrenschmidt98bb2442006-06-29 02:25:01 -0700562 desc->status &= ~IRQ_PENDING;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100563 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700564
David Howells7d12e782006-10-05 14:55:46 +0100565 action_ret = handle_IRQ_event(irq, action);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700566 if (!noirqdebug)
David Howells7d12e782006-10-05 14:55:46 +0100567 note_interrupt(irq, desc, action_ret);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700568
Thomas Gleixner239007b2009-11-17 16:46:45 +0100569 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700570 desc->status &= ~IRQ_INPROGRESS;
571out:
Thomas Gleixner0c5c1552010-09-27 12:44:53 +0000572 desc->irq_data.chip->irq_eoi(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700573
Thomas Gleixner239007b2009-11-17 16:46:45 +0100574 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700575}
576
577/**
578 * handle_edge_irq - edge type IRQ handler
579 * @irq: the interrupt number
580 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700581 *
582 * Interrupt occures on the falling and/or rising edge of a hardware
583 * signal. The occurence is latched into the irq controller hardware
584 * and must be acked in order to be reenabled. After the ack another
585 * interrupt can happen on the same source even before the first one
Uwe Kleine-Königdfff0612010-02-12 21:58:11 +0100586 * is handled by the associated event handler. If this happens it
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700587 * might be necessary to disable (mask) the interrupt depending on the
588 * controller hardware. This requires to reenable the interrupt inside
589 * of the loop which handles the interrupts which have arrived while
590 * the handler was running. If all pending interrupts are handled, the
591 * loop is left.
592 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800593void
David Howells7d12e782006-10-05 14:55:46 +0100594handle_edge_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700595{
Thomas Gleixner239007b2009-11-17 16:46:45 +0100596 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700597
598 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
599
600 /*
601 * If we're currently running this IRQ, or its disabled,
602 * we shouldn't process the IRQ. Mark it pending, handle
603 * the necessary masking and go out
604 */
605 if (unlikely((desc->status & (IRQ_INPROGRESS | IRQ_DISABLED)) ||
606 !desc->action)) {
Thomas Gleixnerfe200ae2011-02-07 10:34:30 +0100607 if (!irq_check_poll(desc)) {
608 desc->status |= (IRQ_PENDING | IRQ_MASKED);
609 mask_ack_irq(desc);
610 goto out_unlock;
611 }
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700612 }
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200613 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700614
615 /* Start handling the irq */
Thomas Gleixner22a49162010-09-27 12:44:47 +0000616 desc->irq_data.chip->irq_ack(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700617
618 /* Mark the IRQ currently in progress.*/
619 desc->status |= IRQ_INPROGRESS;
620
621 do {
622 struct irqaction *action = desc->action;
623 irqreturn_t action_ret;
624
625 if (unlikely(!action)) {
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000626 mask_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700627 goto out_unlock;
628 }
629
630 /*
631 * When another irq arrived while we were handling
632 * one, we could have masked the irq.
633 * Renable it, if it was not disabled in meantime.
634 */
635 if (unlikely((desc->status &
636 (IRQ_PENDING | IRQ_MASKED | IRQ_DISABLED)) ==
637 (IRQ_PENDING | IRQ_MASKED))) {
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000638 unmask_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700639 }
640
641 desc->status &= ~IRQ_PENDING;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100642 raw_spin_unlock(&desc->lock);
David Howells7d12e782006-10-05 14:55:46 +0100643 action_ret = handle_IRQ_event(irq, action);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700644 if (!noirqdebug)
David Howells7d12e782006-10-05 14:55:46 +0100645 note_interrupt(irq, desc, action_ret);
Thomas Gleixner239007b2009-11-17 16:46:45 +0100646 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700647
648 } while ((desc->status & (IRQ_PENDING | IRQ_DISABLED)) == IRQ_PENDING);
649
650 desc->status &= ~IRQ_INPROGRESS;
651out_unlock:
Thomas Gleixner239007b2009-11-17 16:46:45 +0100652 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700653}
654
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700655/**
Liuweni24b26d42009-11-04 20:11:05 +0800656 * handle_percpu_irq - Per CPU local irq handler
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700657 * @irq: the interrupt number
658 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700659 *
660 * Per CPU interrupts on SMP machines without locking requirements
661 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800662void
David Howells7d12e782006-10-05 14:55:46 +0100663handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700664{
665 irqreturn_t action_ret;
666
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200667 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700668
Thomas Gleixner22a49162010-09-27 12:44:47 +0000669 if (desc->irq_data.chip->irq_ack)
670 desc->irq_data.chip->irq_ack(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700671
David Howells7d12e782006-10-05 14:55:46 +0100672 action_ret = handle_IRQ_event(irq, desc->action);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700673 if (!noirqdebug)
David Howells7d12e782006-10-05 14:55:46 +0100674 note_interrupt(irq, desc, action_ret);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700675
Thomas Gleixner0c5c1552010-09-27 12:44:53 +0000676 if (desc->irq_data.chip->irq_eoi)
677 desc->irq_data.chip->irq_eoi(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700678}
679
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700680void
Ingo Molnara460e742006-10-17 00:10:03 -0700681__set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
682 const char *name)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700683{
Thomas Gleixnerd3c60042008-10-16 09:55:00 +0200684 struct irq_desc *desc = irq_to_desc(irq);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700685 unsigned long flags;
686
Yinghai Lu7d94f7c2008-08-19 20:50:14 -0700687 if (!desc) {
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700688 printk(KERN_ERR
689 "Trying to install type control for IRQ%d\n", irq);
690 return;
691 }
692
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700693 if (!handle)
694 handle = handle_bad_irq;
Thomas Gleixner6b8ff312010-10-01 12:58:38 +0200695 else if (desc->irq_data.chip == &no_irq_chip) {
Thomas Gleixnerf8b54732006-07-01 22:30:08 +0100696 printk(KERN_WARNING "Trying to install %sinterrupt handler "
Geert Uytterhoevenb039db82006-12-20 15:59:48 +0100697 "for IRQ%d\n", is_chained ? "chained " : "", irq);
Thomas Gleixnerf8b54732006-07-01 22:30:08 +0100698 /*
699 * Some ARM implementations install a handler for really dumb
700 * interrupt hardware without setting an irq_chip. This worked
701 * with the ARM no_irq_chip but the check in setup_irq would
702 * prevent us to setup the interrupt at all. Switch it to
703 * dummy_irq_chip for easy transition.
704 */
Thomas Gleixner6b8ff312010-10-01 12:58:38 +0200705 desc->irq_data.chip = &dummy_irq_chip;
Thomas Gleixnerf8b54732006-07-01 22:30:08 +0100706 }
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700707
Thomas Gleixner3876ec92010-09-27 12:44:35 +0000708 chip_bus_lock(desc);
Thomas Gleixner239007b2009-11-17 16:46:45 +0100709 raw_spin_lock_irqsave(&desc->lock, flags);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700710
711 /* Uninstall? */
712 if (handle == handle_bad_irq) {
Thomas Gleixner6b8ff312010-10-01 12:58:38 +0200713 if (desc->irq_data.chip != &no_irq_chip)
Thomas Gleixner9205e312010-09-27 12:44:50 +0000714 mask_ack_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700715 desc->status |= IRQ_DISABLED;
716 desc->depth = 1;
717 }
718 desc->handle_irq = handle;
Ingo Molnara460e742006-10-17 00:10:03 -0700719 desc->name = name;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700720
721 if (handle != handle_bad_irq && is_chained) {
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700722 desc->status |= IRQ_NOREQUEST | IRQ_NOPROBE;
Thomas Gleixner46999232011-02-02 21:41:14 +0000723 irq_startup(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700724 }
Thomas Gleixner239007b2009-11-17 16:46:45 +0100725 raw_spin_unlock_irqrestore(&desc->lock, flags);
Thomas Gleixner3876ec92010-09-27 12:44:35 +0000726 chip_bus_sync_unlock(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700727}
Ingo Molnar14819ea2009-01-14 12:34:21 +0100728EXPORT_SYMBOL_GPL(__set_irq_handler);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700729
730void
731set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip,
David Howells57a58a92006-10-05 13:06:34 +0100732 irq_flow_handler_t handle)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700733{
734 set_irq_chip(irq, chip);
Ingo Molnara460e742006-10-17 00:10:03 -0700735 __set_irq_handler(irq, handle, 0, NULL);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700736}
737
Ingo Molnara460e742006-10-17 00:10:03 -0700738void
739set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
740 irq_flow_handler_t handle, const char *name)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700741{
Ingo Molnara460e742006-10-17 00:10:03 -0700742 set_irq_chip(irq, chip);
743 __set_irq_handler(irq, handle, 0, name);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700744}
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800745
Thomas Gleixner44247182010-09-28 10:40:18 +0200746void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800747{
Thomas Gleixnerd3c60042008-10-16 09:55:00 +0200748 struct irq_desc *desc = irq_to_desc(irq);
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800749 unsigned long flags;
750
Thomas Gleixner44247182010-09-28 10:40:18 +0200751 if (!desc)
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800752 return;
Thomas Gleixner44247182010-09-28 10:40:18 +0200753
754 /* Sanitize flags */
755 set &= IRQF_MODIFY_MASK;
756 clr &= IRQF_MODIFY_MASK;
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800757
Thomas Gleixner239007b2009-11-17 16:46:45 +0100758 raw_spin_lock_irqsave(&desc->lock, flags);
Thomas Gleixner44247182010-09-28 10:40:18 +0200759 desc->status &= ~clr;
760 desc->status |= set;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100761 raw_spin_unlock_irqrestore(&desc->lock, flags);
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800762}