diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2009-11-27 01:42:16 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-11-29 22:02:50 -0500 |
commit | 9a1607071c293e48b08bd703733480b1d55c7b93 (patch) | |
tree | 3b9ced9f290a38fc83cc994791d50b670cc04887 /arch | |
parent | 2ebe0ff7e669e7d5fc51c2add74dd71692d7bc8d (diff) |
sh: convert /proc/cpu/aligmnent, /proc/cpu/kernel_alignment to seq_file
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sh/kernel/traps_32.c | 77 |
1 files changed, 31 insertions, 46 deletions
diff --git a/arch/sh/kernel/traps_32.c b/arch/sh/kernel/traps_32.c index 114d21761823..3da5a125d884 100644 --- a/arch/sh/kernel/traps_32.c +++ b/arch/sh/kernel/traps_32.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/kexec.h> | 25 | #include <linux/kexec.h> |
26 | #include <linux/limits.h> | 26 | #include <linux/limits.h> |
27 | #include <linux/proc_fs.h> | 27 | #include <linux/proc_fs.h> |
28 | #include <linux/seq_file.h> | ||
28 | #include <linux/sysfs.h> | 29 | #include <linux/sysfs.h> |
29 | #include <asm/system.h> | 30 | #include <asm/system.h> |
30 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
@@ -68,61 +69,49 @@ static const char *se_usermode_action[] = { | |||
68 | "signal+warn" | 69 | "signal+warn" |
69 | }; | 70 | }; |
70 | 71 | ||
71 | static int | 72 | static int alignment_proc_show(struct seq_file *m, void *v) |
72 | proc_alignment_read(char *page, char **start, off_t off, int count, int *eof, | ||
73 | void *data) | ||
74 | { | 73 | { |
75 | char *p = page; | 74 | seq_printf(m, "User:\t\t%lu\n", se_user); |
76 | int len; | 75 | seq_printf(m, "System:\t\t%lu\n", se_sys); |
77 | 76 | seq_printf(m, "Half:\t\t%lu\n", se_half); | |
78 | p += sprintf(p, "User:\t\t%lu\n", se_user); | 77 | seq_printf(m, "Word:\t\t%lu\n", se_word); |
79 | p += sprintf(p, "System:\t\t%lu\n", se_sys); | 78 | seq_printf(m, "DWord:\t\t%lu\n", se_dword); |
80 | p += sprintf(p, "Half:\t\t%lu\n", se_half); | 79 | seq_printf(m, "Multi:\t\t%lu\n", se_multi); |
81 | p += sprintf(p, "Word:\t\t%lu\n", se_word); | 80 | seq_printf(m, "User faults:\t%i (%s)\n", se_usermode, |
82 | p += sprintf(p, "DWord:\t\t%lu\n", se_dword); | ||
83 | p += sprintf(p, "Multi:\t\t%lu\n", se_multi); | ||
84 | p += sprintf(p, "User faults:\t%i (%s)\n", se_usermode, | ||
85 | se_usermode_action[se_usermode]); | 81 | se_usermode_action[se_usermode]); |
86 | p += sprintf(p, "Kernel faults:\t%i (fixup%s)\n", se_kernmode_warn, | 82 | seq_printf(m, "Kernel faults:\t%i (fixup%s)\n", se_kernmode_warn, |
87 | se_kernmode_warn ? "+warn" : ""); | 83 | se_kernmode_warn ? "+warn" : ""); |
88 | 84 | return 0; | |
89 | len = (p - page) - off; | ||
90 | if (len < 0) | ||
91 | len = 0; | ||
92 | |||
93 | *eof = (len <= count) ? 1 : 0; | ||
94 | *start = page + off; | ||
95 | |||
96 | return len; | ||
97 | } | 85 | } |
98 | 86 | ||
99 | static int proc_alignment_write(struct file *file, const char __user *buffer, | 87 | static int alignment_proc_open(struct inode *inode, struct file *file) |
100 | unsigned long count, void *data) | ||
101 | { | 88 | { |
102 | char mode; | 89 | return single_open(file, alignment_proc_show, NULL); |
103 | |||
104 | if (count > 0) { | ||
105 | if (get_user(mode, buffer)) | ||
106 | return -EFAULT; | ||
107 | if (mode >= '0' && mode <= '5') | ||
108 | se_usermode = mode - '0'; | ||
109 | } | ||
110 | return count; | ||
111 | } | 90 | } |
112 | 91 | ||
113 | static int proc_alignment_kern_write(struct file *file, const char __user *buffer, | 92 | static ssize_t alignment_proc_write(struct file *file, |
114 | unsigned long count, void *data) | 93 | const char __user *buffer, size_t count, loff_t *pos) |
115 | { | 94 | { |
95 | int *data = PDE(file->f_path.dentry->d_inode)->data; | ||
116 | char mode; | 96 | char mode; |
117 | 97 | ||
118 | if (count > 0) { | 98 | if (count > 0) { |
119 | if (get_user(mode, buffer)) | 99 | if (get_user(mode, buffer)) |
120 | return -EFAULT; | 100 | return -EFAULT; |
121 | if (mode >= '0' && mode <= '1') | 101 | if (mode >= '0' && mode <= '5') |
122 | se_kernmode_warn = mode - '0'; | 102 | *data = mode - '0'; |
123 | } | 103 | } |
124 | return count; | 104 | return count; |
125 | } | 105 | } |
106 | |||
107 | static const struct file_operations alignment_proc_fops = { | ||
108 | .owner = THIS_MODULE, | ||
109 | .open = alignment_proc_open, | ||
110 | .read = seq_read, | ||
111 | .llseek = seq_lseek, | ||
112 | .release = single_release, | ||
113 | .write = alignment_proc_write, | ||
114 | }; | ||
126 | #endif | 115 | #endif |
127 | 116 | ||
128 | static void dump_mem(const char *str, unsigned long bottom, unsigned long top) | 117 | static void dump_mem(const char *str, unsigned long bottom, unsigned long top) |
@@ -1006,20 +995,16 @@ static int __init alignment_init(void) | |||
1006 | if (!dir) | 995 | if (!dir) |
1007 | return -ENOMEM; | 996 | return -ENOMEM; |
1008 | 997 | ||
1009 | res = create_proc_entry("alignment", S_IWUSR | S_IRUGO, dir); | 998 | res = proc_create_data("alignment", S_IWUSR | S_IRUGO, dir, |
999 | &alignment_proc_fops, &se_usermode); | ||
1010 | if (!res) | 1000 | if (!res) |
1011 | return -ENOMEM; | 1001 | return -ENOMEM; |
1012 | 1002 | ||
1013 | res->read_proc = proc_alignment_read; | 1003 | res = proc_create_data("kernel_alignment", S_IWUSR | S_IRUGO, dir, |
1014 | res->write_proc = proc_alignment_write; | 1004 | &alignment_proc_fops, &se_kernmode_warn); |
1015 | |||
1016 | res = create_proc_entry("kernel_alignment", S_IWUSR | S_IRUGO, dir); | ||
1017 | if (!res) | 1005 | if (!res) |
1018 | return -ENOMEM; | 1006 | return -ENOMEM; |
1019 | 1007 | ||
1020 | res->read_proc = proc_alignment_read; | ||
1021 | res->write_proc = proc_alignment_kern_write; | ||
1022 | |||
1023 | return 0; | 1008 | return 0; |
1024 | } | 1009 | } |
1025 | 1010 | ||