irqf_oneshot.cocci 1.9 KB

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