diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2018-07-09 03:23:41 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2018-07-10 01:58:06 -0400 |
commit | eb07fe9f9f28d4ce441c5b51653d421725b0c998 (patch) | |
tree | 2d6ebb63a5eb5eddd8ec016b992aa772085cc78b /arch/arm/mach-omap2/pm-debug.c | |
parent | 6d609b35c815ba20132b7b64bcca04516bb17c56 (diff) |
ARM: OMAP2+: reuse DEFINE_SHOW_ATTRIBUTE() macro
Reuse DEFINE_SHOW_ATTRIBUTE() macro instead of open coding file
operations followed by custom ->open() callbacks per each attribute.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/pm-debug.c')
-rw-r--r-- | arch/arm/mach-omap2/pm-debug.c | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c index acb698d5780f..5a8839203958 100644 --- a/arch/arm/mach-omap2/pm-debug.c +++ b/arch/arm/mach-omap2/pm-debug.c | |||
@@ -47,11 +47,6 @@ static int pm_dbg_init_done; | |||
47 | 47 | ||
48 | static int pm_dbg_init(void); | 48 | static int pm_dbg_init(void); |
49 | 49 | ||
50 | enum { | ||
51 | DEBUG_FILE_COUNTERS = 0, | ||
52 | DEBUG_FILE_TIMERS, | ||
53 | }; | ||
54 | |||
55 | static const char pwrdm_state_names[][PWRDM_MAX_PWRSTS] = { | 50 | static const char pwrdm_state_names[][PWRDM_MAX_PWRSTS] = { |
56 | "OFF", | 51 | "OFF", |
57 | "RET", | 52 | "RET", |
@@ -141,39 +136,21 @@ static int pwrdm_dbg_show_timer(struct powerdomain *pwrdm, void *user) | |||
141 | return 0; | 136 | return 0; |
142 | } | 137 | } |
143 | 138 | ||
144 | static int pm_dbg_show_counters(struct seq_file *s, void *unused) | 139 | static int pm_dbg_counters_show(struct seq_file *s, void *unused) |
145 | { | 140 | { |
146 | pwrdm_for_each(pwrdm_dbg_show_counter, s); | 141 | pwrdm_for_each(pwrdm_dbg_show_counter, s); |
147 | clkdm_for_each(clkdm_dbg_show_counter, s); | 142 | clkdm_for_each(clkdm_dbg_show_counter, s); |
148 | 143 | ||
149 | return 0; | 144 | return 0; |
150 | } | 145 | } |
146 | DEFINE_SHOW_ATTRIBUTE(pm_dbg_counters); | ||
151 | 147 | ||
152 | static int pm_dbg_show_timers(struct seq_file *s, void *unused) | 148 | static int pm_dbg_timers_show(struct seq_file *s, void *unused) |
153 | { | 149 | { |
154 | pwrdm_for_each(pwrdm_dbg_show_timer, s); | 150 | pwrdm_for_each(pwrdm_dbg_show_timer, s); |
155 | return 0; | 151 | return 0; |
156 | } | 152 | } |
157 | 153 | DEFINE_SHOW_ATTRIBUTE(pm_dbg_timers); | |
158 | static int pm_dbg_open(struct inode *inode, struct file *file) | ||
159 | { | ||
160 | switch ((int)inode->i_private) { | ||
161 | case DEBUG_FILE_COUNTERS: | ||
162 | return single_open(file, pm_dbg_show_counters, | ||
163 | &inode->i_private); | ||
164 | case DEBUG_FILE_TIMERS: | ||
165 | default: | ||
166 | return single_open(file, pm_dbg_show_timers, | ||
167 | &inode->i_private); | ||
168 | } | ||
169 | } | ||
170 | |||
171 | static const struct file_operations debug_fops = { | ||
172 | .open = pm_dbg_open, | ||
173 | .read = seq_read, | ||
174 | .llseek = seq_lseek, | ||
175 | .release = single_release, | ||
176 | }; | ||
177 | 154 | ||
178 | static int pwrdm_suspend_get(void *data, u64 *val) | 155 | static int pwrdm_suspend_get(void *data, u64 *val) |
179 | { | 156 | { |
@@ -259,10 +236,8 @@ static int __init pm_dbg_init(void) | |||
259 | if (!d) | 236 | if (!d) |
260 | return -EINVAL; | 237 | return -EINVAL; |
261 | 238 | ||
262 | (void) debugfs_create_file("count", S_IRUGO, | 239 | (void) debugfs_create_file("count", 0444, d, NULL, &pm_dbg_counters_fops); |
263 | d, (void *)DEBUG_FILE_COUNTERS, &debug_fops); | 240 | (void) debugfs_create_file("time", 0444, d, NULL, &pm_dbg_timers_fops); |
264 | (void) debugfs_create_file("time", S_IRUGO, | ||
265 | d, (void *)DEBUG_FILE_TIMERS, &debug_fops); | ||
266 | 241 | ||
267 | pwrdm_for_each(pwrdms_setup, (void *)d); | 242 | pwrdm_for_each(pwrdms_setup, (void *)d); |
268 | 243 | ||