Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Nicolai Stange | 5103068 | 2016-03-22 14:11:16 +0100 | [diff] [blame] | 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 | |
| 13 | virtual context |
| 14 | virtual patch |
| 15 | virtual org |
| 16 | virtual report |
| 17 | |
| 18 | @dsa@ |
| 19 | declarer name DEFINE_SIMPLE_ATTRIBUTE; |
| 20 | identifier dsa_fops; |
| 21 | expression dsa_get, dsa_set, dsa_fmt; |
| 22 | position p; |
| 23 | @@ |
| 24 | DEFINE_SIMPLE_ATTRIBUTE@p(dsa_fops, dsa_get, dsa_set, dsa_fmt); |
| 25 | |
| 26 | @dcf@ |
| 27 | expression name, mode, parent, data; |
| 28 | identifier dsa.dsa_fops; |
| 29 | @@ |
| 30 | debugfs_create_file(name, mode, parent, data, &dsa_fops) |
| 31 | |
| 32 | |
| 33 | @context_dsa depends on context && dcf@ |
| 34 | declarer name DEFINE_DEBUGFS_ATTRIBUTE; |
| 35 | identifier dsa.dsa_fops; |
| 36 | expression 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@ |
| 42 | expression name, mode, parent, data; |
| 43 | identifier 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@ |
| 49 | identifier dsa.dsa_fops; |
| 50 | expression 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@ |
| 57 | fops << dsa.dsa_fops; |
| 58 | p << dsa.p; |
| 59 | @@ |
| 60 | msg="%s should be defined with DEFINE_DEBUGFS_ATTRIBUTE" % (fops) |
| 61 | coccilib.org.print_todo(p[0], msg) |
| 62 | |
| 63 | @script:python depends on report && dcf@ |
| 64 | fops << dsa.dsa_fops; |
| 65 | p << dsa.p; |
| 66 | @@ |
| 67 | msg="WARNING: %s should be defined with DEFINE_DEBUGFS_ATTRIBUTE" % (fops) |
| 68 | coccilib.report.print_report(p[0], msg) |