diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2014-04-15 20:46:11 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-05-21 05:12:55 -0400 |
commit | 85c51c511d6373d4bc859458fd3f130015db31a5 (patch) | |
tree | c0b1076aba628760c3a9da5c46b818d2158634ad /arch/mips/math-emu/me-debugfs.c | |
parent | 6d18b6246d2bfb9da2d342553e41565e14422089 (diff) |
MIPS: math-emu: Move all debug fs code to a separate file.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/math-emu/me-debugfs.c')
-rw-r--r-- | arch/mips/math-emu/me-debugfs.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/arch/mips/math-emu/me-debugfs.c b/arch/mips/math-emu/me-debugfs.c new file mode 100644 index 000000000000..d895b38773df --- /dev/null +++ b/arch/mips/math-emu/me-debugfs.c | |||
@@ -0,0 +1,59 @@ | |||
1 | #include <linux/cpumask.h> | ||
2 | #include <linux/debugfs.h> | ||
3 | #include <linux/fs.h> | ||
4 | #include <linux/init.h> | ||
5 | #include <linux/percpu.h> | ||
6 | #include <linux/types.h> | ||
7 | #include <asm/fpu_emulator.h> | ||
8 | #include <asm/local.h> | ||
9 | |||
10 | DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats); | ||
11 | |||
12 | static int fpuemu_stat_get(void *data, u64 *val) | ||
13 | { | ||
14 | int cpu; | ||
15 | unsigned long sum = 0; | ||
16 | |||
17 | for_each_online_cpu(cpu) { | ||
18 | struct mips_fpu_emulator_stats *ps; | ||
19 | local_t *pv; | ||
20 | |||
21 | ps = &per_cpu(fpuemustats, cpu); | ||
22 | pv = (void *)ps + (unsigned long)data; | ||
23 | sum += local_read(pv); | ||
24 | } | ||
25 | *val = sum; | ||
26 | return 0; | ||
27 | } | ||
28 | DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n"); | ||
29 | |||
30 | extern struct dentry *mips_debugfs_dir; | ||
31 | static int __init debugfs_fpuemu(void) | ||
32 | { | ||
33 | struct dentry *d, *dir; | ||
34 | |||
35 | if (!mips_debugfs_dir) | ||
36 | return -ENODEV; | ||
37 | dir = debugfs_create_dir("fpuemustats", mips_debugfs_dir); | ||
38 | if (!dir) | ||
39 | return -ENOMEM; | ||
40 | |||
41 | #define FPU_STAT_CREATE(M) \ | ||
42 | do { \ | ||
43 | d = debugfs_create_file(#M , S_IRUGO, dir, \ | ||
44 | (void *)offsetof(struct mips_fpu_emulator_stats, M), \ | ||
45 | &fops_fpuemu_stat); \ | ||
46 | if (!d) \ | ||
47 | return -ENOMEM; \ | ||
48 | } while (0) | ||
49 | |||
50 | FPU_STAT_CREATE(emulated); | ||
51 | FPU_STAT_CREATE(loads); | ||
52 | FPU_STAT_CREATE(stores); | ||
53 | FPU_STAT_CREATE(cp1ops); | ||
54 | FPU_STAT_CREATE(cp1xops); | ||
55 | FPU_STAT_CREATE(errors); | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | __initcall(debugfs_fpuemu); | ||