chip.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  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. #include <linux/irq.h>
  13. #include <linux/msi.h>
  14. #include <linux/module.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/kernel_stat.h>
  17. #include "internals.h"
  18. /**
  19. * irq_set_chip - set the irq chip for an irq
  20. * @irq: irq number
  21. * @chip: pointer to irq chip description structure
  22. */
  23. int irq_set_chip(unsigned int irq, struct irq_chip *chip)
  24. {
  25. unsigned long flags;
  26. struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
  27. if (!desc)
  28. return -EINVAL;
  29. if (!chip)
  30. chip = &no_irq_chip;
  31. irq_chip_set_defaults(chip);
  32. desc->irq_data.chip = chip;
  33. irq_put_desc_unlock(desc, flags);
  34. /*
  35. * For !CONFIG_SPARSE_IRQ make the irq show up in
  36. * allocated_irqs. For the CONFIG_SPARSE_IRQ case, it is
  37. * already marked, and this call is harmless.
  38. */
  39. irq_reserve_irq(irq);
  40. return 0;
  41. }
  42. EXPORT_SYMBOL(irq_set_chip);
  43. /**
  44. * irq_set_type - set the irq trigger type for an irq
  45. * @irq: irq number
  46. * @type: IRQ_TYPE_{LEVEL,EDGE}_* value - see include/linux/irq.h
  47. */
  48. int irq_set_irq_type(unsigned int irq, unsigned int type)
  49. {
  50. unsigned long flags;
  51. struct irq_desc *desc = irq_get_desc_buslock(irq, &flags);
  52. int ret = 0;
  53. if (!desc)
  54. return -EINVAL;
  55. type &= IRQ_TYPE_SENSE_MASK;
  56. if (type != IRQ_TYPE_NONE)
  57. ret = __irq_set_trigger(desc, irq, type);
  58. irq_put_desc_busunlock(desc, flags);
  59. return ret;
  60. }
  61. EXPORT_SYMBOL(irq_set_irq_type);
  62. /**
  63. * irq_set_handler_data - set irq handler data for an irq
  64. * @irq: Interrupt number
  65. * @data: Pointer to interrupt specific data
  66. *
  67. * Set the hardware irq controller data for an irq
  68. */
  69. int irq_set_handler_data(unsigned int irq, void *data)
  70. {
  71. unsigned long flags;
  72. struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
  73. if (!desc)
  74. return -EINVAL;
  75. desc->irq_data.handler_data = data;
  76. irq_put_desc_unlock(desc, flags);
  77. return 0;
  78. }
  79. EXPORT_SYMBOL(irq_set_handler_data);
  80. /**
  81. * irq_set_msi_desc - set MSI descriptor data for an irq
  82. * @irq: Interrupt number
  83. * @entry: Pointer to MSI descriptor data
  84. *
  85. * Set the MSI descriptor entry for an irq
  86. */
  87. int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
  88. {
  89. unsigned long flags;
  90. struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
  91. if (!desc)
  92. return -EINVAL;
  93. desc->irq_data.msi_desc = entry;
  94. if (entry)
  95. entry->irq = irq;
  96. irq_put_desc_unlock(desc, flags);
  97. return 0;
  98. }
  99. /**
  100. * irq_set_chip_data - set irq chip data for an irq
  101. * @irq: Interrupt number
  102. * @data: Pointer to chip specific data
  103. *
  104. * Set the hardware irq chip data for an irq
  105. */
  106. int irq_set_chip_data(unsigned int irq, void *data)
  107. {
  108. unsigned long flags;
  109. struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
  110. if (!desc)
  111. return -EINVAL;
  112. desc->irq_data.chip_data = data;
  113. irq_put_desc_unlock(desc, flags);
  114. return 0;
  115. }
  116. EXPORT_SYMBOL(irq_set_chip_data);
  117. struct irq_data *irq_get_irq_data(unsigned int irq)
  118. {
  119. struct irq_desc *desc = irq_to_desc(irq);
  120. return desc ? &desc->irq_data : NULL;
  121. }
  122. EXPORT_SYMBOL_GPL(irq_get_irq_data);
  123. static void irq_state_clr_disabled(struct irq_desc *desc)
  124. {
  125. desc->istate &= ~IRQS_DISABLED;
  126. irqd_clear(&desc->irq_data, IRQD_IRQ_DISABLED);
  127. irq_compat_clr_disabled(desc);
  128. }
  129. static void irq_state_set_disabled(struct irq_desc *desc)
  130. {
  131. desc->istate |= IRQS_DISABLED;
  132. irqd_set(&desc->irq_data, IRQD_IRQ_DISABLED);
  133. irq_compat_set_disabled(desc);
  134. }
  135. static void irq_state_clr_masked(struct irq_desc *desc)
  136. {
  137. desc->istate &= ~IRQS_MASKED;
  138. irq_compat_clr_masked(desc);
  139. }
  140. static void irq_state_set_masked(struct irq_desc *desc)
  141. {
  142. desc->istate |= IRQS_MASKED;
  143. irq_compat_set_masked(desc);
  144. }
  145. int irq_startup(struct irq_desc *desc)
  146. {
  147. irq_state_clr_disabled(desc);
  148. desc->depth = 0;
  149. if (desc->irq_data.chip->irq_startup) {
  150. int ret = desc->irq_data.chip->irq_startup(&desc->irq_data);
  151. irq_state_clr_masked(desc);
  152. return ret;
  153. }
  154. irq_enable(desc);
  155. return 0;
  156. }
  157. void irq_shutdown(struct irq_desc *desc)
  158. {
  159. irq_state_set_disabled(desc);
  160. desc->depth = 1;
  161. if (desc->irq_data.chip->irq_shutdown)
  162. desc->irq_data.chip->irq_shutdown(&desc->irq_data);
  163. if (desc->irq_data.chip->irq_disable)
  164. desc->irq_data.chip->irq_disable(&desc->irq_data);
  165. else
  166. desc->irq_data.chip->irq_mask(&desc->irq_data);
  167. irq_state_set_masked(desc);
  168. }
  169. void irq_enable(struct irq_desc *desc)
  170. {
  171. irq_state_clr_disabled(desc);
  172. if (desc->irq_data.chip->irq_enable)
  173. desc->irq_data.chip->irq_enable(&desc->irq_data);
  174. else
  175. desc->irq_data.chip->irq_unmask(&desc->irq_data);
  176. irq_state_clr_masked(desc);
  177. }
  178. void irq_disable(struct irq_desc *desc)
  179. {
  180. irq_state_set_disabled(desc);
  181. if (desc->irq_data.chip->irq_disable) {
  182. desc->irq_data.chip->irq_disable(&desc->irq_data);
  183. irq_state_set_masked(desc);
  184. }
  185. }
  186. #ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
  187. /* Temporary migration helpers */
  188. static void compat_irq_mask(struct irq_data *data)
  189. {
  190. data->chip->mask(data->irq);
  191. }
  192. static void compat_irq_unmask(struct irq_data *data)
  193. {
  194. data->chip->unmask(data->irq);
  195. }
  196. static void compat_irq_ack(struct irq_data *data)
  197. {
  198. data->chip->ack(data->irq);
  199. }
  200. static void compat_irq_mask_ack(struct irq_data *data)
  201. {
  202. data->chip->mask_ack(data->irq);
  203. }
  204. static void compat_irq_eoi(struct irq_data *data)
  205. {
  206. data->chip->eoi(data->irq);
  207. }
  208. static void compat_irq_enable(struct irq_data *data)
  209. {
  210. data->chip->enable(data->irq);
  211. }
  212. static void compat_irq_disable(struct irq_data *data)
  213. {
  214. data->chip->disable(data->irq);
  215. }
  216. static void compat_irq_shutdown(struct irq_data *data)
  217. {
  218. data->chip->shutdown(data->irq);
  219. }
  220. static unsigned int compat_irq_startup(struct irq_data *data)
  221. {
  222. return data->chip->startup(data->irq);
  223. }
  224. static int compat_irq_set_affinity(struct irq_data *data,
  225. const struct cpumask *dest, bool force)
  226. {
  227. return data->chip->set_affinity(data->irq, dest);
  228. }
  229. static int compat_irq_set_type(struct irq_data *data, unsigned int type)
  230. {
  231. return data->chip->set_type(data->irq, type);
  232. }
  233. static int compat_irq_set_wake(struct irq_data *data, unsigned int on)
  234. {
  235. return data->chip->set_wake(data->irq, on);
  236. }
  237. static int compat_irq_retrigger(struct irq_data *data)
  238. {
  239. return data->chip->retrigger(data->irq);
  240. }
  241. static void compat_bus_lock(struct irq_data *data)
  242. {
  243. data->chip->bus_lock(data->irq);
  244. }
  245. static void compat_bus_sync_unlock(struct irq_data *data)
  246. {
  247. data->chip->bus_sync_unlock(data->irq);
  248. }
  249. #endif
  250. /*
  251. * Fixup enable/disable function pointers
  252. */
  253. void irq_chip_set_defaults(struct irq_chip *chip)
  254. {
  255. #ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
  256. if (chip->enable)
  257. chip->irq_enable = compat_irq_enable;
  258. if (chip->disable)
  259. chip->irq_disable = compat_irq_disable;
  260. if (chip->shutdown)
  261. chip->irq_shutdown = compat_irq_shutdown;
  262. if (chip->startup)
  263. chip->irq_startup = compat_irq_startup;
  264. if (!chip->end)
  265. chip->end = dummy_irq_chip.end;
  266. if (chip->bus_lock)
  267. chip->irq_bus_lock = compat_bus_lock;
  268. if (chip->bus_sync_unlock)
  269. chip->irq_bus_sync_unlock = compat_bus_sync_unlock;
  270. if (chip->mask)
  271. chip->irq_mask = compat_irq_mask;
  272. if (chip->unmask)
  273. chip->irq_unmask = compat_irq_unmask;
  274. if (chip->ack)
  275. chip->irq_ack = compat_irq_ack;
  276. if (chip->mask_ack)
  277. chip->irq_mask_ack = compat_irq_mask_ack;
  278. if (chip->eoi)
  279. chip->irq_eoi = compat_irq_eoi;
  280. if (chip->set_affinity)
  281. chip->irq_set_affinity = compat_irq_set_affinity;
  282. if (chip->set_type)
  283. chip->irq_set_type = compat_irq_set_type;
  284. if (chip->set_wake)
  285. chip->irq_set_wake = compat_irq_set_wake;
  286. if (chip->retrigger)
  287. chip->irq_retrigger = compat_irq_retrigger;
  288. #endif
  289. }
  290. static inline void mask_ack_irq(struct irq_desc *desc)
  291. {
  292. if (desc->irq_data.chip->irq_mask_ack)
  293. desc->irq_data.chip->irq_mask_ack(&desc->irq_data);
  294. else {
  295. desc->irq_data.chip->irq_mask(&desc->irq_data);
  296. if (desc->irq_data.chip->irq_ack)
  297. desc->irq_data.chip->irq_ack(&desc->irq_data);
  298. }
  299. irq_state_set_masked(desc);
  300. }
  301. void mask_irq(struct irq_desc *desc)
  302. {
  303. if (desc->irq_data.chip->irq_mask) {
  304. desc->irq_data.chip->irq_mask(&desc->irq_data);
  305. irq_state_set_masked(desc);
  306. }
  307. }
  308. void unmask_irq(struct irq_desc *desc)
  309. {
  310. if (desc->irq_data.chip->irq_unmask) {
  311. desc->irq_data.chip->irq_unmask(&desc->irq_data);
  312. irq_state_clr_masked(desc);
  313. }
  314. }
  315. /*
  316. * handle_nested_irq - Handle a nested irq from a irq thread
  317. * @irq: the interrupt number
  318. *
  319. * Handle interrupts which are nested into a threaded interrupt
  320. * handler. The handler function is called inside the calling
  321. * threads context.
  322. */
  323. void handle_nested_irq(unsigned int irq)
  324. {
  325. struct irq_desc *desc = irq_to_desc(irq);
  326. struct irqaction *action;
  327. irqreturn_t action_ret;
  328. might_sleep();
  329. raw_spin_lock_irq(&desc->lock);
  330. kstat_incr_irqs_this_cpu(irq, desc);
  331. action = desc->action;
  332. if (unlikely(!action || (desc->istate & IRQS_DISABLED)))
  333. goto out_unlock;
  334. irq_compat_set_progress(desc);
  335. desc->istate |= IRQS_INPROGRESS;
  336. raw_spin_unlock_irq(&desc->lock);
  337. action_ret = action->thread_fn(action->irq, action->dev_id);
  338. if (!noirqdebug)
  339. note_interrupt(irq, desc, action_ret);
  340. raw_spin_lock_irq(&desc->lock);
  341. desc->istate &= ~IRQS_INPROGRESS;
  342. irq_compat_clr_progress(desc);
  343. out_unlock:
  344. raw_spin_unlock_irq(&desc->lock);
  345. }
  346. EXPORT_SYMBOL_GPL(handle_nested_irq);
  347. static bool irq_check_poll(struct irq_desc *desc)
  348. {
  349. if (!(desc->istate & IRQS_POLL_INPROGRESS))
  350. return false;
  351. return irq_wait_for_poll(desc);
  352. }
  353. /**
  354. * handle_simple_irq - Simple and software-decoded IRQs.
  355. * @irq: the interrupt number
  356. * @desc: the interrupt description structure for this irq
  357. *
  358. * Simple interrupts are either sent from a demultiplexing interrupt
  359. * handler or come from hardware, where no interrupt hardware control
  360. * is necessary.
  361. *
  362. * Note: The caller is expected to handle the ack, clear, mask and
  363. * unmask issues if necessary.
  364. */
  365. void
  366. handle_simple_irq(unsigned int irq, struct irq_desc *desc)
  367. {
  368. raw_spin_lock(&desc->lock);
  369. if (unlikely(desc->istate & IRQS_INPROGRESS))
  370. if (!irq_check_poll(desc))
  371. goto out_unlock;
  372. desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
  373. kstat_incr_irqs_this_cpu(irq, desc);
  374. if (unlikely(!desc->action || (desc->istate & IRQS_DISABLED)))
  375. goto out_unlock;
  376. handle_irq_event(desc);
  377. out_unlock:
  378. raw_spin_unlock(&desc->lock);
  379. }
  380. /**
  381. * handle_level_irq - Level type irq handler
  382. * @irq: the interrupt number
  383. * @desc: the interrupt description structure for this irq
  384. *
  385. * Level type interrupts are active as long as the hardware line has
  386. * the active level. This may require to mask the interrupt and unmask
  387. * it after the associated handler has acknowledged the device, so the
  388. * interrupt line is back to inactive.
  389. */
  390. void
  391. handle_level_irq(unsigned int irq, struct irq_desc *desc)
  392. {
  393. raw_spin_lock(&desc->lock);
  394. mask_ack_irq(desc);
  395. if (unlikely(desc->istate & IRQS_INPROGRESS))
  396. if (!irq_check_poll(desc))
  397. goto out_unlock;
  398. desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
  399. kstat_incr_irqs_this_cpu(irq, desc);
  400. /*
  401. * If its disabled or no action available
  402. * keep it masked and get out of here
  403. */
  404. if (unlikely(!desc->action || (desc->istate & IRQS_DISABLED)))
  405. goto out_unlock;
  406. handle_irq_event(desc);
  407. if (!(desc->istate & (IRQS_DISABLED | IRQS_ONESHOT)))
  408. unmask_irq(desc);
  409. out_unlock:
  410. raw_spin_unlock(&desc->lock);
  411. }
  412. EXPORT_SYMBOL_GPL(handle_level_irq);
  413. #ifdef CONFIG_IRQ_PREFLOW_FASTEOI
  414. static inline void preflow_handler(struct irq_desc *desc)
  415. {
  416. if (desc->preflow_handler)
  417. desc->preflow_handler(&desc->irq_data);
  418. }
  419. #else
  420. static inline void preflow_handler(struct irq_desc *desc) { }
  421. #endif
  422. /**
  423. * handle_fasteoi_irq - irq handler for transparent controllers
  424. * @irq: the interrupt number
  425. * @desc: the interrupt description structure for this irq
  426. *
  427. * Only a single callback will be issued to the chip: an ->eoi()
  428. * call when the interrupt has been serviced. This enables support
  429. * for modern forms of interrupt handlers, which handle the flow
  430. * details in hardware, transparently.
  431. */
  432. void
  433. handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
  434. {
  435. raw_spin_lock(&desc->lock);
  436. if (unlikely(desc->istate & IRQS_INPROGRESS))
  437. if (!irq_check_poll(desc))
  438. goto out;
  439. desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
  440. kstat_incr_irqs_this_cpu(irq, desc);
  441. /*
  442. * If its disabled or no action available
  443. * then mask it and get out of here:
  444. */
  445. if (unlikely(!desc->action || (desc->istate & IRQS_DISABLED))) {
  446. irq_compat_set_pending(desc);
  447. desc->istate |= IRQS_PENDING;
  448. mask_irq(desc);
  449. goto out;
  450. }
  451. if (desc->istate & IRQS_ONESHOT)
  452. mask_irq(desc);
  453. preflow_handler(desc);
  454. handle_irq_event(desc);
  455. out_eoi:
  456. desc->irq_data.chip->irq_eoi(&desc->irq_data);
  457. out_unlock:
  458. raw_spin_unlock(&desc->lock);
  459. return;
  460. out:
  461. if (!(desc->irq_data.chip->flags & IRQCHIP_EOI_IF_HANDLED))
  462. goto out_eoi;
  463. goto out_unlock;
  464. }
  465. /**
  466. * handle_edge_irq - edge type IRQ handler
  467. * @irq: the interrupt number
  468. * @desc: the interrupt description structure for this irq
  469. *
  470. * Interrupt occures on the falling and/or rising edge of a hardware
  471. * signal. The occurence is latched into the irq controller hardware
  472. * and must be acked in order to be reenabled. After the ack another
  473. * interrupt can happen on the same source even before the first one
  474. * is handled by the associated event handler. If this happens it
  475. * might be necessary to disable (mask) the interrupt depending on the
  476. * controller hardware. This requires to reenable the interrupt inside
  477. * of the loop which handles the interrupts which have arrived while
  478. * the handler was running. If all pending interrupts are handled, the
  479. * loop is left.
  480. */
  481. void
  482. handle_edge_irq(unsigned int irq, struct irq_desc *desc)
  483. {
  484. raw_spin_lock(&desc->lock);
  485. desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
  486. /*
  487. * If we're currently running this IRQ, or its disabled,
  488. * we shouldn't process the IRQ. Mark it pending, handle
  489. * the necessary masking and go out
  490. */
  491. if (unlikely((desc->istate & (IRQS_DISABLED | IRQS_INPROGRESS) ||
  492. !desc->action))) {
  493. if (!irq_check_poll(desc)) {
  494. irq_compat_set_pending(desc);
  495. desc->istate |= IRQS_PENDING;
  496. mask_ack_irq(desc);
  497. goto out_unlock;
  498. }
  499. }
  500. kstat_incr_irqs_this_cpu(irq, desc);
  501. /* Start handling the irq */
  502. desc->irq_data.chip->irq_ack(&desc->irq_data);
  503. do {
  504. if (unlikely(!desc->action)) {
  505. mask_irq(desc);
  506. goto out_unlock;
  507. }
  508. /*
  509. * When another irq arrived while we were handling
  510. * one, we could have masked the irq.
  511. * Renable it, if it was not disabled in meantime.
  512. */
  513. if (unlikely(desc->istate & IRQS_PENDING)) {
  514. if (!(desc->istate & IRQS_DISABLED) &&
  515. (desc->istate & IRQS_MASKED))
  516. unmask_irq(desc);
  517. }
  518. handle_irq_event(desc);
  519. } while ((desc->istate & IRQS_PENDING) &&
  520. !(desc->istate & IRQS_DISABLED));
  521. out_unlock:
  522. raw_spin_unlock(&desc->lock);
  523. }
  524. /**
  525. * handle_percpu_irq - Per CPU local irq handler
  526. * @irq: the interrupt number
  527. * @desc: the interrupt description structure for this irq
  528. *
  529. * Per CPU interrupts on SMP machines without locking requirements
  530. */
  531. void
  532. handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
  533. {
  534. struct irq_chip *chip = irq_desc_get_chip(desc);
  535. kstat_incr_irqs_this_cpu(irq, desc);
  536. if (chip->irq_ack)
  537. chip->irq_ack(&desc->irq_data);
  538. handle_irq_event_percpu(desc, desc->action);
  539. if (chip->irq_eoi)
  540. chip->irq_eoi(&desc->irq_data);
  541. }
  542. void
  543. __irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
  544. const char *name)
  545. {
  546. unsigned long flags;
  547. struct irq_desc *desc = irq_get_desc_buslock(irq, &flags);
  548. if (!desc)
  549. return;
  550. if (!handle) {
  551. handle = handle_bad_irq;
  552. } else {
  553. if (WARN_ON(desc->irq_data.chip == &no_irq_chip))
  554. goto out;
  555. }
  556. /* Uninstall? */
  557. if (handle == handle_bad_irq) {
  558. if (desc->irq_data.chip != &no_irq_chip)
  559. mask_ack_irq(desc);
  560. irq_state_set_disabled(desc);
  561. desc->depth = 1;
  562. }
  563. desc->handle_irq = handle;
  564. desc->name = name;
  565. if (handle != handle_bad_irq && is_chained) {
  566. irq_settings_set_noprobe(desc);
  567. irq_settings_set_norequest(desc);
  568. irq_startup(desc);
  569. }
  570. out:
  571. irq_put_desc_busunlock(desc, flags);
  572. }
  573. EXPORT_SYMBOL_GPL(__irq_set_handler);
  574. void
  575. irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
  576. irq_flow_handler_t handle, const char *name)
  577. {
  578. irq_set_chip(irq, chip);
  579. __irq_set_handler(irq, handle, 0, name);
  580. }
  581. void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
  582. {
  583. unsigned long flags;
  584. struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
  585. if (!desc)
  586. return;
  587. irq_settings_clr_and_set(desc, clr, set);
  588. irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU |
  589. IRQD_TRIGGER_MASK | IRQD_LEVEL | IRQD_MOVE_PCNTXT);
  590. if (irq_settings_has_no_balance_set(desc))
  591. irqd_set(&desc->irq_data, IRQD_NO_BALANCING);
  592. if (irq_settings_is_per_cpu(desc))
  593. irqd_set(&desc->irq_data, IRQD_PER_CPU);
  594. if (irq_settings_can_move_pcntxt(desc))
  595. irqd_set(&desc->irq_data, IRQD_MOVE_PCNTXT);
  596. irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc));
  597. irq_put_desc_unlock(desc, flags);
  598. }