blob: 9639ab8bece037be4c3dbdd2df4348c39a8858ed [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 Gleixnerdd87eb32006-06-29 02:24:53 -070022 * set_irq_chip - set the irq chip for an irq
23 * @irq: irq number
24 * @chip: pointer to irq chip description structure
25 */
26int set_irq_chip(unsigned int irq, struct irq_chip *chip)
27{
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}
46EXPORT_SYMBOL(set_irq_chip);
47
48/**
David Brownell0c5d1eb2008-10-01 14:46:18 -070049 * set_irq_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 */
53int set_irq_type(unsigned int irq, unsigned int type)
54{
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}
75EXPORT_SYMBOL(set_irq_type);
76
77/**
78 * set_irq_data - set irq type data for an irq
79 * @irq: Interrupt number
80 * @data: Pointer to interrupt specific data
81 *
82 * Set the hardware irq controller data for an irq
83 */
84int set_irq_data(unsigned int irq, void *data)
85{
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}
100EXPORT_SYMBOL(set_irq_data);
101
102/**
Liuweni24b26d42009-11-04 20:11:05 +0800103 * set_irq_msi - 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 */
109int set_irq_msi(unsigned int irq, struct msi_desc *entry)
110{
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 Gleixnerdd87eb32006-06-29 02:24:53 -0700129 * set_irq_chip_data - set irq chip data for an irq
130 * @irq: Interrupt number
131 * @data: Pointer to chip specific data
132 *
133 * Set the hardware irq chip data for an irq
134 */
135int set_irq_chip_data(unsigned int irq, void *data)
136{
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}
157EXPORT_SYMBOL(set_irq_chip_data);
158
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 Gleixnerdd87eb32006-06-29 02:24:53 -0700195/*
196 * default enable function
197 */
Thomas Gleixnerc5f75632010-09-27 12:44:56 +0000198static void default_enable(struct irq_data *data)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700199{
Thomas Gleixnerc5f75632010-09-27 12:44:56 +0000200 struct irq_desc *desc = irq_data_to_desc(data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700201
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000202 desc->irq_data.chip->irq_unmask(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700203 desc->status &= ~IRQ_MASKED;
204}
205
206/*
207 * default disable function
208 */
Thomas Gleixnerbc310dd2010-09-27 12:45:02 +0000209static void default_disable(struct irq_data *data)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700210{
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700211}
212
213/*
214 * default startup function
215 */
Thomas Gleixner37e12df2010-09-27 12:45:38 +0000216static unsigned int default_startup(struct irq_data *data)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700217{
Thomas Gleixner37e12df2010-09-27 12:45:38 +0000218 struct irq_desc *desc = irq_data_to_desc(data);
Yinghai Lu08678b02008-08-19 20:50:05 -0700219
Thomas Gleixner37e12df2010-09-27 12:45:38 +0000220 desc->irq_data.chip->irq_enable(data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700221 return 0;
222}
223
224/*
Thomas Gleixner89d694b2008-02-18 18:25:17 +0100225 * default shutdown function
226 */
Thomas Gleixnerbc310dd2010-09-27 12:45:02 +0000227static void default_shutdown(struct irq_data *data)
Thomas Gleixner89d694b2008-02-18 18:25:17 +0100228{
Thomas Gleixnerbc310dd2010-09-27 12:45:02 +0000229 struct irq_desc *desc = irq_data_to_desc(data);
Thomas Gleixner89d694b2008-02-18 18:25:17 +0100230
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000231 desc->irq_data.chip->irq_mask(&desc->irq_data);
Thomas Gleixner89d694b2008-02-18 18:25:17 +0100232 desc->status |= IRQ_MASKED;
233}
234
Thomas Gleixnerbd151412010-10-01 15:17:14 +0200235#ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
Thomas Gleixner3876ec92010-09-27 12:44:35 +0000236/* Temporary migration helpers */
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000237static void compat_irq_mask(struct irq_data *data)
238{
239 data->chip->mask(data->irq);
240}
241
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000242static void compat_irq_unmask(struct irq_data *data)
243{
244 data->chip->unmask(data->irq);
245}
246
Thomas Gleixner22a49162010-09-27 12:44:47 +0000247static void compat_irq_ack(struct irq_data *data)
248{
249 data->chip->ack(data->irq);
250}
251
Thomas Gleixner9205e312010-09-27 12:44:50 +0000252static void compat_irq_mask_ack(struct irq_data *data)
253{
254 data->chip->mask_ack(data->irq);
255}
256
Thomas Gleixner0c5c1552010-09-27 12:44:53 +0000257static void compat_irq_eoi(struct irq_data *data)
258{
259 data->chip->eoi(data->irq);
260}
261
Thomas Gleixnerc5f75632010-09-27 12:44:56 +0000262static void compat_irq_enable(struct irq_data *data)
263{
264 data->chip->enable(data->irq);
265}
266
Thomas Gleixnerbc310dd2010-09-27 12:45:02 +0000267static void compat_irq_disable(struct irq_data *data)
268{
269 data->chip->disable(data->irq);
270}
271
272static void compat_irq_shutdown(struct irq_data *data)
273{
274 data->chip->shutdown(data->irq);
275}
276
Thomas Gleixner37e12df2010-09-27 12:45:38 +0000277static unsigned int compat_irq_startup(struct irq_data *data)
278{
279 return data->chip->startup(data->irq);
280}
281
Thomas Gleixnerc96b3b32010-09-27 12:45:41 +0000282static int compat_irq_set_affinity(struct irq_data *data,
283 const struct cpumask *dest, bool force)
284{
285 return data->chip->set_affinity(data->irq, dest);
286}
287
Thomas Gleixnerb2ba2c32010-09-27 12:45:47 +0000288static int compat_irq_set_type(struct irq_data *data, unsigned int type)
289{
290 return data->chip->set_type(data->irq, type);
291}
292
Thomas Gleixner2f7e99b2010-09-27 12:45:50 +0000293static int compat_irq_set_wake(struct irq_data *data, unsigned int on)
294{
295 return data->chip->set_wake(data->irq, on);
296}
297
Thomas Gleixner21e2b8c2010-09-27 12:45:53 +0000298static int compat_irq_retrigger(struct irq_data *data)
299{
300 return data->chip->retrigger(data->irq);
301}
302
Thomas Gleixner3876ec92010-09-27 12:44:35 +0000303static void compat_bus_lock(struct irq_data *data)
304{
305 data->chip->bus_lock(data->irq);
306}
307
308static void compat_bus_sync_unlock(struct irq_data *data)
309{
310 data->chip->bus_sync_unlock(data->irq);
311}
Thomas Gleixnerbd151412010-10-01 15:17:14 +0200312#endif
Thomas Gleixner3876ec92010-09-27 12:44:35 +0000313
Thomas Gleixner89d694b2008-02-18 18:25:17 +0100314/*
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700315 * Fixup enable/disable function pointers
316 */
317void irq_chip_set_defaults(struct irq_chip *chip)
318{
Thomas Gleixnerbd151412010-10-01 15:17:14 +0200319#ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
Thomas Gleixnerc5f75632010-09-27 12:44:56 +0000320 /*
321 * Compat fixup functions need to be before we set the
322 * defaults for enable/disable/startup/shutdown
323 */
324 if (chip->enable)
325 chip->irq_enable = compat_irq_enable;
Thomas Gleixnerbc310dd2010-09-27 12:45:02 +0000326 if (chip->disable)
327 chip->irq_disable = compat_irq_disable;
328 if (chip->shutdown)
329 chip->irq_shutdown = compat_irq_shutdown;
Thomas Gleixner37e12df2010-09-27 12:45:38 +0000330 if (chip->startup)
331 chip->irq_startup = compat_irq_startup;
Thomas Gleixnerbd151412010-10-01 15:17:14 +0200332#endif
Thomas Gleixnerc5f75632010-09-27 12:44:56 +0000333 /*
334 * The real defaults
335 */
336 if (!chip->irq_enable)
337 chip->irq_enable = default_enable;
Thomas Gleixnerbc310dd2010-09-27 12:45:02 +0000338 if (!chip->irq_disable)
339 chip->irq_disable = default_disable;
Thomas Gleixner37e12df2010-09-27 12:45:38 +0000340 if (!chip->irq_startup)
341 chip->irq_startup = default_startup;
Thomas Gleixner89d694b2008-02-18 18:25:17 +0100342 /*
Thomas Gleixnerbc310dd2010-09-27 12:45:02 +0000343 * We use chip->irq_disable, when the user provided its own. When
344 * we have default_disable set for chip->irq_disable, then we need
Thomas Gleixner89d694b2008-02-18 18:25:17 +0100345 * to use default_shutdown, otherwise the irq line is not
346 * disabled on free_irq():
347 */
Thomas Gleixnerbc310dd2010-09-27 12:45:02 +0000348 if (!chip->irq_shutdown)
349 chip->irq_shutdown = chip->irq_disable != default_disable ?
350 chip->irq_disable : default_shutdown;
Thomas Gleixnerbd151412010-10-01 15:17:14 +0200351
352#ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
Zhang, Yanminb86432b2006-11-16 01:19:10 -0800353 if (!chip->end)
354 chip->end = dummy_irq_chip.end;
Thomas Gleixner3876ec92010-09-27 12:44:35 +0000355
Thomas Gleixnerbc310dd2010-09-27 12:45:02 +0000356 /*
357 * Now fix up the remaining compat handlers
358 */
Thomas Gleixner3876ec92010-09-27 12:44:35 +0000359 if (chip->bus_lock)
360 chip->irq_bus_lock = compat_bus_lock;
361 if (chip->bus_sync_unlock)
362 chip->irq_bus_sync_unlock = compat_bus_sync_unlock;
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000363 if (chip->mask)
364 chip->irq_mask = compat_irq_mask;
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000365 if (chip->unmask)
366 chip->irq_unmask = compat_irq_unmask;
Thomas Gleixner22a49162010-09-27 12:44:47 +0000367 if (chip->ack)
368 chip->irq_ack = compat_irq_ack;
Thomas Gleixner9205e312010-09-27 12:44:50 +0000369 if (chip->mask_ack)
370 chip->irq_mask_ack = compat_irq_mask_ack;
Thomas Gleixner0c5c1552010-09-27 12:44:53 +0000371 if (chip->eoi)
372 chip->irq_eoi = compat_irq_eoi;
Thomas Gleixnerc96b3b32010-09-27 12:45:41 +0000373 if (chip->set_affinity)
374 chip->irq_set_affinity = compat_irq_set_affinity;
Thomas Gleixnerb2ba2c32010-09-27 12:45:47 +0000375 if (chip->set_type)
376 chip->irq_set_type = compat_irq_set_type;
Thomas Gleixner2f7e99b2010-09-27 12:45:50 +0000377 if (chip->set_wake)
378 chip->irq_set_wake = compat_irq_set_wake;
Thomas Gleixner21e2b8c2010-09-27 12:45:53 +0000379 if (chip->retrigger)
380 chip->irq_retrigger = compat_irq_retrigger;
Thomas Gleixnerbd151412010-10-01 15:17:14 +0200381#endif
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700382}
383
Thomas Gleixner9205e312010-09-27 12:44:50 +0000384static inline void mask_ack_irq(struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700385{
Thomas Gleixner9205e312010-09-27 12:44:50 +0000386 if (desc->irq_data.chip->irq_mask_ack)
387 desc->irq_data.chip->irq_mask_ack(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700388 else {
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000389 desc->irq_data.chip->irq_mask(&desc->irq_data);
Thomas Gleixner22a49162010-09-27 12:44:47 +0000390 if (desc->irq_data.chip->irq_ack)
391 desc->irq_data.chip->irq_ack(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700392 }
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100393 desc->status |= IRQ_MASKED;
394}
395
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000396static inline void mask_irq(struct irq_desc *desc)
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100397{
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000398 if (desc->irq_data.chip->irq_mask) {
399 desc->irq_data.chip->irq_mask(&desc->irq_data);
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100400 desc->status |= IRQ_MASKED;
401 }
402}
403
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000404static inline void unmask_irq(struct irq_desc *desc)
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100405{
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000406 if (desc->irq_data.chip->irq_unmask) {
407 desc->irq_data.chip->irq_unmask(&desc->irq_data);
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100408 desc->status &= ~IRQ_MASKED;
409 }
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700410}
411
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200412/*
413 * handle_nested_irq - Handle a nested irq from a irq thread
414 * @irq: the interrupt number
415 *
416 * Handle interrupts which are nested into a threaded interrupt
417 * handler. The handler function is called inside the calling
418 * threads context.
419 */
420void handle_nested_irq(unsigned int irq)
421{
422 struct irq_desc *desc = irq_to_desc(irq);
423 struct irqaction *action;
424 irqreturn_t action_ret;
425
426 might_sleep();
427
Thomas Gleixner239007b2009-11-17 16:46:45 +0100428 raw_spin_lock_irq(&desc->lock);
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200429
430 kstat_incr_irqs_this_cpu(irq, desc);
431
432 action = desc->action;
433 if (unlikely(!action || (desc->status & IRQ_DISABLED)))
434 goto out_unlock;
435
436 desc->status |= IRQ_INPROGRESS;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100437 raw_spin_unlock_irq(&desc->lock);
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200438
439 action_ret = action->thread_fn(action->irq, action->dev_id);
440 if (!noirqdebug)
441 note_interrupt(irq, desc, action_ret);
442
Thomas Gleixner239007b2009-11-17 16:46:45 +0100443 raw_spin_lock_irq(&desc->lock);
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200444 desc->status &= ~IRQ_INPROGRESS;
445
446out_unlock:
Thomas Gleixner239007b2009-11-17 16:46:45 +0100447 raw_spin_unlock_irq(&desc->lock);
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200448}
449EXPORT_SYMBOL_GPL(handle_nested_irq);
450
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700451/**
452 * handle_simple_irq - Simple and software-decoded IRQs.
453 * @irq: the interrupt number
454 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700455 *
456 * Simple interrupts are either sent from a demultiplexing interrupt
457 * handler or come from hardware, where no interrupt hardware control
458 * is necessary.
459 *
460 * Note: The caller is expected to handle the ack, clear, mask and
461 * unmask issues if necessary.
462 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800463void
David Howells7d12e782006-10-05 14:55:46 +0100464handle_simple_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700465{
466 struct irqaction *action;
467 irqreturn_t action_ret;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700468
Thomas Gleixner239007b2009-11-17 16:46:45 +0100469 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700470
471 if (unlikely(desc->status & IRQ_INPROGRESS))
472 goto out_unlock;
Steven Rostedt971e5b35f2007-12-18 18:05:58 +0100473 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200474 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700475
476 action = desc->action;
Steven Rostedt971e5b35f2007-12-18 18:05:58 +0100477 if (unlikely(!action || (desc->status & IRQ_DISABLED)))
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700478 goto out_unlock;
479
480 desc->status |= IRQ_INPROGRESS;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100481 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700482
David Howells7d12e782006-10-05 14:55:46 +0100483 action_ret = handle_IRQ_event(irq, action);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700484 if (!noirqdebug)
David Howells7d12e782006-10-05 14:55:46 +0100485 note_interrupt(irq, desc, action_ret);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700486
Thomas Gleixner239007b2009-11-17 16:46:45 +0100487 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700488 desc->status &= ~IRQ_INPROGRESS;
489out_unlock:
Thomas Gleixner239007b2009-11-17 16:46:45 +0100490 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700491}
492
493/**
494 * handle_level_irq - Level type irq handler
495 * @irq: the interrupt number
496 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700497 *
498 * Level type interrupts are active as long as the hardware line has
499 * the active level. This may require to mask the interrupt and unmask
500 * it after the associated handler has acknowledged the device, so the
501 * interrupt line is back to inactive.
502 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800503void
David Howells7d12e782006-10-05 14:55:46 +0100504handle_level_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700505{
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700506 struct irqaction *action;
507 irqreturn_t action_ret;
508
Thomas Gleixner239007b2009-11-17 16:46:45 +0100509 raw_spin_lock(&desc->lock);
Thomas Gleixner9205e312010-09-27 12:44:50 +0000510 mask_ack_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700511
512 if (unlikely(desc->status & IRQ_INPROGRESS))
Ingo Molnar86998aa2006-09-19 11:14:34 +0200513 goto out_unlock;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700514 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200515 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700516
517 /*
518 * If its disabled or no action available
519 * keep it masked and get out of here
520 */
521 action = desc->action;
Thomas Gleixner49663422007-08-12 15:46:34 +0000522 if (unlikely(!action || (desc->status & IRQ_DISABLED)))
Ingo Molnar86998aa2006-09-19 11:14:34 +0200523 goto out_unlock;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700524
525 desc->status |= IRQ_INPROGRESS;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100526 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700527
David Howells7d12e782006-10-05 14:55:46 +0100528 action_ret = handle_IRQ_event(irq, action);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700529 if (!noirqdebug)
David Howells7d12e782006-10-05 14:55:46 +0100530 note_interrupt(irq, desc, action_ret);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700531
Thomas Gleixner239007b2009-11-17 16:46:45 +0100532 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700533 desc->status &= ~IRQ_INPROGRESS;
Thomas Gleixnerb25c3402009-08-13 12:17:22 +0200534
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100535 if (!(desc->status & (IRQ_DISABLED | IRQ_ONESHOT)))
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000536 unmask_irq(desc);
Ingo Molnar86998aa2006-09-19 11:14:34 +0200537out_unlock:
Thomas Gleixner239007b2009-11-17 16:46:45 +0100538 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700539}
Ingo Molnar14819ea2009-01-14 12:34:21 +0100540EXPORT_SYMBOL_GPL(handle_level_irq);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700541
542/**
Ingo Molnar47c2a3a2006-06-29 02:25:03 -0700543 * handle_fasteoi_irq - irq handler for transparent controllers
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700544 * @irq: the interrupt number
545 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700546 *
Ingo Molnar47c2a3a2006-06-29 02:25:03 -0700547 * Only a single callback will be issued to the chip: an ->eoi()
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700548 * call when the interrupt has been serviced. This enables support
549 * for modern forms of interrupt handlers, which handle the flow
550 * details in hardware, transparently.
551 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800552void
David Howells7d12e782006-10-05 14:55:46 +0100553handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700554{
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700555 struct irqaction *action;
556 irqreturn_t action_ret;
557
Thomas Gleixner239007b2009-11-17 16:46:45 +0100558 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700559
560 if (unlikely(desc->status & IRQ_INPROGRESS))
561 goto out;
562
563 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200564 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700565
566 /*
567 * If its disabled or no action available
Ingo Molnar76d21602007-02-16 01:28:24 -0800568 * then mask it and get out of here:
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700569 */
570 action = desc->action;
Benjamin Herrenschmidt98bb2442006-06-29 02:25:01 -0700571 if (unlikely(!action || (desc->status & IRQ_DISABLED))) {
572 desc->status |= IRQ_PENDING;
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000573 mask_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700574 goto out;
Benjamin Herrenschmidt98bb2442006-06-29 02:25:01 -0700575 }
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700576
577 desc->status |= IRQ_INPROGRESS;
Benjamin Herrenschmidt98bb2442006-06-29 02:25:01 -0700578 desc->status &= ~IRQ_PENDING;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100579 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700580
David Howells7d12e782006-10-05 14:55:46 +0100581 action_ret = handle_IRQ_event(irq, action);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700582 if (!noirqdebug)
David Howells7d12e782006-10-05 14:55:46 +0100583 note_interrupt(irq, desc, action_ret);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700584
Thomas Gleixner239007b2009-11-17 16:46:45 +0100585 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700586 desc->status &= ~IRQ_INPROGRESS;
587out:
Thomas Gleixner0c5c1552010-09-27 12:44:53 +0000588 desc->irq_data.chip->irq_eoi(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700589
Thomas Gleixner239007b2009-11-17 16:46:45 +0100590 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700591}
592
593/**
594 * handle_edge_irq - edge type IRQ handler
595 * @irq: the interrupt number
596 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700597 *
598 * Interrupt occures on the falling and/or rising edge of a hardware
599 * signal. The occurence is latched into the irq controller hardware
600 * and must be acked in order to be reenabled. After the ack another
601 * interrupt can happen on the same source even before the first one
Uwe Kleine-Königdfff0612010-02-12 21:58:11 +0100602 * is handled by the associated event handler. If this happens it
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700603 * might be necessary to disable (mask) the interrupt depending on the
604 * controller hardware. This requires to reenable the interrupt inside
605 * of the loop which handles the interrupts which have arrived while
606 * the handler was running. If all pending interrupts are handled, the
607 * loop is left.
608 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800609void
David Howells7d12e782006-10-05 14:55:46 +0100610handle_edge_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700611{
Thomas Gleixner239007b2009-11-17 16:46:45 +0100612 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700613
614 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
615
616 /*
617 * If we're currently running this IRQ, or its disabled,
618 * we shouldn't process the IRQ. Mark it pending, handle
619 * the necessary masking and go out
620 */
621 if (unlikely((desc->status & (IRQ_INPROGRESS | IRQ_DISABLED)) ||
622 !desc->action)) {
623 desc->status |= (IRQ_PENDING | IRQ_MASKED);
Thomas Gleixner9205e312010-09-27 12:44:50 +0000624 mask_ack_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700625 goto out_unlock;
626 }
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200627 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700628
629 /* Start handling the irq */
Thomas Gleixner22a49162010-09-27 12:44:47 +0000630 desc->irq_data.chip->irq_ack(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700631
632 /* Mark the IRQ currently in progress.*/
633 desc->status |= IRQ_INPROGRESS;
634
635 do {
636 struct irqaction *action = desc->action;
637 irqreturn_t action_ret;
638
639 if (unlikely(!action)) {
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000640 mask_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700641 goto out_unlock;
642 }
643
644 /*
645 * When another irq arrived while we were handling
646 * one, we could have masked the irq.
647 * Renable it, if it was not disabled in meantime.
648 */
649 if (unlikely((desc->status &
650 (IRQ_PENDING | IRQ_MASKED | IRQ_DISABLED)) ==
651 (IRQ_PENDING | IRQ_MASKED))) {
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000652 unmask_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700653 }
654
655 desc->status &= ~IRQ_PENDING;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100656 raw_spin_unlock(&desc->lock);
David Howells7d12e782006-10-05 14:55:46 +0100657 action_ret = handle_IRQ_event(irq, action);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700658 if (!noirqdebug)
David Howells7d12e782006-10-05 14:55:46 +0100659 note_interrupt(irq, desc, action_ret);
Thomas Gleixner239007b2009-11-17 16:46:45 +0100660 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700661
662 } while ((desc->status & (IRQ_PENDING | IRQ_DISABLED)) == IRQ_PENDING);
663
664 desc->status &= ~IRQ_INPROGRESS;
665out_unlock:
Thomas Gleixner239007b2009-11-17 16:46:45 +0100666 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700667}
668
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700669/**
Liuweni24b26d42009-11-04 20:11:05 +0800670 * handle_percpu_irq - Per CPU local irq handler
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700671 * @irq: the interrupt number
672 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700673 *
674 * Per CPU interrupts on SMP machines without locking requirements
675 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800676void
David Howells7d12e782006-10-05 14:55:46 +0100677handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700678{
679 irqreturn_t action_ret;
680
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200681 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700682
Thomas Gleixner22a49162010-09-27 12:44:47 +0000683 if (desc->irq_data.chip->irq_ack)
684 desc->irq_data.chip->irq_ack(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700685
David Howells7d12e782006-10-05 14:55:46 +0100686 action_ret = handle_IRQ_event(irq, desc->action);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700687 if (!noirqdebug)
David Howells7d12e782006-10-05 14:55:46 +0100688 note_interrupt(irq, desc, action_ret);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700689
Thomas Gleixner0c5c1552010-09-27 12:44:53 +0000690 if (desc->irq_data.chip->irq_eoi)
691 desc->irq_data.chip->irq_eoi(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700692}
693
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700694void
Ingo Molnara460e742006-10-17 00:10:03 -0700695__set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
696 const char *name)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700697{
Thomas Gleixnerd3c60042008-10-16 09:55:00 +0200698 struct irq_desc *desc = irq_to_desc(irq);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700699 unsigned long flags;
700
Yinghai Lu7d94f7c2008-08-19 20:50:14 -0700701 if (!desc) {
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700702 printk(KERN_ERR
703 "Trying to install type control for IRQ%d\n", irq);
704 return;
705 }
706
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700707 if (!handle)
708 handle = handle_bad_irq;
Thomas Gleixner6b8ff312010-10-01 12:58:38 +0200709 else if (desc->irq_data.chip == &no_irq_chip) {
Thomas Gleixnerf8b54732006-07-01 22:30:08 +0100710 printk(KERN_WARNING "Trying to install %sinterrupt handler "
Geert Uytterhoevenb039db82006-12-20 15:59:48 +0100711 "for IRQ%d\n", is_chained ? "chained " : "", irq);
Thomas Gleixnerf8b54732006-07-01 22:30:08 +0100712 /*
713 * Some ARM implementations install a handler for really dumb
714 * interrupt hardware without setting an irq_chip. This worked
715 * with the ARM no_irq_chip but the check in setup_irq would
716 * prevent us to setup the interrupt at all. Switch it to
717 * dummy_irq_chip for easy transition.
718 */
Thomas Gleixner6b8ff312010-10-01 12:58:38 +0200719 desc->irq_data.chip = &dummy_irq_chip;
Thomas Gleixnerf8b54732006-07-01 22:30:08 +0100720 }
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700721
Thomas Gleixner3876ec92010-09-27 12:44:35 +0000722 chip_bus_lock(desc);
Thomas Gleixner239007b2009-11-17 16:46:45 +0100723 raw_spin_lock_irqsave(&desc->lock, flags);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700724
725 /* Uninstall? */
726 if (handle == handle_bad_irq) {
Thomas Gleixner6b8ff312010-10-01 12:58:38 +0200727 if (desc->irq_data.chip != &no_irq_chip)
Thomas Gleixner9205e312010-09-27 12:44:50 +0000728 mask_ack_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700729 desc->status |= IRQ_DISABLED;
730 desc->depth = 1;
731 }
732 desc->handle_irq = handle;
Ingo Molnara460e742006-10-17 00:10:03 -0700733 desc->name = name;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700734
735 if (handle != handle_bad_irq && is_chained) {
736 desc->status &= ~IRQ_DISABLED;
737 desc->status |= IRQ_NOREQUEST | IRQ_NOPROBE;
738 desc->depth = 0;
Thomas Gleixner37e12df2010-09-27 12:45:38 +0000739 desc->irq_data.chip->irq_startup(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700740 }
Thomas Gleixner239007b2009-11-17 16:46:45 +0100741 raw_spin_unlock_irqrestore(&desc->lock, flags);
Thomas Gleixner3876ec92010-09-27 12:44:35 +0000742 chip_bus_sync_unlock(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700743}
Ingo Molnar14819ea2009-01-14 12:34:21 +0100744EXPORT_SYMBOL_GPL(__set_irq_handler);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700745
746void
747set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip,
David Howells57a58a92006-10-05 13:06:34 +0100748 irq_flow_handler_t handle)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700749{
750 set_irq_chip(irq, chip);
Ingo Molnara460e742006-10-17 00:10:03 -0700751 __set_irq_handler(irq, handle, 0, NULL);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700752}
753
Ingo Molnara460e742006-10-17 00:10:03 -0700754void
755set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
756 irq_flow_handler_t handle, const char *name)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700757{
Ingo Molnara460e742006-10-17 00:10:03 -0700758 set_irq_chip(irq, chip);
759 __set_irq_handler(irq, handle, 0, name);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700760}
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800761
Thomas Gleixner44247182010-09-28 10:40:18 +0200762void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800763{
Thomas Gleixnerd3c60042008-10-16 09:55:00 +0200764 struct irq_desc *desc = irq_to_desc(irq);
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800765 unsigned long flags;
766
Thomas Gleixner44247182010-09-28 10:40:18 +0200767 if (!desc)
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800768 return;
Thomas Gleixner44247182010-09-28 10:40:18 +0200769
770 /* Sanitize flags */
771 set &= IRQF_MODIFY_MASK;
772 clr &= IRQF_MODIFY_MASK;
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800773
Thomas Gleixner239007b2009-11-17 16:46:45 +0100774 raw_spin_lock_irqsave(&desc->lock, flags);
Thomas Gleixner44247182010-09-28 10:40:18 +0200775 desc->status &= ~clr;
776 desc->status |= set;
Thomas Gleixner239007b2009-11-17 16:46:45 +0100777 raw_spin_unlock_irqrestore(&desc->lock, flags);
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800778}