1*7f904d7eSThomas Gleixner// SPDX-License-Identifier: GPL-2.0-only 241167d07SJulia Lawall/// Device node iterators put the previous value of the index variable, so an 341167d07SJulia Lawall/// explicit put causes a double put. 441167d07SJulia Lawall/// 541167d07SJulia Lawall// Confidence: High 6*7f904d7eSThomas Gleixner// Copyright: (C) 2015 Julia Lawall, Inria. 741167d07SJulia Lawall// URL: http://coccinelle.lip6.fr/ 841167d07SJulia Lawall// Options: --no-includes --include-headers 9cc65e823SLuis R. Rodriguez// Requires: 1.0.4 1041167d07SJulia Lawall// Keywords: for_each_child_of_node, etc. 1141167d07SJulia Lawall 12cc65e823SLuis R. Rodriguez// This uses a conjunction, which requires at least coccinelle >= 1.0.4 13cc65e823SLuis R. Rodriguez 1441167d07SJulia Lawallvirtual patch 1541167d07SJulia Lawallvirtual context 1641167d07SJulia Lawallvirtual org 1741167d07SJulia Lawallvirtual report 1841167d07SJulia Lawall 1941167d07SJulia Lawall@r exists@ 2041167d07SJulia Lawallexpression e1,e2; 2141167d07SJulia Lawalllocal idexpression n; 2241167d07SJulia Lawalliterator name for_each_node_by_name, for_each_node_by_type, 2341167d07SJulia Lawallfor_each_compatible_node, for_each_matching_node, 2441167d07SJulia Lawallfor_each_matching_node_and_match, for_each_child_of_node, 2541167d07SJulia Lawallfor_each_available_child_of_node, for_each_node_with_property; 2641167d07SJulia Lawalliterator i; 2741167d07SJulia Lawallposition p1,p2; 2841167d07SJulia Lawallstatement S; 2941167d07SJulia Lawall@@ 3041167d07SJulia Lawall 3141167d07SJulia Lawall( 3241167d07SJulia Lawall( 3341167d07SJulia Lawallfor_each_node_by_name(n,e1) S 3441167d07SJulia Lawall| 3541167d07SJulia Lawallfor_each_node_by_type(n,e1) S 3641167d07SJulia Lawall| 3741167d07SJulia Lawallfor_each_compatible_node(n,e1,e2) S 3841167d07SJulia Lawall| 3941167d07SJulia Lawallfor_each_matching_node(n,e1) S 4041167d07SJulia Lawall| 4141167d07SJulia Lawallfor_each_matching_node_and_match(n,e1,e2) S 4241167d07SJulia Lawall| 4341167d07SJulia Lawallfor_each_child_of_node(e1,n) S 4441167d07SJulia Lawall| 4541167d07SJulia Lawallfor_each_available_child_of_node(e1,n) S 4641167d07SJulia Lawall| 4741167d07SJulia Lawallfor_each_node_with_property(n,e1) S 4841167d07SJulia Lawall) 4941167d07SJulia Lawall& 5041167d07SJulia Lawalli@p1(...) { 5141167d07SJulia Lawall ... when != of_node_get(n) 5241167d07SJulia Lawall when any 5341167d07SJulia Lawall of_node_put@p2(n); 5441167d07SJulia Lawall ... when any 5541167d07SJulia Lawall} 5641167d07SJulia Lawall) 5741167d07SJulia Lawall 5841167d07SJulia Lawall@s exists@ 5941167d07SJulia Lawalllocal idexpression r.n; 6041167d07SJulia Lawallstatement S; 6141167d07SJulia Lawallposition r.p1,r.p2; 6241167d07SJulia Lawalliterator i; 6341167d07SJulia Lawall@@ 6441167d07SJulia Lawall 6541167d07SJulia Lawall of_node_put@p2(n); 6641167d07SJulia Lawall ... when any 6741167d07SJulia Lawall i@p1(..., n, ...) 6841167d07SJulia Lawall S 6941167d07SJulia Lawall 7041167d07SJulia Lawall@t depends on s && patch && !context && !org && !report@ 7141167d07SJulia Lawalllocal idexpression n; 7241167d07SJulia Lawallposition r.p2; 7341167d07SJulia Lawall@@ 7441167d07SJulia Lawall 7541167d07SJulia Lawall- of_node_put@p2(n); 7641167d07SJulia Lawall 7741167d07SJulia Lawall// ---------------------------------------------------------------------------- 7841167d07SJulia Lawall 7941167d07SJulia Lawall@t_context depends on s && !patch && (context || org || report)@ 8041167d07SJulia Lawalllocal idexpression n; 8141167d07SJulia Lawallposition r.p2; 8241167d07SJulia Lawallposition j0; 8341167d07SJulia Lawall@@ 8441167d07SJulia Lawall 8541167d07SJulia Lawall* of_node_put@j0@p2(n); 8641167d07SJulia Lawall 8741167d07SJulia Lawall// ---------------------------------------------------------------------------- 8841167d07SJulia Lawall 8941167d07SJulia Lawall@script:python t_org depends on org@ 9041167d07SJulia Lawallj0 << t_context.j0; 9141167d07SJulia Lawall@@ 9241167d07SJulia Lawall 9341167d07SJulia Lawallmsg = "ERROR: probable double put." 9441167d07SJulia Lawallcoccilib.org.print_todo(j0[0], msg) 9541167d07SJulia Lawall 9641167d07SJulia Lawall// ---------------------------------------------------------------------------- 9741167d07SJulia Lawall 9841167d07SJulia Lawall@script:python t_report depends on report@ 9941167d07SJulia Lawallj0 << t_context.j0; 10041167d07SJulia Lawall@@ 10141167d07SJulia Lawall 10241167d07SJulia Lawallmsg = "ERROR: probable double put." 10341167d07SJulia Lawallcoccilib.report.print_report(j0[0], msg) 10441167d07SJulia Lawall 105