]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - kernel/irq/chip.c
genirq: Mark polled irqs and defer the real handler
[mirror_ubuntu-zesty-kernel.git] / kernel / irq / chip.c
1 /*
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>
14 #include <linux/msi.h>
15 #include <linux/module.h>
16 #include <linux/interrupt.h>
17 #include <linux/kernel_stat.h>
18
19 #include "internals.h"
20
21 /**
22 * irq_set_chip - set the irq chip for an irq
23 * @irq: irq number
24 * @chip: pointer to irq chip description structure
25 */
26 int irq_set_chip(unsigned int irq, struct irq_chip *chip)
27 {
28 struct irq_desc *desc = irq_to_desc(irq);
29 unsigned long flags;
30
31 if (!desc) {
32 WARN(1, KERN_ERR "Trying to install chip for IRQ%d\n", irq);
33 return -EINVAL;
34 }
35
36 if (!chip)
37 chip = &no_irq_chip;
38
39 raw_spin_lock_irqsave(&desc->lock, flags);
40 irq_chip_set_defaults(chip);
41 desc->irq_data.chip = chip;
42 raw_spin_unlock_irqrestore(&desc->lock, flags);
43
44 return 0;
45 }
46 EXPORT_SYMBOL(irq_set_chip);
47
48 /**
49 * irq_set_type - set the irq trigger type for an irq
50 * @irq: irq number
51 * @type: IRQ_TYPE_{LEVEL,EDGE}_* value - see include/linux/irq.h
52 */
53 int irq_set_irq_type(unsigned int irq, unsigned int type)
54 {
55 struct irq_desc *desc = irq_to_desc(irq);
56 unsigned long flags;
57 int ret = -ENXIO;
58
59 if (!desc) {
60 printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq);
61 return -ENODEV;
62 }
63
64 type &= IRQ_TYPE_SENSE_MASK;
65 if (type == IRQ_TYPE_NONE)
66 return 0;
67
68 chip_bus_lock(desc);
69 raw_spin_lock_irqsave(&desc->lock, flags);
70 ret = __irq_set_trigger(desc, irq, type);
71 raw_spin_unlock_irqrestore(&desc->lock, flags);
72 chip_bus_sync_unlock(desc);
73 return ret;
74 }
75 EXPORT_SYMBOL(irq_set_irq_type);
76
77 /**
78 * irq_set_handler_data - set irq handler 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 */
84 int irq_set_handler_data(unsigned int irq, void *data)
85 {
86 struct irq_desc *desc = irq_to_desc(irq);
87 unsigned long flags;
88
89 if (!desc) {
90 printk(KERN_ERR
91 "Trying to install controller data for IRQ%d\n", irq);
92 return -EINVAL;
93 }
94
95 raw_spin_lock_irqsave(&desc->lock, flags);
96 desc->irq_data.handler_data = data;
97 raw_spin_unlock_irqrestore(&desc->lock, flags);
98 return 0;
99 }
100 EXPORT_SYMBOL(irq_set_handler_data);
101
102 /**
103 * irq_set_msi_desc - set MSI descriptor data for an irq
104 * @irq: Interrupt number
105 * @entry: Pointer to MSI descriptor data
106 *
107 * Set the MSI descriptor entry for an irq
108 */
109 int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
110 {
111 struct irq_desc *desc = irq_to_desc(irq);
112 unsigned long flags;
113
114 if (!desc) {
115 printk(KERN_ERR
116 "Trying to install msi data for IRQ%d\n", irq);
117 return -EINVAL;
118 }
119
120 raw_spin_lock_irqsave(&desc->lock, flags);
121 desc->irq_data.msi_desc = entry;
122 if (entry)
123 entry->irq = irq;
124 raw_spin_unlock_irqrestore(&desc->lock, flags);
125 return 0;
126 }
127
128 /**
129 * irq_set_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 */
135 int irq_set_chip_data(unsigned int irq, void *data)
136 {
137 struct irq_desc *desc = irq_to_desc(irq);
138 unsigned long flags;
139
140 if (!desc) {
141 printk(KERN_ERR
142 "Trying to install chip data for IRQ%d\n", irq);
143 return -EINVAL;
144 }
145
146 if (!desc->irq_data.chip) {
147 printk(KERN_ERR "BUG: bad set_irq_chip_data(IRQ#%d)\n", irq);
148 return -EINVAL;
149 }
150
151 raw_spin_lock_irqsave(&desc->lock, flags);
152 desc->irq_data.chip_data = data;
153 raw_spin_unlock_irqrestore(&desc->lock, flags);
154
155 return 0;
156 }
157 EXPORT_SYMBOL(irq_set_chip_data);
158
159 struct 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 }
165 EXPORT_SYMBOL_GPL(irq_get_irq_data);
166
167 /**
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 */
178 void 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
186 raw_spin_lock_irqsave(&desc->lock, flags);
187 if (nest)
188 desc->status |= IRQ_NESTED_THREAD;
189 else
190 desc->status &= ~IRQ_NESTED_THREAD;
191 raw_spin_unlock_irqrestore(&desc->lock, flags);
192 }
193 EXPORT_SYMBOL_GPL(set_irq_nested_thread);
194
195 /*
196 * default enable function
197 */
198 static void default_enable(struct irq_data *data)
199 {
200 struct irq_desc *desc = irq_data_to_desc(data);
201
202 desc->irq_data.chip->irq_unmask(&desc->irq_data);
203 desc->status &= ~IRQ_MASKED;
204 }
205
206 /*
207 * default disable function
208 */
209 static void default_disable(struct irq_data *data)
210 {
211 }
212
213 /*
214 * default startup function
215 */
216 static unsigned int default_startup(struct irq_data *data)
217 {
218 struct irq_desc *desc = irq_data_to_desc(data);
219
220 desc->irq_data.chip->irq_enable(data);
221 return 0;
222 }
223
224 /*
225 * default shutdown function
226 */
227 static void default_shutdown(struct irq_data *data)
228 {
229 struct irq_desc *desc = irq_data_to_desc(data);
230
231 desc->irq_data.chip->irq_mask(&desc->irq_data);
232 desc->status |= IRQ_MASKED;
233 }
234
235 #ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
236 /* Temporary migration helpers */
237 static void compat_irq_mask(struct irq_data *data)
238 {
239 data->chip->mask(data->irq);
240 }
241
242 static void compat_irq_unmask(struct irq_data *data)
243 {
244 data->chip->unmask(data->irq);
245 }
246
247 static void compat_irq_ack(struct irq_data *data)
248 {
249 data->chip->ack(data->irq);
250 }
251
252 static void compat_irq_mask_ack(struct irq_data *data)
253 {
254 data->chip->mask_ack(data->irq);
255 }
256
257 static void compat_irq_eoi(struct irq_data *data)
258 {
259 data->chip->eoi(data->irq);
260 }
261
262 static void compat_irq_enable(struct irq_data *data)
263 {
264 data->chip->enable(data->irq);
265 }
266
267 static void compat_irq_disable(struct irq_data *data)
268 {
269 data->chip->disable(data->irq);
270 }
271
272 static void compat_irq_shutdown(struct irq_data *data)
273 {
274 data->chip->shutdown(data->irq);
275 }
276
277 static unsigned int compat_irq_startup(struct irq_data *data)
278 {
279 return data->chip->startup(data->irq);
280 }
281
282 static 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
288 static int compat_irq_set_type(struct irq_data *data, unsigned int type)
289 {
290 return data->chip->set_type(data->irq, type);
291 }
292
293 static int compat_irq_set_wake(struct irq_data *data, unsigned int on)
294 {
295 return data->chip->set_wake(data->irq, on);
296 }
297
298 static int compat_irq_retrigger(struct irq_data *data)
299 {
300 return data->chip->retrigger(data->irq);
301 }
302
303 static void compat_bus_lock(struct irq_data *data)
304 {
305 data->chip->bus_lock(data->irq);
306 }
307
308 static void compat_bus_sync_unlock(struct irq_data *data)
309 {
310 data->chip->bus_sync_unlock(data->irq);
311 }
312 #endif
313
314 /*
315 * Fixup enable/disable function pointers
316 */
317 void irq_chip_set_defaults(struct irq_chip *chip)
318 {
319 #ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
320 /*
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;
326 if (chip->disable)
327 chip->irq_disable = compat_irq_disable;
328 if (chip->shutdown)
329 chip->irq_shutdown = compat_irq_shutdown;
330 if (chip->startup)
331 chip->irq_startup = compat_irq_startup;
332 #endif
333 /*
334 * The real defaults
335 */
336 if (!chip->irq_enable)
337 chip->irq_enable = default_enable;
338 if (!chip->irq_disable)
339 chip->irq_disable = default_disable;
340 if (!chip->irq_startup)
341 chip->irq_startup = default_startup;
342 /*
343 * 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
345 * to use default_shutdown, otherwise the irq line is not
346 * disabled on free_irq():
347 */
348 if (!chip->irq_shutdown)
349 chip->irq_shutdown = chip->irq_disable != default_disable ?
350 chip->irq_disable : default_shutdown;
351
352 #ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
353 if (!chip->end)
354 chip->end = dummy_irq_chip.end;
355
356 /*
357 * Now fix up the remaining compat handlers
358 */
359 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;
363 if (chip->mask)
364 chip->irq_mask = compat_irq_mask;
365 if (chip->unmask)
366 chip->irq_unmask = compat_irq_unmask;
367 if (chip->ack)
368 chip->irq_ack = compat_irq_ack;
369 if (chip->mask_ack)
370 chip->irq_mask_ack = compat_irq_mask_ack;
371 if (chip->eoi)
372 chip->irq_eoi = compat_irq_eoi;
373 if (chip->set_affinity)
374 chip->irq_set_affinity = compat_irq_set_affinity;
375 if (chip->set_type)
376 chip->irq_set_type = compat_irq_set_type;
377 if (chip->set_wake)
378 chip->irq_set_wake = compat_irq_set_wake;
379 if (chip->retrigger)
380 chip->irq_retrigger = compat_irq_retrigger;
381 #endif
382 }
383
384 static inline void mask_ack_irq(struct irq_desc *desc)
385 {
386 if (desc->irq_data.chip->irq_mask_ack)
387 desc->irq_data.chip->irq_mask_ack(&desc->irq_data);
388 else {
389 desc->irq_data.chip->irq_mask(&desc->irq_data);
390 if (desc->irq_data.chip->irq_ack)
391 desc->irq_data.chip->irq_ack(&desc->irq_data);
392 }
393 desc->status |= IRQ_MASKED;
394 }
395
396 static inline void mask_irq(struct irq_desc *desc)
397 {
398 if (desc->irq_data.chip->irq_mask) {
399 desc->irq_data.chip->irq_mask(&desc->irq_data);
400 desc->status |= IRQ_MASKED;
401 }
402 }
403
404 static inline void unmask_irq(struct irq_desc *desc)
405 {
406 if (desc->irq_data.chip->irq_unmask) {
407 desc->irq_data.chip->irq_unmask(&desc->irq_data);
408 desc->status &= ~IRQ_MASKED;
409 }
410 }
411
412 /*
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 */
420 void 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
428 raw_spin_lock_irq(&desc->lock);
429
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;
437 raw_spin_unlock_irq(&desc->lock);
438
439 action_ret = action->thread_fn(action->irq, action->dev_id);
440 if (!noirqdebug)
441 note_interrupt(irq, desc, action_ret);
442
443 raw_spin_lock_irq(&desc->lock);
444 desc->status &= ~IRQ_INPROGRESS;
445
446 out_unlock:
447 raw_spin_unlock_irq(&desc->lock);
448 }
449 EXPORT_SYMBOL_GPL(handle_nested_irq);
450
451 static bool irq_check_poll(struct irq_desc *desc)
452 {
453 if (!(desc->status & IRQ_POLL_INPROGRESS))
454 return false;
455 return irq_wait_for_poll(desc);
456 }
457
458 /**
459 * handle_simple_irq - Simple and software-decoded IRQs.
460 * @irq: the interrupt number
461 * @desc: the interrupt description structure for this irq
462 *
463 * Simple interrupts are either sent from a demultiplexing interrupt
464 * handler or come from hardware, where no interrupt hardware control
465 * is necessary.
466 *
467 * Note: The caller is expected to handle the ack, clear, mask and
468 * unmask issues if necessary.
469 */
470 void
471 handle_simple_irq(unsigned int irq, struct irq_desc *desc)
472 {
473 struct irqaction *action;
474 irqreturn_t action_ret;
475
476 raw_spin_lock(&desc->lock);
477
478 if (unlikely(desc->status & IRQ_INPROGRESS))
479 if (!irq_check_poll(desc))
480 goto out_unlock;
481
482 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
483 kstat_incr_irqs_this_cpu(irq, desc);
484
485 action = desc->action;
486 if (unlikely(!action || (desc->status & IRQ_DISABLED)))
487 goto out_unlock;
488
489 desc->status |= IRQ_INPROGRESS;
490 raw_spin_unlock(&desc->lock);
491
492 action_ret = handle_IRQ_event(irq, action);
493 if (!noirqdebug)
494 note_interrupt(irq, desc, action_ret);
495
496 raw_spin_lock(&desc->lock);
497 desc->status &= ~IRQ_INPROGRESS;
498 out_unlock:
499 raw_spin_unlock(&desc->lock);
500 }
501
502 /**
503 * handle_level_irq - Level type irq handler
504 * @irq: the interrupt number
505 * @desc: the interrupt description structure for this irq
506 *
507 * Level type interrupts are active as long as the hardware line has
508 * the active level. This may require to mask the interrupt and unmask
509 * it after the associated handler has acknowledged the device, so the
510 * interrupt line is back to inactive.
511 */
512 void
513 handle_level_irq(unsigned int irq, struct irq_desc *desc)
514 {
515 struct irqaction *action;
516 irqreturn_t action_ret;
517
518 raw_spin_lock(&desc->lock);
519 mask_ack_irq(desc);
520
521 if (unlikely(desc->status & IRQ_INPROGRESS))
522 if (!irq_check_poll(desc))
523 goto out_unlock;
524
525 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
526 kstat_incr_irqs_this_cpu(irq, desc);
527
528 /*
529 * If its disabled or no action available
530 * keep it masked and get out of here
531 */
532 action = desc->action;
533 if (unlikely(!action || (desc->status & IRQ_DISABLED)))
534 goto out_unlock;
535
536 desc->status |= IRQ_INPROGRESS;
537 raw_spin_unlock(&desc->lock);
538
539 action_ret = handle_IRQ_event(irq, action);
540 if (!noirqdebug)
541 note_interrupt(irq, desc, action_ret);
542
543 raw_spin_lock(&desc->lock);
544 desc->status &= ~IRQ_INPROGRESS;
545
546 if (!(desc->status & (IRQ_DISABLED | IRQ_ONESHOT)))
547 unmask_irq(desc);
548 out_unlock:
549 raw_spin_unlock(&desc->lock);
550 }
551 EXPORT_SYMBOL_GPL(handle_level_irq);
552
553 /**
554 * handle_fasteoi_irq - irq handler for transparent controllers
555 * @irq: the interrupt number
556 * @desc: the interrupt description structure for this irq
557 *
558 * Only a single callback will be issued to the chip: an ->eoi()
559 * call when the interrupt has been serviced. This enables support
560 * for modern forms of interrupt handlers, which handle the flow
561 * details in hardware, transparently.
562 */
563 void
564 handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
565 {
566 struct irqaction *action;
567 irqreturn_t action_ret;
568
569 raw_spin_lock(&desc->lock);
570
571 if (unlikely(desc->status & IRQ_INPROGRESS))
572 if (!irq_check_poll(desc))
573 goto out;
574
575 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
576 kstat_incr_irqs_this_cpu(irq, desc);
577
578 /*
579 * If its disabled or no action available
580 * then mask it and get out of here:
581 */
582 action = desc->action;
583 if (unlikely(!action || (desc->status & IRQ_DISABLED))) {
584 desc->status |= IRQ_PENDING;
585 mask_irq(desc);
586 goto out;
587 }
588
589 desc->status |= IRQ_INPROGRESS;
590 desc->status &= ~IRQ_PENDING;
591 raw_spin_unlock(&desc->lock);
592
593 action_ret = handle_IRQ_event(irq, action);
594 if (!noirqdebug)
595 note_interrupt(irq, desc, action_ret);
596
597 raw_spin_lock(&desc->lock);
598 desc->status &= ~IRQ_INPROGRESS;
599 out:
600 desc->irq_data.chip->irq_eoi(&desc->irq_data);
601
602 raw_spin_unlock(&desc->lock);
603 }
604
605 /**
606 * handle_edge_irq - edge type IRQ handler
607 * @irq: the interrupt number
608 * @desc: the interrupt description structure for this irq
609 *
610 * Interrupt occures on the falling and/or rising edge of a hardware
611 * signal. The occurence is latched into the irq controller hardware
612 * and must be acked in order to be reenabled. After the ack another
613 * interrupt can happen on the same source even before the first one
614 * is handled by the associated event handler. If this happens it
615 * might be necessary to disable (mask) the interrupt depending on the
616 * controller hardware. This requires to reenable the interrupt inside
617 * of the loop which handles the interrupts which have arrived while
618 * the handler was running. If all pending interrupts are handled, the
619 * loop is left.
620 */
621 void
622 handle_edge_irq(unsigned int irq, struct irq_desc *desc)
623 {
624 raw_spin_lock(&desc->lock);
625
626 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
627
628 /*
629 * If we're currently running this IRQ, or its disabled,
630 * we shouldn't process the IRQ. Mark it pending, handle
631 * the necessary masking and go out
632 */
633 if (unlikely((desc->status & (IRQ_INPROGRESS | IRQ_DISABLED)) ||
634 !desc->action)) {
635 if (!irq_check_poll(desc)) {
636 desc->status |= (IRQ_PENDING | IRQ_MASKED);
637 mask_ack_irq(desc);
638 goto out_unlock;
639 }
640 }
641 kstat_incr_irqs_this_cpu(irq, desc);
642
643 /* Start handling the irq */
644 desc->irq_data.chip->irq_ack(&desc->irq_data);
645
646 /* Mark the IRQ currently in progress.*/
647 desc->status |= IRQ_INPROGRESS;
648
649 do {
650 struct irqaction *action = desc->action;
651 irqreturn_t action_ret;
652
653 if (unlikely(!action)) {
654 mask_irq(desc);
655 goto out_unlock;
656 }
657
658 /*
659 * When another irq arrived while we were handling
660 * one, we could have masked the irq.
661 * Renable it, if it was not disabled in meantime.
662 */
663 if (unlikely((desc->status &
664 (IRQ_PENDING | IRQ_MASKED | IRQ_DISABLED)) ==
665 (IRQ_PENDING | IRQ_MASKED))) {
666 unmask_irq(desc);
667 }
668
669 desc->status &= ~IRQ_PENDING;
670 raw_spin_unlock(&desc->lock);
671 action_ret = handle_IRQ_event(irq, action);
672 if (!noirqdebug)
673 note_interrupt(irq, desc, action_ret);
674 raw_spin_lock(&desc->lock);
675
676 } while ((desc->status & (IRQ_PENDING | IRQ_DISABLED)) == IRQ_PENDING);
677
678 desc->status &= ~IRQ_INPROGRESS;
679 out_unlock:
680 raw_spin_unlock(&desc->lock);
681 }
682
683 /**
684 * handle_percpu_irq - Per CPU local irq handler
685 * @irq: the interrupt number
686 * @desc: the interrupt description structure for this irq
687 *
688 * Per CPU interrupts on SMP machines without locking requirements
689 */
690 void
691 handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
692 {
693 irqreturn_t action_ret;
694
695 kstat_incr_irqs_this_cpu(irq, desc);
696
697 if (desc->irq_data.chip->irq_ack)
698 desc->irq_data.chip->irq_ack(&desc->irq_data);
699
700 action_ret = handle_IRQ_event(irq, desc->action);
701 if (!noirqdebug)
702 note_interrupt(irq, desc, action_ret);
703
704 if (desc->irq_data.chip->irq_eoi)
705 desc->irq_data.chip->irq_eoi(&desc->irq_data);
706 }
707
708 void
709 __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
710 const char *name)
711 {
712 struct irq_desc *desc = irq_to_desc(irq);
713 unsigned long flags;
714
715 if (!desc) {
716 printk(KERN_ERR
717 "Trying to install type control for IRQ%d\n", irq);
718 return;
719 }
720
721 if (!handle)
722 handle = handle_bad_irq;
723 else if (desc->irq_data.chip == &no_irq_chip) {
724 printk(KERN_WARNING "Trying to install %sinterrupt handler "
725 "for IRQ%d\n", is_chained ? "chained " : "", irq);
726 /*
727 * Some ARM implementations install a handler for really dumb
728 * interrupt hardware without setting an irq_chip. This worked
729 * with the ARM no_irq_chip but the check in setup_irq would
730 * prevent us to setup the interrupt at all. Switch it to
731 * dummy_irq_chip for easy transition.
732 */
733 desc->irq_data.chip = &dummy_irq_chip;
734 }
735
736 chip_bus_lock(desc);
737 raw_spin_lock_irqsave(&desc->lock, flags);
738
739 /* Uninstall? */
740 if (handle == handle_bad_irq) {
741 if (desc->irq_data.chip != &no_irq_chip)
742 mask_ack_irq(desc);
743 desc->status |= IRQ_DISABLED;
744 desc->depth = 1;
745 }
746 desc->handle_irq = handle;
747 desc->name = name;
748
749 if (handle != handle_bad_irq && is_chained) {
750 desc->status &= ~IRQ_DISABLED;
751 desc->status |= IRQ_NOREQUEST | IRQ_NOPROBE;
752 desc->depth = 0;
753 desc->irq_data.chip->irq_startup(&desc->irq_data);
754 }
755 raw_spin_unlock_irqrestore(&desc->lock, flags);
756 chip_bus_sync_unlock(desc);
757 }
758 EXPORT_SYMBOL_GPL(__set_irq_handler);
759
760 void
761 set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip,
762 irq_flow_handler_t handle)
763 {
764 set_irq_chip(irq, chip);
765 __set_irq_handler(irq, handle, 0, NULL);
766 }
767
768 void
769 set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
770 irq_flow_handler_t handle, const char *name)
771 {
772 set_irq_chip(irq, chip);
773 __set_irq_handler(irq, handle, 0, name);
774 }
775
776 void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
777 {
778 struct irq_desc *desc = irq_to_desc(irq);
779 unsigned long flags;
780
781 if (!desc)
782 return;
783
784 /* Sanitize flags */
785 set &= IRQF_MODIFY_MASK;
786 clr &= IRQF_MODIFY_MASK;
787
788 raw_spin_lock_irqsave(&desc->lock, flags);
789 desc->status &= ~clr;
790 desc->status |= set;
791 raw_spin_unlock_irqrestore(&desc->lock, flags);
792 }