Commit 9a160707 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Paul Mundt

sh: convert /proc/cpu/aligmnent, /proc/cpu/kernel_alignment to seq_file

Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 2ebe0ff7
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/kexec.h> #include <linux/kexec.h>
#include <linux/limits.h> #include <linux/limits.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -68,61 +69,49 @@ static const char *se_usermode_action[] = { ...@@ -68,61 +69,49 @@ static const char *se_usermode_action[] = {
"signal+warn" "signal+warn"
}; };
static int static int alignment_proc_show(struct seq_file *m, void *v)
proc_alignment_read(char *page, char **start, off_t off, int count, int *eof,
void *data)
{ {
char *p = page; seq_printf(m, "User:\t\t%lu\n", se_user);
int len; seq_printf(m, "System:\t\t%lu\n", se_sys);
seq_printf(m, "Half:\t\t%lu\n", se_half);
p += sprintf(p, "User:\t\t%lu\n", se_user); seq_printf(m, "Word:\t\t%lu\n", se_word);
p += sprintf(p, "System:\t\t%lu\n", se_sys); seq_printf(m, "DWord:\t\t%lu\n", se_dword);
p += sprintf(p, "Half:\t\t%lu\n", se_half); seq_printf(m, "Multi:\t\t%lu\n", se_multi);
p += sprintf(p, "Word:\t\t%lu\n", se_word); seq_printf(m, "User faults:\t%i (%s)\n", se_usermode,
p += sprintf(p, "DWord:\t\t%lu\n", se_dword);
p += sprintf(p, "Multi:\t\t%lu\n", se_multi);
p += sprintf(p, "User faults:\t%i (%s)\n", se_usermode,
se_usermode_action[se_usermode]); se_usermode_action[se_usermode]);
p += sprintf(p, "Kernel faults:\t%i (fixup%s)\n", se_kernmode_warn, seq_printf(m, "Kernel faults:\t%i (fixup%s)\n", se_kernmode_warn,
se_kernmode_warn ? "+warn" : ""); se_kernmode_warn ? "+warn" : "");
return 0;
len = (p - page) - off;
if (len < 0)
len = 0;
*eof = (len <= count) ? 1 : 0;
*start = page + off;
return len;
} }
static int proc_alignment_write(struct file *file, const char __user *buffer, static int alignment_proc_open(struct inode *inode, struct file *file)
unsigned long count, void *data)
{ {
char mode; return single_open(file, alignment_proc_show, NULL);
if (count > 0) {
if (get_user(mode, buffer))
return -EFAULT;
if (mode >= '0' && mode <= '5')
se_usermode = mode - '0';
}
return count;
} }
static int proc_alignment_kern_write(struct file *file, const char __user *buffer, static ssize_t alignment_proc_write(struct file *file,
unsigned long count, void *data) const char __user *buffer, size_t count, loff_t *pos)
{ {
int *data = PDE(file->f_path.dentry->d_inode)->data;
char mode; char mode;
if (count > 0) { if (count > 0) {
if (get_user(mode, buffer)) if (get_user(mode, buffer))
return -EFAULT; return -EFAULT;
if (mode >= '0' && mode <= '1') if (mode >= '0' && mode <= '5')
se_kernmode_warn = mode - '0'; *data = mode - '0';
} }
return count; return count;
} }
static const struct file_operations alignment_proc_fops = {
.owner = THIS_MODULE,
.open = alignment_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = alignment_proc_write,
};
#endif #endif
static void dump_mem(const char *str, unsigned long bottom, unsigned long top) static void dump_mem(const char *str, unsigned long bottom, unsigned long top)
...@@ -1006,20 +995,16 @@ static int __init alignment_init(void) ...@@ -1006,20 +995,16 @@ static int __init alignment_init(void)
if (!dir) if (!dir)
return -ENOMEM; return -ENOMEM;
res = create_proc_entry("alignment", S_IWUSR | S_IRUGO, dir); res = proc_create_data("alignment", S_IWUSR | S_IRUGO, dir,
&alignment_proc_fops, &se_usermode);
if (!res) if (!res)
return -ENOMEM; return -ENOMEM;
res->read_proc = proc_alignment_read; res = proc_create_data("kernel_alignment", S_IWUSR | S_IRUGO, dir,
res->write_proc = proc_alignment_write; &alignment_proc_fops, &se_kernmode_warn);
res = create_proc_entry("kernel_alignment", S_IWUSR | S_IRUGO, dir);
if (!res) if (!res)
return -ENOMEM; return -ENOMEM;
res->read_proc = proc_alignment_read;
res->write_proc = proc_alignment_kern_write;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment