irqf_oneshot.cocci 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // SPDX-License-Identifier: GPL-2.0
  2. /// Since commit 1c6c69525b40 ("genirq: Reject bogus threaded irq requests")
  3. /// threaded IRQs without a primary handler need to be requested with
  4. /// IRQF_ONESHOT, otherwise the request will fail.
  5. ///
  6. /// So pass the IRQF_ONESHOT flag in this case.
  7. ///
  8. //
  9. // Confidence: Moderate
  10. // Comments:
  11. // Options: --no-includes
  12. virtual patch
  13. virtual context
  14. virtual org
  15. virtual report
  16. @r1@
  17. expression dev, irq, thread_fn;
  18. position p;
  19. @@
  20. (
  21. request_threaded_irq@p(irq, NULL, thread_fn,
  22. (
  23. IRQF_ONESHOT | ...
  24. |
  25. IRQF_ONESHOT
  26. )
  27. , ...)
  28. |
  29. devm_request_threaded_irq@p(dev, irq, NULL, thread_fn,
  30. (
  31. IRQF_ONESHOT | ...
  32. |
  33. IRQF_ONESHOT
  34. )
  35. , ...)
  36. )
  37. @r2@
  38. expression dev, irq, thread_fn, flags, e;
  39. position p != r1.p;
  40. @@
  41. (
  42. flags = IRQF_ONESHOT | ...
  43. |
  44. flags |= IRQF_ONESHOT | ...
  45. )
  46. ... when != flags = e
  47. (
  48. request_threaded_irq@p(irq, NULL, thread_fn, flags, ...);
  49. |
  50. devm_request_threaded_irq@p(dev, irq, NULL, thread_fn, flags, ...);
  51. )
  52. @depends on patch@
  53. expression dev, irq, thread_fn, flags;
  54. position p != {r1.p,r2.p};
  55. @@
  56. (
  57. request_threaded_irq@p(irq, NULL, thread_fn,
  58. (
  59. -0
  60. +IRQF_ONESHOT
  61. |
  62. -flags
  63. +flags | IRQF_ONESHOT
  64. )
  65. , ...)
  66. |
  67. devm_request_threaded_irq@p(dev, irq, NULL, thread_fn,
  68. (
  69. -0
  70. +IRQF_ONESHOT
  71. |
  72. -flags
  73. +flags | IRQF_ONESHOT
  74. )
  75. , ...)
  76. )
  77. @depends on context@
  78. expression dev, irq;
  79. position p != {r1.p,r2.p};
  80. @@
  81. (
  82. *request_threaded_irq@p(irq, NULL, ...)
  83. |
  84. *devm_request_threaded_irq@p(dev, irq, NULL, ...)
  85. )
  86. @match depends on report || org@
  87. expression dev, irq;
  88. position p != {r1.p,r2.p};
  89. @@
  90. (
  91. request_threaded_irq@p(irq, NULL, ...)
  92. |
  93. devm_request_threaded_irq@p(dev, irq, NULL, ...)
  94. )
  95. @script:python depends on org@
  96. p << match.p;
  97. @@
  98. msg = "WARNING: Threaded IRQ with no primary handler requested without IRQF_ONESHOT (unless it is nested IRQ)"
  99. coccilib.org.print_todo(p[0],msg)
  100. @script:python depends on report@
  101. p << match.p;
  102. @@
  103. msg = "WARNING: Threaded IRQ with no primary handler requested without IRQF_ONESHOT (unless it is nested IRQ)"
  104. coccilib.report.print_report(p[0],msg)