1// SPDX-License-Identifier: GPL-2.0-only 2/// 3/// Use kobj_to_dev() instead of container_of() 4/// 5// Confidence: High 6// Copyright: (C) 2020 Denis Efremov ISPRAS 7// Options: --no-includes --include-headers 8// 9// Keywords: kobj_to_dev, container_of 10// 11 12virtual context 13virtual report 14virtual org 15virtual patch 16 17 18@r depends on !patch@ 19expression ptr; 20symbol kobj; 21position p; 22@@ 23 24* container_of(ptr, struct device, kobj)@p 25 26 27@depends on patch@ 28expression ptr; 29@@ 30 31- container_of(ptr, struct device, kobj) 32+ kobj_to_dev(ptr) 33 34 35@script:python depends on report@ 36p << r.p; 37@@ 38 39coccilib.report.print_report(p[0], "WARNING opportunity for kobj_to_dev()") 40 41@script:python depends on org@ 42p << r.p; 43@@ 44 45coccilib.org.print_todo(p[0], "WARNING opportunity for kobj_to_dev()") 46