• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// SPDX-License-Identifier: GPL-2.0
2/// Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
3/// for debugfs files.
4///
5//# Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
6//# imposes some significant overhead as compared to
7//# DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().
8//
9// Copyright (C): 2016 Nicolai Stange
10// Options: --no-includes
11//
12
13virtual context
14virtual patch
15virtual org
16virtual report
17
18@dsa@
19declarer name DEFINE_SIMPLE_ATTRIBUTE;
20identifier dsa_fops;
21expression dsa_get, dsa_set, dsa_fmt;
22position p;
23@@
24DEFINE_SIMPLE_ATTRIBUTE@p(dsa_fops, dsa_get, dsa_set, dsa_fmt);
25
26@dcf@
27expression name, mode, parent, data;
28identifier dsa.dsa_fops;
29@@
30debugfs_create_file(name, mode, parent, data, &dsa_fops)
31
32
33@context_dsa depends on context && dcf@
34declarer name DEFINE_DEBUGFS_ATTRIBUTE;
35identifier dsa.dsa_fops;
36expression dsa.dsa_get, dsa.dsa_set, dsa.dsa_fmt;
37@@
38* DEFINE_SIMPLE_ATTRIBUTE(dsa_fops, dsa_get, dsa_set, dsa_fmt);
39
40
41@patch_dcf depends on patch expression@
42expression name, mode, parent, data;
43identifier dsa.dsa_fops;
44@@
45- debugfs_create_file(name, mode, parent, data, &dsa_fops)
46+ debugfs_create_file_unsafe(name, mode, parent, data, &dsa_fops)
47
48@patch_dsa depends on patch_dcf && patch@
49identifier dsa.dsa_fops;
50expression dsa.dsa_get, dsa.dsa_set, dsa.dsa_fmt;
51@@
52- DEFINE_SIMPLE_ATTRIBUTE(dsa_fops, dsa_get, dsa_set, dsa_fmt);
53+ DEFINE_DEBUGFS_ATTRIBUTE(dsa_fops, dsa_get, dsa_set, dsa_fmt);
54
55
56@script:python depends on org && dcf@
57fops << dsa.dsa_fops;
58p << dsa.p;
59@@
60msg="%s should be defined with DEFINE_DEBUGFS_ATTRIBUTE" % (fops)
61coccilib.org.print_todo(p[0], msg)
62
63@script:python depends on report && dcf@
64fops << dsa.dsa_fops;
65p << dsa.p;
66@@
67msg="WARNING: %s should be defined with DEFINE_DEBUGFS_ATTRIBUTE" % (fops)
68coccilib.report.print_report(p[0], msg)
69