Commit b7072c63 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Russell King

ARM: convert /proc/cpu/aligment to seq_file

Convert code away from ->read_proc/->write_proc interfaces.  Switch to
proc_create()/proc_create_data() which makes addition of proc entries
reliable wrt NULL ->proc_fops, NULL ->data and so on.

Problem with ->read_proc et al is described here commit
786d7e16 "Fix rmmod/read/write races in
/proc entries"

This patch is part of an effort to remove the old simple procfs PAGE_SIZE
buffer interface.
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 4d736b5e
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
...@@ -94,36 +95,29 @@ static const char *usermode_action[] = { ...@@ -94,36 +95,29 @@ static const char *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", ai_user);
int len; seq_printf(m, "System:\t\t%lu\n", ai_sys);
seq_printf(m, "Skipped:\t%lu\n", ai_skipped);
p += sprintf(p, "User:\t\t%lu\n", ai_user); seq_printf(m, "Half:\t\t%lu\n", ai_half);
p += sprintf(p, "System:\t\t%lu\n", ai_sys); seq_printf(m, "Word:\t\t%lu\n", ai_word);
p += sprintf(p, "Skipped:\t%lu\n", ai_skipped);
p += sprintf(p, "Half:\t\t%lu\n", ai_half);
p += sprintf(p, "Word:\t\t%lu\n", ai_word);
if (cpu_architecture() >= CPU_ARCH_ARMv5TE) if (cpu_architecture() >= CPU_ARCH_ARMv5TE)
p += sprintf(p, "DWord:\t\t%lu\n", ai_dword); seq_printf(m, "DWord:\t\t%lu\n", ai_dword);
p += sprintf(p, "Multi:\t\t%lu\n", ai_multi); seq_printf(m, "Multi:\t\t%lu\n", ai_multi);
p += sprintf(p, "User faults:\t%i (%s)\n", ai_usermode, seq_printf(m, "User faults:\t%i (%s)\n", ai_usermode,
usermode_action[ai_usermode]); usermode_action[ai_usermode]);
len = (p - page) - off; return 0;
if (len < 0) }
len = 0;
*eof = (len <= count) ? 1 : 0;
*start = page + off;
return len; static int alignment_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, alignment_proc_show, NULL);
} }
static int proc_alignment_write(struct file *file, const char __user *buffer, static ssize_t alignment_proc_write(struct file *file, const char __user *buffer,
unsigned long count, void *data) size_t count, loff_t *pos)
{ {
char mode; char mode;
...@@ -136,6 +130,13 @@ static int proc_alignment_write(struct file *file, const char __user *buffer, ...@@ -136,6 +130,13 @@ static int proc_alignment_write(struct file *file, const char __user *buffer,
return count; return count;
} }
static const struct file_operations alignment_proc_fops = {
.open = alignment_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = alignment_proc_write,
};
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
union offset_union { union offset_union {
...@@ -901,12 +902,10 @@ static int __init alignment_init(void) ...@@ -901,12 +902,10 @@ static int __init alignment_init(void)
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct proc_dir_entry *res; struct proc_dir_entry *res;
res = create_proc_entry("cpu/alignment", S_IWUSR | S_IRUGO, NULL); res = proc_create("cpu/alignment", S_IWUSR | S_IRUGO, NULL,
&alignment_proc_fops);
if (!res) if (!res)
return -ENOMEM; return -ENOMEM;
res->read_proc = proc_alignment_read;
res->write_proc = proc_alignment_write;
#endif #endif
/* /*
......
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