Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /// Find missing clk_puts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) ///
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) //# This only signals a missing clk_put when there is a clk_put later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) //# in the same function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) //# False positives can be due to loops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) // Confidence: Moderate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) // URL: http://coccinelle.lip6.fr/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) // Comments:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) // Options:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) virtual context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) virtual org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) virtual report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) @clk@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) expression e;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) statement S,S1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) position p1,p2,p3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) e = clk_get@p1(...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) ... when != clk_put(e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) if (<+...e...+>) S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) ... when any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)     when != clk_put(e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)     when != if (...) { ... clk_put(e); ... }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)  if (ret == 0) S1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) if (...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)    { ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)      return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) if (...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)    { ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)      return <+...e...+>; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) *if@p2 (...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)    { ... when != clk_put(e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)          when forall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)      return@p3 ...; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ... when any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) clk_put(e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) @script:python depends on org@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) p1 << clk.p1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) p2 << clk.p2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) p3 << clk.p3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) cocci.print_main("clk_get",p1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) cocci.print_secs("if",p2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) cocci.print_secs("needed clk_put",p3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) @script:python depends on report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) p1 << clk.p1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) p2 << clk.p2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) p3 << clk.p3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) msg = "ERROR: missing clk_put; clk_get on line %s and execution via conditional on line %s" % (p1[0].line,p2[0].line)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) coccilib.report.print_report(p3[0],msg)