aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-01 20:51:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-01 20:51:54 -0400
commit20b4fb485227404329e41ad15588afad3df23050 (patch)
treef3e099f0ab3da8a93b447203e294d2bb22f6dc05 /arch
parentb9394d8a657cd3c064fa432aa0905c1b58b38fe9 (diff)
parentac3e3c5b1164397656df81b9e9ab4991184d3236 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull VFS updates from Al Viro, Misc cleanups all over the place, mainly wrt /proc interfaces (switch create_proc_entry to proc_create(), get rid of the deprecated create_proc_read_entry() in favor of using proc_create_data() and seq_file etc). 7kloc removed. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (204 commits) don't bother with deferred freeing of fdtables proc: Move non-public stuff from linux/proc_fs.h to fs/proc/internal.h proc: Make the PROC_I() and PDE() macros internal to procfs proc: Supply a function to remove a proc entry by PDE take cgroup_open() and cpuset_open() to fs/proc/base.c ppc: Clean up scanlog ppc: Clean up rtas_flash driver somewhat hostap: proc: Use remove_proc_subtree() drm: proc: Use remove_proc_subtree() drm: proc: Use minor->index to label things, not PDE->name drm: Constify drm_proc_list[] zoran: Don't print proc_dir_entry data in debug reiserfs: Don't access the proc_dir_entry in r_open(), r_start() r_show() proc: Supply an accessor for getting the data from a PDE's parent airo: Use remove_proc_subtree() rtl8192u: Don't need to save device proc dir PDE rtl8187se: Use a dir under /proc/net/r8180/ proc: Add proc_mkdir_data() proc: Move some bits from linux/proc_fs.h to linux/{of.h,signal.h,tty.h} proc: Move PDE_NET() to fs/proc/proc_net.c ...
Diffstat (limited to 'arch')
-rw-r--r--arch/alpha/kernel/srm_env.c93
-rw-r--r--arch/arm/kernel/atags_proc.c28
-rw-r--r--arch/arm/kernel/swp_emulate.c43
-rw-r--r--arch/arm/mach-msm/last_radio_log.c20
-rw-r--r--arch/arm/mach-omap1/pm.c78
-rw-r--r--arch/blackfin/kernel/cplbinfo.c4
-rw-r--r--arch/cris/arch-v10/kernel/fasttimer.c301
-rw-r--r--arch/cris/arch-v32/kernel/fasttimer.c299
-rw-r--r--arch/h8300/kernel/gpio.c35
-rw-r--r--arch/ia64/kernel/palinfo.c502
-rw-r--r--arch/ia64/kernel/salinfo.c57
-rw-r--r--arch/ia64/sn/kernel/sn2/prominfo_proc.c146
-rw-r--r--arch/mips/kernel/smtc-proc.c64
-rw-r--r--arch/mips/lasat/picvue_proc.c4
-rw-r--r--arch/mips/mm/init.c1
-rw-r--r--arch/mips/pci/ops-pmcmsp.c95
-rw-r--r--arch/mips/sibyte/sb1250/bus_watcher.c81
-rw-r--r--arch/parisc/kernel/pdc_chassis.c47
-rw-r--r--arch/powerpc/kernel/lparcfg.c11
-rw-r--r--arch/powerpc/kernel/proc_powerpc.c21
-rw-r--r--arch/powerpc/kernel/rtas_flash.c452
-rw-r--r--arch/powerpc/kvm/book3s_64_mmu_hv.c2
-rw-r--r--arch/powerpc/kvm/book3s_64_vio.c2
-rw-r--r--arch/powerpc/kvm/book3s_hv.c2
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c2
-rw-r--r--arch/powerpc/platforms/pseries/reconfig.c2
-rw-r--r--arch/powerpc/platforms/pseries/scanlog.c32
-rw-r--r--arch/s390/kernel/compat_wrapper.S16
-rw-r--r--arch/s390/kernel/irq.c6
-rw-r--r--arch/s390/kernel/os_info.c1
-rw-r--r--arch/s390/kernel/syscalls.S4
-rw-r--r--arch/score/mm/init.c2
-rw-r--r--arch/sh/drivers/dma/dma-api.c28
-rw-r--r--arch/sh/mm/alignment.c2
-rw-r--r--arch/sparc/kernel/ioport.c2
-rw-r--r--arch/sparc/kernel/sun4d_irq.c1
-rw-r--r--arch/tile/kernel/hardwall.c2
-rw-r--r--arch/um/drivers/mconsole_kern.c3
-rw-r--r--arch/x86/ia32/ia32_aout.c30
-rw-r--r--arch/x86/mm/init_64.c1
-rw-r--r--arch/x86/platform/efi/efi.c1
-rw-r--r--arch/x86/platform/efi/efi_64.c1
-rw-r--r--arch/xtensa/platforms/iss/simdisk.c36
43 files changed, 1109 insertions, 1451 deletions
diff --git a/arch/alpha/kernel/srm_env.c b/arch/alpha/kernel/srm_env.c
index e64559f0a82d..ffe996a54fad 100644
--- a/arch/alpha/kernel/srm_env.c
+++ b/arch/alpha/kernel/srm_env.c
@@ -51,13 +51,11 @@ MODULE_LICENSE("GPL");
51typedef struct _srm_env { 51typedef struct _srm_env {
52 char *name; 52 char *name;
53 unsigned long id; 53 unsigned long id;
54 struct proc_dir_entry *proc_entry;
55} srm_env_t; 54} srm_env_t;
56 55
57static struct proc_dir_entry *base_dir; 56static struct proc_dir_entry *base_dir;
58static struct proc_dir_entry *named_dir; 57static struct proc_dir_entry *named_dir;
59static struct proc_dir_entry *numbered_dir; 58static struct proc_dir_entry *numbered_dir;
60static char number[256][4];
61 59
62static srm_env_t srm_named_entries[] = { 60static srm_env_t srm_named_entries[] = {
63 { "auto_action", ENV_AUTO_ACTION }, 61 { "auto_action", ENV_AUTO_ACTION },
@@ -77,21 +75,18 @@ static srm_env_t srm_named_entries[] = {
77 { "tty_dev", ENV_TTY_DEV }, 75 { "tty_dev", ENV_TTY_DEV },
78 { NULL, 0 }, 76 { NULL, 0 },
79}; 77};
80static srm_env_t srm_numbered_entries[256];
81
82 78
83static int srm_env_proc_show(struct seq_file *m, void *v) 79static int srm_env_proc_show(struct seq_file *m, void *v)
84{ 80{
85 unsigned long ret; 81 unsigned long ret;
86 srm_env_t *entry; 82 unsigned long id = (unsigned long)m->private;
87 char *page; 83 char *page;
88 84
89 entry = m->private;
90 page = (char *)__get_free_page(GFP_USER); 85 page = (char *)__get_free_page(GFP_USER);
91 if (!page) 86 if (!page)
92 return -ENOMEM; 87 return -ENOMEM;
93 88
94 ret = callback_getenv(entry->id, page, PAGE_SIZE); 89 ret = callback_getenv(id, page, PAGE_SIZE);
95 90
96 if ((ret >> 61) == 0) { 91 if ((ret >> 61) == 0) {
97 seq_write(m, page, ret); 92 seq_write(m, page, ret);
@@ -104,14 +99,14 @@ static int srm_env_proc_show(struct seq_file *m, void *v)
104 99
105static int srm_env_proc_open(struct inode *inode, struct file *file) 100static int srm_env_proc_open(struct inode *inode, struct file *file)
106{ 101{
107 return single_open(file, srm_env_proc_show, PDE(inode)->data); 102 return single_open(file, srm_env_proc_show, PDE_DATA(inode));
108} 103}
109 104
110static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer, 105static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer,
111 size_t count, loff_t *pos) 106 size_t count, loff_t *pos)
112{ 107{
113 int res; 108 int res;
114 srm_env_t *entry = PDE(file_inode(file))->data; 109 unsigned long id = (unsigned long)PDE_DATA(file_inode(file));
115 char *buf = (char *) __get_free_page(GFP_USER); 110 char *buf = (char *) __get_free_page(GFP_USER);
116 unsigned long ret1, ret2; 111 unsigned long ret1, ret2;
117 112
@@ -127,7 +122,7 @@ static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer,
127 goto out; 122 goto out;
128 buf[count] = '\0'; 123 buf[count] = '\0';
129 124
130 ret1 = callback_setenv(entry->id, buf, count); 125 ret1 = callback_setenv(id, buf, count);
131 if ((ret1 >> 61) == 0) { 126 if ((ret1 >> 61) == 0) {
132 do 127 do
133 ret2 = callback_save_env(); 128 ret2 = callback_save_env();
@@ -149,52 +144,6 @@ static const struct file_operations srm_env_proc_fops = {
149 .write = srm_env_proc_write, 144 .write = srm_env_proc_write,
150}; 145};
151 146
152static void
153srm_env_cleanup(void)
154{
155 srm_env_t *entry;
156 unsigned long var_num;
157
158 if (base_dir) {
159 /*
160 * Remove named entries
161 */
162 if (named_dir) {
163 entry = srm_named_entries;
164 while (entry->name != NULL && entry->id != 0) {
165 if (entry->proc_entry) {
166 remove_proc_entry(entry->name,
167 named_dir);
168 entry->proc_entry = NULL;
169 }
170 entry++;
171 }
172 remove_proc_entry(NAMED_DIR, base_dir);
173 }
174
175 /*
176 * Remove numbered entries
177 */
178 if (numbered_dir) {
179 for (var_num = 0; var_num <= 255; var_num++) {
180 entry = &srm_numbered_entries[var_num];
181
182 if (entry->proc_entry) {
183 remove_proc_entry(entry->name,
184 numbered_dir);
185 entry->proc_entry = NULL;
186 entry->name = NULL;
187 }
188 }
189 remove_proc_entry(NUMBERED_DIR, base_dir);
190 }
191
192 remove_proc_entry(BASE_DIR, NULL);
193 }
194
195 return;
196}
197
198static int __init 147static int __init
199srm_env_init(void) 148srm_env_init(void)
200{ 149{
@@ -213,19 +162,13 @@ srm_env_init(void)
213 } 162 }
214 163
215 /* 164 /*
216 * Init numbers
217 */
218 for (var_num = 0; var_num <= 255; var_num++)
219 sprintf(number[var_num], "%ld", var_num);
220
221 /*
222 * Create base directory 165 * Create base directory
223 */ 166 */
224 base_dir = proc_mkdir(BASE_DIR, NULL); 167 base_dir = proc_mkdir(BASE_DIR, NULL);
225 if (!base_dir) { 168 if (!base_dir) {
226 printk(KERN_ERR "Couldn't create base dir /proc/%s\n", 169 printk(KERN_ERR "Couldn't create base dir /proc/%s\n",
227 BASE_DIR); 170 BASE_DIR);
228 goto cleanup; 171 return -ENOMEM;
229 } 172 }
230 173
231 /* 174 /*
@@ -254,9 +197,8 @@ srm_env_init(void)
254 */ 197 */
255 entry = srm_named_entries; 198 entry = srm_named_entries;
256 while (entry->name && entry->id) { 199 while (entry->name && entry->id) {
257 entry->proc_entry = proc_create_data(entry->name, 0644, named_dir, 200 if (!proc_create_data(entry->name, 0644, named_dir,
258 &srm_env_proc_fops, entry); 201 &srm_env_proc_fops, (void *)entry->id))
259 if (!entry->proc_entry)
260 goto cleanup; 202 goto cleanup;
261 entry++; 203 entry++;
262 } 204 }
@@ -265,15 +207,11 @@ srm_env_init(void)
265 * Create all numbered nodes 207 * Create all numbered nodes
266 */ 208 */
267 for (var_num = 0; var_num <= 255; var_num++) { 209 for (var_num = 0; var_num <= 255; var_num++) {
268 entry = &srm_numbered_entries[var_num]; 210 char name[4];
269 entry->name = number[var_num]; 211 sprintf(name, "%ld", var_num);
270 212 if (!proc_create_data(name, 0644, numbered_dir,
271 entry->proc_entry = proc_create_data(entry->name, 0644, numbered_dir, 213 &srm_env_proc_fops, (void *)var_num))
272 &srm_env_proc_fops, entry);
273 if (!entry->proc_entry)
274 goto cleanup; 214 goto cleanup;
275
276 entry->id = var_num;
277 } 215 }
278 216
279 printk(KERN_INFO "%s: version %s loaded successfully\n", NAME, 217 printk(KERN_INFO "%s: version %s loaded successfully\n", NAME,
@@ -282,18 +220,15 @@ srm_env_init(void)
282 return 0; 220 return 0;
283 221
284cleanup: 222cleanup:
285 srm_env_cleanup(); 223 remove_proc_subtree(BASE_DIR, NULL);
286
287 return -ENOMEM; 224 return -ENOMEM;
288} 225}
289 226
290static void __exit 227static void __exit
291srm_env_exit(void) 228srm_env_exit(void)
292{ 229{
293 srm_env_cleanup(); 230 remove_proc_subtree(BASE_DIR, NULL);
294 printk(KERN_INFO "%s: unloaded successfully\n", NAME); 231 printk(KERN_INFO "%s: unloaded successfully\n", NAME);
295
296 return;
297} 232}
298 233
299module_init(srm_env_init); 234module_init(srm_env_init);
diff --git a/arch/arm/kernel/atags_proc.c b/arch/arm/kernel/atags_proc.c
index 42a1a1415fa6..c7ff8073416f 100644
--- a/arch/arm/kernel/atags_proc.c
+++ b/arch/arm/kernel/atags_proc.c
@@ -9,24 +9,18 @@ struct buffer {
9 char data[]; 9 char data[];
10}; 10};
11 11
12static int 12static ssize_t atags_read(struct file *file, char __user *buf,
13read_buffer(char* page, char** start, off_t off, int count, 13 size_t count, loff_t *ppos)
14 int* eof, void* data)
15{ 14{
16 struct buffer *buffer = (struct buffer *)data; 15 struct buffer *b = PDE_DATA(file_inode(file));
17 16 return simple_read_from_buffer(buf, count, ppos, b->data, b->size);
18 if (off >= buffer->size) {
19 *eof = 1;
20 return 0;
21 }
22
23 count = min((int) (buffer->size - off), count);
24
25 memcpy(page, &buffer->data[off], count);
26
27 return count;
28} 17}
29 18
19static const struct file_operations atags_fops = {
20 .read = atags_read,
21 .llseek = default_llseek,
22};
23
30#define BOOT_PARAMS_SIZE 1536 24#define BOOT_PARAMS_SIZE 1536
31static char __initdata atags_copy[BOOT_PARAMS_SIZE]; 25static char __initdata atags_copy[BOOT_PARAMS_SIZE];
32 26
@@ -66,9 +60,7 @@ static int __init init_atags_procfs(void)
66 b->size = size; 60 b->size = size;
67 memcpy(b->data, atags_copy, size); 61 memcpy(b->data, atags_copy, size);
68 62
69 tags_entry = create_proc_read_entry("atags", 0400, 63 tags_entry = proc_create_data("atags", 0400, NULL, &atags_fops, b);
70 NULL, read_buffer, b);
71
72 if (!tags_entry) 64 if (!tags_entry)
73 goto nomem; 65 goto nomem;
74 66
diff --git a/arch/arm/kernel/swp_emulate.c b/arch/arm/kernel/swp_emulate.c
index ab1017bd1667..087fc321e9e5 100644
--- a/arch/arm/kernel/swp_emulate.c
+++ b/arch/arm/kernel/swp_emulate.c
@@ -21,6 +21,7 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/proc_fs.h> 23#include <linux/proc_fs.h>
24#include <linux/seq_file.h>
24#include <linux/sched.h> 25#include <linux/sched.h>
25#include <linux/syscalls.h> 26#include <linux/syscalls.h>
26#include <linux/perf_event.h> 27#include <linux/perf_event.h>
@@ -79,27 +80,27 @@ static unsigned long abtcounter;
79static pid_t previous_pid; 80static pid_t previous_pid;
80 81
81#ifdef CONFIG_PROC_FS 82#ifdef CONFIG_PROC_FS
82static int proc_read_status(char *page, char **start, off_t off, int count, 83static int proc_status_show(struct seq_file *m, void *v)
83 int *eof, void *data)
84{ 84{
85 char *p = page; 85 seq_printf(m, "Emulated SWP:\t\t%lu\n", swpcounter);
86 int len; 86 seq_printf(m, "Emulated SWPB:\t\t%lu\n", swpbcounter);
87 87 seq_printf(m, "Aborted SWP{B}:\t\t%lu\n", abtcounter);
88 p += sprintf(p, "Emulated SWP:\t\t%lu\n", swpcounter);
89 p += sprintf(p, "Emulated SWPB:\t\t%lu\n", swpbcounter);
90 p += sprintf(p, "Aborted SWP{B}:\t\t%lu\n", abtcounter);
91 if (previous_pid != 0) 88 if (previous_pid != 0)
92 p += sprintf(p, "Last process:\t\t%d\n", previous_pid); 89 seq_printf(m, "Last process:\t\t%d\n", previous_pid);
93 90 return 0;
94 len = (p - page) - off; 91}
95 if (len < 0)
96 len = 0;
97
98 *eof = (len <= count) ? 1 : 0;
99 *start = page + off;
100 92
101 return len; 93static int proc_status_open(struct inode *inode, struct file *file)
94{
95 return single_open(file, proc_status_show, PDE_DATA(inode));
102} 96}
97
98static const struct file_operations proc_status_fops = {
99 .open = proc_status_open,
100 .read = seq_read,
101 .llseek = seq_lseek,
102 .release = seq_release,
103};
103#endif 104#endif
104 105
105/* 106/*
@@ -266,14 +267,8 @@ static struct undef_hook swp_hook = {
266static int __init swp_emulation_init(void) 267static int __init swp_emulation_init(void)
267{ 268{
268#ifdef CONFIG_PROC_FS 269#ifdef CONFIG_PROC_FS
269 struct proc_dir_entry *res; 270 if (!proc_create("cpu/swp_emulation", S_IRUGO, NULL, &proc_status_fops))
270
271 res = create_proc_entry("cpu/swp_emulation", S_IRUGO, NULL);
272
273 if (!res)
274 return -ENOMEM; 271 return -ENOMEM;
275
276 res->read_proc = proc_read_status;
277#endif /* CONFIG_PROC_FS */ 272#endif /* CONFIG_PROC_FS */
278 273
279 printk(KERN_NOTICE "Registering SWP/SWPB emulation handler\n"); 274 printk(KERN_NOTICE "Registering SWP/SWPB emulation handler\n");
diff --git a/arch/arm/mach-msm/last_radio_log.c b/arch/arm/mach-msm/last_radio_log.c
index 1e243f46a969..7777767ee89a 100644
--- a/arch/arm/mach-msm/last_radio_log.c
+++ b/arch/arm/mach-msm/last_radio_log.c
@@ -31,20 +31,8 @@ extern void *smem_item(unsigned id, unsigned *size);
31static ssize_t last_radio_log_read(struct file *file, char __user *buf, 31static ssize_t last_radio_log_read(struct file *file, char __user *buf,
32 size_t len, loff_t *offset) 32 size_t len, loff_t *offset)
33{ 33{
34 loff_t pos = *offset; 34 return simple_read_from_buffer(buf, len, offset,
35 ssize_t count; 35 radio_log_base, radio_log_size);
36
37 if (pos >= radio_log_size)
38 return 0;
39
40 count = min(len, (size_t)(radio_log_size - pos));
41 if (copy_to_user(buf, radio_log_base + pos, count)) {
42 pr_err("%s: copy to user failed\n", __func__);
43 return -EFAULT;
44 }
45
46 *offset += count;
47 return count;
48} 36}
49 37
50static struct file_operations last_radio_log_fops = { 38static struct file_operations last_radio_log_fops = {
@@ -67,7 +55,8 @@ void msm_init_last_radio_log(struct module *owner)
67 return; 55 return;
68 } 56 }
69 57
70 entry = create_proc_entry("last_radio_log", S_IFREG | S_IRUGO, NULL); 58 entry = proc_create("last_radio_log", S_IRUGO, NULL,
59 &last_radio_log_fops);
71 if (!entry) { 60 if (!entry) {
72 pr_err("%s: could not create proc entry for radio log\n", 61 pr_err("%s: could not create proc entry for radio log\n",
73 __func__); 62 __func__);
@@ -77,7 +66,6 @@ void msm_init_last_radio_log(struct module *owner)
77 pr_err("%s: last radio log is %d bytes long\n", __func__, 66 pr_err("%s: last radio log is %d bytes long\n", __func__,
78 radio_log_size); 67 radio_log_size);
79 last_radio_log_fops.owner = owner; 68 last_radio_log_fops.owner = owner;
80 entry->proc_fops = &last_radio_log_fops;
81 entry->size = radio_log_size; 69 entry->size = radio_log_size;
82} 70}
83EXPORT_SYMBOL(msm_init_last_radio_log); 71EXPORT_SYMBOL(msm_init_last_radio_log);
diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c
index db37f49da5ac..dd712f109738 100644
--- a/arch/arm/mach-omap1/pm.c
+++ b/arch/arm/mach-omap1/pm.c
@@ -37,7 +37,8 @@
37 37
38#include <linux/suspend.h> 38#include <linux/suspend.h>
39#include <linux/sched.h> 39#include <linux/sched.h>
40#include <linux/proc_fs.h> 40#include <linux/debugfs.h>
41#include <linux/seq_file.h>
41#include <linux/interrupt.h> 42#include <linux/interrupt.h>
42#include <linux/sysfs.h> 43#include <linux/sysfs.h>
43#include <linux/module.h> 44#include <linux/module.h>
@@ -423,23 +424,12 @@ void omap1_pm_suspend(void)
423 omap_rev()); 424 omap_rev());
424} 425}
425 426
426#if defined(DEBUG) && defined(CONFIG_PROC_FS) 427#ifdef CONFIG_DEBUG_FS
427static int g_read_completed;
428
429/* 428/*
430 * Read system PM registers for debugging 429 * Read system PM registers for debugging
431 */ 430 */
432static int omap_pm_read_proc( 431static int omap_pm_debug_show(struct seq_file *m, void *v)
433 char *page_buffer,
434 char **my_first_byte,
435 off_t virtual_start,
436 int length,
437 int *eof,
438 void *data)
439{ 432{
440 int my_buffer_offset = 0;
441 char * const my_base = page_buffer;
442
443 ARM_SAVE(ARM_CKCTL); 433 ARM_SAVE(ARM_CKCTL);
444 ARM_SAVE(ARM_IDLECT1); 434 ARM_SAVE(ARM_IDLECT1);
445 ARM_SAVE(ARM_IDLECT2); 435 ARM_SAVE(ARM_IDLECT2);
@@ -480,10 +470,7 @@ static int omap_pm_read_proc(
480 MPUI1610_SAVE(EMIFS_CONFIG); 470 MPUI1610_SAVE(EMIFS_CONFIG);
481 } 471 }
482 472
483 if (virtual_start == 0) { 473 seq_printf(m,
484 g_read_completed = 0;
485
486 my_buffer_offset += sprintf(my_base + my_buffer_offset,
487 "ARM_CKCTL_REG: 0x%-8x \n" 474 "ARM_CKCTL_REG: 0x%-8x \n"
488 "ARM_IDLECT1_REG: 0x%-8x \n" 475 "ARM_IDLECT1_REG: 0x%-8x \n"
489 "ARM_IDLECT2_REG: 0x%-8x \n" 476 "ARM_IDLECT2_REG: 0x%-8x \n"
@@ -513,8 +500,8 @@ static int omap_pm_read_proc(
513 ULPD_SHOW(ULPD_STATUS_REQ), 500 ULPD_SHOW(ULPD_STATUS_REQ),
514 ULPD_SHOW(ULPD_POWER_CTRL)); 501 ULPD_SHOW(ULPD_POWER_CTRL));
515 502
516 if (cpu_is_omap7xx()) { 503 if (cpu_is_omap7xx()) {
517 my_buffer_offset += sprintf(my_base + my_buffer_offset, 504 seq_printf(m,
518 "MPUI7XX_CTRL_REG 0x%-8x \n" 505 "MPUI7XX_CTRL_REG 0x%-8x \n"
519 "MPUI7XX_DSP_STATUS_REG: 0x%-8x \n" 506 "MPUI7XX_DSP_STATUS_REG: 0x%-8x \n"
520 "MPUI7XX_DSP_BOOT_CONFIG_REG: 0x%-8x \n" 507 "MPUI7XX_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
@@ -527,8 +514,8 @@ static int omap_pm_read_proc(
527 MPUI7XX_SHOW(MPUI_DSP_API_CONFIG), 514 MPUI7XX_SHOW(MPUI_DSP_API_CONFIG),
528 MPUI7XX_SHOW(EMIFF_SDRAM_CONFIG), 515 MPUI7XX_SHOW(EMIFF_SDRAM_CONFIG),
529 MPUI7XX_SHOW(EMIFS_CONFIG)); 516 MPUI7XX_SHOW(EMIFS_CONFIG));
530 } else if (cpu_is_omap15xx()) { 517 } else if (cpu_is_omap15xx()) {
531 my_buffer_offset += sprintf(my_base + my_buffer_offset, 518 seq_printf(m,
532 "MPUI1510_CTRL_REG 0x%-8x \n" 519 "MPUI1510_CTRL_REG 0x%-8x \n"
533 "MPUI1510_DSP_STATUS_REG: 0x%-8x \n" 520 "MPUI1510_DSP_STATUS_REG: 0x%-8x \n"
534 "MPUI1510_DSP_BOOT_CONFIG_REG: 0x%-8x \n" 521 "MPUI1510_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
@@ -541,8 +528,8 @@ static int omap_pm_read_proc(
541 MPUI1510_SHOW(MPUI_DSP_API_CONFIG), 528 MPUI1510_SHOW(MPUI_DSP_API_CONFIG),
542 MPUI1510_SHOW(EMIFF_SDRAM_CONFIG), 529 MPUI1510_SHOW(EMIFF_SDRAM_CONFIG),
543 MPUI1510_SHOW(EMIFS_CONFIG)); 530 MPUI1510_SHOW(EMIFS_CONFIG));
544 } else if (cpu_is_omap16xx()) { 531 } else if (cpu_is_omap16xx()) {
545 my_buffer_offset += sprintf(my_base + my_buffer_offset, 532 seq_printf(m,
546 "MPUI1610_CTRL_REG 0x%-8x \n" 533 "MPUI1610_CTRL_REG 0x%-8x \n"
547 "MPUI1610_DSP_STATUS_REG: 0x%-8x \n" 534 "MPUI1610_DSP_STATUS_REG: 0x%-8x \n"
548 "MPUI1610_DSP_BOOT_CONFIG_REG: 0x%-8x \n" 535 "MPUI1610_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
@@ -555,28 +542,37 @@ static int omap_pm_read_proc(
555 MPUI1610_SHOW(MPUI_DSP_API_CONFIG), 542 MPUI1610_SHOW(MPUI_DSP_API_CONFIG),
556 MPUI1610_SHOW(EMIFF_SDRAM_CONFIG), 543 MPUI1610_SHOW(EMIFF_SDRAM_CONFIG),
557 MPUI1610_SHOW(EMIFS_CONFIG)); 544 MPUI1610_SHOW(EMIFS_CONFIG));
558 }
559
560 g_read_completed++;
561 } else if (g_read_completed >= 1) {
562 *eof = 1;
563 return 0;
564 } 545 }
565 g_read_completed++;
566 546
567 *my_first_byte = page_buffer; 547 return 0;
568 return my_buffer_offset; 548}
549
550static int omap_pm_debug_open(struct inode *inode, struct file *file)
551{
552 return single_open(file, omap_pm_debug_show,
553 &inode->i_private);
569} 554}
570 555
571static void omap_pm_init_proc(void) 556static const struct file_operations omap_pm_debug_fops = {
557 .open = omap_pm_debug_open,
558 .read = seq_read,
559 .llseek = seq_lseek,
560 .release = seq_release,
561};
562
563static void omap_pm_init_debugfs(void)
572{ 564{
573 /* XXX Appears to leak memory */ 565 struct dentry *d;
574 create_proc_read_entry("driver/omap_pm", 566
575 S_IWUSR | S_IRUGO, NULL, 567 d = debugfs_create_dir("pm_debug", NULL);
576 omap_pm_read_proc, NULL); 568 if (!d)
569 return;
570
571 (void) debugfs_create_file("omap_pm", S_IWUSR | S_IRUGO,
572 d, NULL, &omap_pm_debug_fops);
577} 573}
578 574
579#endif /* DEBUG && CONFIG_PROC_FS */ 575#endif /* CONFIG_DEBUG_FS */
580 576
581/* 577/*
582 * omap_pm_prepare - Do preliminary suspend work. 578 * omap_pm_prepare - Do preliminary suspend work.
@@ -701,8 +697,8 @@ static int __init omap_pm_init(void)
701 697
702 suspend_set_ops(&omap_pm_ops); 698 suspend_set_ops(&omap_pm_ops);
703 699
704#if defined(DEBUG) && defined(CONFIG_PROC_FS) 700#ifdef CONFIG_DEBUG_FS
705 omap_pm_init_proc(); 701 omap_pm_init_debugfs();
706#endif 702#endif
707 703
708#ifdef CONFIG_OMAP_32K_TIMER 704#ifdef CONFIG_OMAP_32K_TIMER
diff --git a/arch/blackfin/kernel/cplbinfo.c b/arch/blackfin/kernel/cplbinfo.c
index e1d0b24c6070..404045dcc5e4 100644
--- a/arch/blackfin/kernel/cplbinfo.c
+++ b/arch/blackfin/kernel/cplbinfo.c
@@ -116,14 +116,12 @@ static const struct seq_operations cplbinfo_sops = {
116 116
117static int cplbinfo_open(struct inode *inode, struct file *file) 117static int cplbinfo_open(struct inode *inode, struct file *file)
118{ 118{
119 struct proc_dir_entry *pde = PDE(file_inode(file));
120 char cplb_type; 119 char cplb_type;
121 unsigned int cpu; 120 unsigned int cpu = (unsigned long)PDE_DATA(file_inode(file));
122 int ret; 121 int ret;
123 struct seq_file *m; 122 struct seq_file *m;
124 struct cplbinfo_data *cdata; 123 struct cplbinfo_data *cdata;
125 124
126 cpu = (unsigned int)pde->data;
127 cplb_type = cpu & CPLBINFO_DCPLB_FLAG ? 'D' : 'I'; 125 cplb_type = cpu & CPLBINFO_DCPLB_FLAG ? 'D' : 'I';
128 cpu &= ~CPLBINFO_DCPLB_FLAG; 126 cpu &= ~CPLBINFO_DCPLB_FLAG;
129 127
diff --git a/arch/cris/arch-v10/kernel/fasttimer.c b/arch/cris/arch-v10/kernel/fasttimer.c
index 082f1890bacb..ce6f512968a4 100644
--- a/arch/cris/arch-v10/kernel/fasttimer.c
+++ b/arch/cris/arch-v10/kernel/fasttimer.c
@@ -25,6 +25,7 @@
25#include <arch/svinto.h> 25#include <arch/svinto.h>
26#include <asm/fasttimer.h> 26#include <asm/fasttimer.h>
27#include <linux/proc_fs.h> 27#include <linux/proc_fs.h>
28#include <linux/seq_file.h>
28 29
29 30
30#define DEBUG_LOG_INCLUDED 31#define DEBUG_LOG_INCLUDED
@@ -489,197 +490,162 @@ void schedule_usleep(unsigned long us)
489} 490}
490 491
491#ifdef CONFIG_PROC_FS 492#ifdef CONFIG_PROC_FS
492static int proc_fasttimer_read(char *buf, char **start, off_t offset, int len
493 ,int *eof, void *data_unused);
494static struct proc_dir_entry *fasttimer_proc_entry;
495#endif /* CONFIG_PROC_FS */
496
497#ifdef CONFIG_PROC_FS
498
499/* This value is very much based on testing */ 493/* This value is very much based on testing */
500#define BIG_BUF_SIZE (500 + NUM_TIMER_STATS * 300) 494#define BIG_BUF_SIZE (500 + NUM_TIMER_STATS * 300)
501 495
502static int proc_fasttimer_read(char *buf, char **start, off_t offset, int len 496static int proc_fasttimer_show(struct seq_file *m, void *v)
503 ,int *eof, void *data_unused)
504{ 497{
505 unsigned long flags; 498 unsigned long flags;
506 int i = 0; 499 int i = 0;
507 int num_to_show; 500 int num_to_show;
508 struct fasttime_t tv; 501 struct fasttime_t tv;
509 struct fast_timer *t, *nextt; 502 struct fast_timer *t, *nextt;
510 static char *bigbuf = NULL; 503
511 static unsigned long used; 504 do_gettimeofday_fast(&tv);
512 505
513 if (!bigbuf && !(bigbuf = vmalloc(BIG_BUF_SIZE))) 506 seq_printf(m, "Fast timers added: %i\n", fast_timers_added);
514 { 507 seq_printf(m, "Fast timers started: %i\n", fast_timers_started);
515 used = 0; 508 seq_printf(m, "Fast timer interrupts: %i\n", fast_timer_ints);
516 if (buf) 509 seq_printf(m, "Fast timers expired: %i\n", fast_timers_expired);
517 buf[0] = '\0'; 510 seq_printf(m, "Fast timers deleted: %i\n", fast_timers_deleted);
518 return 0; 511 seq_printf(m, "Fast timer running: %s\n",
519 } 512 fast_timer_running ? "yes" : "no");
520 513 seq_printf(m, "Current time: %lu.%06lu\n",
521 if (!offset || !used) 514 (unsigned long)tv.tv_jiff,
522 { 515 (unsigned long)tv.tv_usec);
523 do_gettimeofday_fast(&tv);
524
525 used = 0;
526 used += sprintf(bigbuf + used, "Fast timers added: %i\n",
527 fast_timers_added);
528 used += sprintf(bigbuf + used, "Fast timers started: %i\n",
529 fast_timers_started);
530 used += sprintf(bigbuf + used, "Fast timer interrupts: %i\n",
531 fast_timer_ints);
532 used += sprintf(bigbuf + used, "Fast timers expired: %i\n",
533 fast_timers_expired);
534 used += sprintf(bigbuf + used, "Fast timers deleted: %i\n",
535 fast_timers_deleted);
536 used += sprintf(bigbuf + used, "Fast timer running: %s\n",
537 fast_timer_running ? "yes" : "no");
538 used += sprintf(bigbuf + used, "Current time: %lu.%06lu\n",
539 (unsigned long)tv.tv_jiff,
540 (unsigned long)tv.tv_usec);
541#ifdef FAST_TIMER_SANITY_CHECKS 516#ifdef FAST_TIMER_SANITY_CHECKS
542 used += sprintf(bigbuf + used, "Sanity failed: %i\n", 517 seq_printf(m, "Sanity failed: %i\n", sanity_failed);
543 sanity_failed);
544#endif 518#endif
545 used += sprintf(bigbuf + used, "\n"); 519 seq_putc(m, '\n');
546 520
547#ifdef DEBUG_LOG_INCLUDED 521#ifdef DEBUG_LOG_INCLUDED
548 { 522 {
549 int end_i = debug_log_cnt; 523 int end_i = debug_log_cnt;
550 i = 0; 524 i = 0;
551 525
552 if (debug_log_cnt_wrapped) 526 if (debug_log_cnt_wrapped)
553 { 527 i = debug_log_cnt;
554 i = debug_log_cnt; 528
555 } 529 while (i != end_i || debug_log_cnt_wrapped) {
556 530 if (seq_printf(m, debug_log_string[i], debug_log_value[i]) < 0)
557 while ((i != end_i || (debug_log_cnt_wrapped && !used)) && 531 return 0;
558 used+100 < BIG_BUF_SIZE) 532 i = (i+1) % DEBUG_LOG_MAX;
559 { 533 }
560 used += sprintf(bigbuf + used, debug_log_string[i], 534 }
561 debug_log_value[i]); 535 seq_putc(m, '\n');
562 i = (i+1) % DEBUG_LOG_MAX;
563 }
564 }
565 used += sprintf(bigbuf + used, "\n");
566#endif 536#endif
567 537
568 num_to_show = (fast_timers_started < NUM_TIMER_STATS ? fast_timers_started: 538 num_to_show = (fast_timers_started < NUM_TIMER_STATS ? fast_timers_started:
569 NUM_TIMER_STATS); 539 NUM_TIMER_STATS);
570 used += sprintf(bigbuf + used, "Timers started: %i\n", fast_timers_started); 540 seq_printf(m, "Timers started: %i\n", fast_timers_started);
571 for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE) ; i++) 541 for (i = 0; i < num_to_show; i++) {
572 { 542 int cur = (fast_timers_started - i - 1) % NUM_TIMER_STATS;
573 int cur = (fast_timers_started - i - 1) % NUM_TIMER_STATS;
574 543
575#if 1 //ndef FAST_TIMER_LOG 544#if 1 //ndef FAST_TIMER_LOG
576 used += sprintf(bigbuf + used, "div: %i freq: %i delay: %i" 545 seq_printf(m, "div: %i freq: %i delay: %i"
577 "\n", 546 "\n",
578 timer_div_settings[cur], 547 timer_div_settings[cur],
579 timer_freq_settings[cur], 548 timer_freq_settings[cur],
580 timer_delay_settings[cur] 549 timer_delay_settings[cur]);
581 );
582#endif 550#endif
583#ifdef FAST_TIMER_LOG 551#ifdef FAST_TIMER_LOG
584 t = &timer_started_log[cur]; 552 t = &timer_started_log[cur];
585 used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " 553 if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
586 "d: %6li us data: 0x%08lX" 554 "d: %6li us data: 0x%08lX"
587 "\n", 555 "\n",
588 t->name, 556 t->name,
589 (unsigned long)t->tv_set.tv_jiff, 557 (unsigned long)t->tv_set.tv_jiff,
590 (unsigned long)t->tv_set.tv_usec, 558 (unsigned long)t->tv_set.tv_usec,
591 (unsigned long)t->tv_expires.tv_jiff, 559 (unsigned long)t->tv_expires.tv_jiff,
592 (unsigned long)t->tv_expires.tv_usec, 560 (unsigned long)t->tv_expires.tv_usec,
593 t->delay_us, 561 t->delay_us,
594 t->data 562 t->data) < 0)
595 ); 563 return 0;
596#endif 564#endif
597 } 565 }
598 used += sprintf(bigbuf + used, "\n"); 566 seq_putc(m, '\n');
599 567
600#ifdef FAST_TIMER_LOG 568#ifdef FAST_TIMER_LOG
601 num_to_show = (fast_timers_added < NUM_TIMER_STATS ? fast_timers_added: 569 num_to_show = (fast_timers_added < NUM_TIMER_STATS ? fast_timers_added:
602 NUM_TIMER_STATS); 570 NUM_TIMER_STATS);
603 used += sprintf(bigbuf + used, "Timers added: %i\n", fast_timers_added); 571 seq_printf(m, "Timers added: %i\n", fast_timers_added);
604 for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE); i++) 572 for (i = 0; i < num_to_show; i++) {
605 { 573 t = &timer_added_log[(fast_timers_added - i - 1) % NUM_TIMER_STATS];
606 t = &timer_added_log[(fast_timers_added - i - 1) % NUM_TIMER_STATS]; 574 if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
607 used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " 575 "d: %6li us data: 0x%08lX"
608 "d: %6li us data: 0x%08lX" 576 "\n",
609 "\n", 577 t->name,
610 t->name, 578 (unsigned long)t->tv_set.tv_jiff,
611 (unsigned long)t->tv_set.tv_jiff, 579 (unsigned long)t->tv_set.tv_usec,
612 (unsigned long)t->tv_set.tv_usec, 580 (unsigned long)t->tv_expires.tv_jiff,
613 (unsigned long)t->tv_expires.tv_jiff, 581 (unsigned long)t->tv_expires.tv_usec,
614 (unsigned long)t->tv_expires.tv_usec, 582 t->delay_us,
615 t->delay_us, 583 t->data) < 0)
616 t->data 584 return 0;
617 ); 585 }
618 } 586 seq_putc(m, '\n');
619 used += sprintf(bigbuf + used, "\n"); 587
620 588 num_to_show = (fast_timers_expired < NUM_TIMER_STATS ? fast_timers_expired:
621 num_to_show = (fast_timers_expired < NUM_TIMER_STATS ? fast_timers_expired: 589 NUM_TIMER_STATS);
622 NUM_TIMER_STATS); 590 seq_printf(m, "Timers expired: %i\n", fast_timers_expired);
623 used += sprintf(bigbuf + used, "Timers expired: %i\n", fast_timers_expired); 591 for (i = 0; i < num_to_show; i++) {
624 for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE); i++) 592 t = &timer_expired_log[(fast_timers_expired - i - 1) % NUM_TIMER_STATS];
625 { 593 if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
626 t = &timer_expired_log[(fast_timers_expired - i - 1) % NUM_TIMER_STATS]; 594 "d: %6li us data: 0x%08lX"
627 used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " 595 "\n",
628 "d: %6li us data: 0x%08lX" 596 t->name,
629 "\n", 597 (unsigned long)t->tv_set.tv_jiff,
630 t->name, 598 (unsigned long)t->tv_set.tv_usec,
631 (unsigned long)t->tv_set.tv_jiff, 599 (unsigned long)t->tv_expires.tv_jiff,
632 (unsigned long)t->tv_set.tv_usec, 600 (unsigned long)t->tv_expires.tv_usec,
633 (unsigned long)t->tv_expires.tv_jiff, 601 t->delay_us,
634 (unsigned long)t->tv_expires.tv_usec, 602 t->data) < 0)
635 t->delay_us, 603 return 0;
636 t->data 604 }
637 ); 605 seq_putc(m, '\n');
638 }
639 used += sprintf(bigbuf + used, "\n");
640#endif 606#endif
641 607
642 used += sprintf(bigbuf + used, "Active timers:\n"); 608 seq_puts(m, "Active timers:\n");
643 local_irq_save(flags); 609 local_irq_save(flags);
644 t = fast_timer_list; 610 t = fast_timer_list;
645 while (t != NULL && (used+100 < BIG_BUF_SIZE)) 611 while (t) {
646 { 612 nextt = t->next;
647 nextt = t->next; 613 local_irq_restore(flags);
648 local_irq_restore(flags); 614 if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
649 used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " 615 "d: %6li us data: 0x%08lX"
650 "d: %6li us data: 0x%08lX"
651/* " func: 0x%08lX" */ 616/* " func: 0x%08lX" */
652 "\n", 617 "\n",
653 t->name, 618 t->name,
654 (unsigned long)t->tv_set.tv_jiff, 619 (unsigned long)t->tv_set.tv_jiff,
655 (unsigned long)t->tv_set.tv_usec, 620 (unsigned long)t->tv_set.tv_usec,
656 (unsigned long)t->tv_expires.tv_jiff, 621 (unsigned long)t->tv_expires.tv_jiff,
657 (unsigned long)t->tv_expires.tv_usec, 622 (unsigned long)t->tv_expires.tv_usec,
658 t->delay_us, 623 t->delay_us,
659 t->data 624 t->data
660/* , t->function */ 625/* , t->function */
661 ); 626 ) < 0)
662 local_irq_save(flags); 627 return 0;
663 if (t->next != nextt) 628 local_irq_save(flags);
664 { 629 if (t->next != nextt)
665 printk(KERN_WARNING "timer removed!\n"); 630 printk(KERN_WARNING "timer removed!\n");
666 } 631 t = nextt;
667 t = nextt; 632 }
668 } 633 local_irq_restore(flags);
669 local_irq_restore(flags);
670 }
671
672 if (used - offset < len)
673 {
674 len = used - offset;
675 }
676 634
677 memcpy(buf, bigbuf + offset, len); 635 return 0;
678 *start = buf; 636}
679 *eof = 1;
680 637
681 return len; 638static int proc_fasttimer_open(struct inode *inode, struct file *file)
639{
640 return single_open_size(file, proc_fasttimer_show, PDE_DATA(inode), BIG_BUF_SIZE);
682} 641}
642
643static const struct file_operations proc_fasttimer_fops = {
644 .open = proc_fasttimer_open,
645 .read = seq_read,
646 .llseek = seq_lseek,
647 .release = seq_release,
648};
683#endif /* PROC_FS */ 649#endif /* PROC_FS */
684 650
685#ifdef FAST_TIMER_TEST 651#ifdef FAST_TIMER_TEST
@@ -857,8 +823,7 @@ int fast_timer_init(void)
857 } 823 }
858#endif 824#endif
859#ifdef CONFIG_PROC_FS 825#ifdef CONFIG_PROC_FS
860 if ((fasttimer_proc_entry = create_proc_entry( "fasttimer", 0, 0 ))) 826 proc_create("fasttimer", 0, NULL, &proc_fasttimer_fops);
861 fasttimer_proc_entry->read_proc = proc_fasttimer_read;
862#endif /* PROC_FS */ 827#endif /* PROC_FS */
863 if(request_irq(TIMER1_IRQ_NBR, timer1_handler, 0, 828 if(request_irq(TIMER1_IRQ_NBR, timer1_handler, 0,
864 "fast timer int", NULL)) 829 "fast timer int", NULL))
diff --git a/arch/cris/arch-v32/kernel/fasttimer.c b/arch/cris/arch-v32/kernel/fasttimer.c
index ab1551ee43c5..e43dd70acd96 100644
--- a/arch/cris/arch-v32/kernel/fasttimer.c
+++ b/arch/cris/arch-v32/kernel/fasttimer.c
@@ -23,6 +23,7 @@
23#include <hwregs/timer_defs.h> 23#include <hwregs/timer_defs.h>
24#include <asm/fasttimer.h> 24#include <asm/fasttimer.h>
25#include <linux/proc_fs.h> 25#include <linux/proc_fs.h>
26#include <linux/seq_file.h>
26 27
27/* 28/*
28 * timer0 is running at 100MHz and generating jiffies timer ticks 29 * timer0 is running at 100MHz and generating jiffies timer ticks
@@ -463,195 +464,161 @@ void schedule_usleep(unsigned long us)
463} 464}
464 465
465#ifdef CONFIG_PROC_FS 466#ifdef CONFIG_PROC_FS
466static int proc_fasttimer_read(char *buf, char **start, off_t offset, int len
467 ,int *eof, void *data_unused);
468static struct proc_dir_entry *fasttimer_proc_entry;
469#endif /* CONFIG_PROC_FS */
470
471#ifdef CONFIG_PROC_FS
472
473/* This value is very much based on testing */ 467/* This value is very much based on testing */
474#define BIG_BUF_SIZE (500 + NUM_TIMER_STATS * 300) 468#define BIG_BUF_SIZE (500 + NUM_TIMER_STATS * 300)
475 469
476static int proc_fasttimer_read(char *buf, char **start, off_t offset, int len 470static int proc_fasttimer_show(struct seq_file *m, void *v)
477 ,int *eof, void *data_unused)
478{ 471{
479 unsigned long flags; 472 unsigned long flags;
480 int i = 0; 473 int i = 0;
481 int num_to_show; 474 int num_to_show;
482 struct fasttime_t tv; 475 struct fasttime_t tv;
483 struct fast_timer *t, *nextt; 476 struct fast_timer *t, *nextt;
484 static char *bigbuf = NULL; 477
485 static unsigned long used; 478 do_gettimeofday_fast(&tv);
486 479
487 if (!bigbuf) { 480 seq_printf(m, "Fast timers added: %i\n", fast_timers_added);
488 bigbuf = vmalloc(BIG_BUF_SIZE); 481 seq_printf(m, "Fast timers started: %i\n", fast_timers_started);
489 if (!bigbuf) { 482 seq_printf(m, "Fast timer interrupts: %i\n", fast_timer_ints);
490 used = 0; 483 seq_printf(m, "Fast timers expired: %i\n", fast_timers_expired);
491 if (buf) 484 seq_printf(m, "Fast timers deleted: %i\n", fast_timers_deleted);
492 buf[0] = '\0'; 485 seq_printf(m, "Fast timer running: %s\n",
493 return 0; 486 fast_timer_running ? "yes" : "no");
494 } 487 seq_printf(m, "Current time: %lu.%06lu\n",
495 } 488 (unsigned long)tv.tv_jiff,
496 489 (unsigned long)tv.tv_usec);
497 if (!offset || !used) {
498 do_gettimeofday_fast(&tv);
499
500 used = 0;
501 used += sprintf(bigbuf + used, "Fast timers added: %i\n",
502 fast_timers_added);
503 used += sprintf(bigbuf + used, "Fast timers started: %i\n",
504 fast_timers_started);
505 used += sprintf(bigbuf + used, "Fast timer interrupts: %i\n",
506 fast_timer_ints);
507 used += sprintf(bigbuf + used, "Fast timers expired: %i\n",
508 fast_timers_expired);
509 used += sprintf(bigbuf + used, "Fast timers deleted: %i\n",
510 fast_timers_deleted);
511 used += sprintf(bigbuf + used, "Fast timer running: %s\n",
512 fast_timer_running ? "yes" : "no");
513 used += sprintf(bigbuf + used, "Current time: %lu.%06lu\n",
514 (unsigned long)tv.tv_jiff,
515 (unsigned long)tv.tv_usec);
516#ifdef FAST_TIMER_SANITY_CHECKS 490#ifdef FAST_TIMER_SANITY_CHECKS
517 used += sprintf(bigbuf + used, "Sanity failed: %i\n", 491 seq_printf(m, "Sanity failed: %i\n", sanity_failed);
518 sanity_failed);
519#endif 492#endif
520 used += sprintf(bigbuf + used, "\n"); 493 seq_putc(m, '\n');
521 494
522#ifdef DEBUG_LOG_INCLUDED 495#ifdef DEBUG_LOG_INCLUDED
523 { 496 {
524 int end_i = debug_log_cnt; 497 int end_i = debug_log_cnt;
525 i = 0; 498 i = 0;
526 499
527 if (debug_log_cnt_wrapped) 500 if (debug_log_cnt_wrapped)
528 i = debug_log_cnt; 501 i = debug_log_cnt;
529 502
530 while ((i != end_i || (debug_log_cnt_wrapped && !used)) && 503 while ((i != end_i || debug_log_cnt_wrapped)) {
531 used+100 < BIG_BUF_SIZE) 504 if (seq_printf(m, debug_log_string[i], debug_log_value[i]) < 0)
532 { 505 return 0;
533 used += sprintf(bigbuf + used, debug_log_string[i], 506 i = (i+1) % DEBUG_LOG_MAX;
534 debug_log_value[i]); 507 }
535 i = (i+1) % DEBUG_LOG_MAX; 508 }
536 } 509 seq_putc(m, '\n');
537 }
538 used += sprintf(bigbuf + used, "\n");
539#endif 510#endif
540 511
541 num_to_show = (fast_timers_started < NUM_TIMER_STATS ? fast_timers_started: 512 num_to_show = (fast_timers_started < NUM_TIMER_STATS ? fast_timers_started:
542 NUM_TIMER_STATS); 513 NUM_TIMER_STATS);
543 used += sprintf(bigbuf + used, "Timers started: %i\n", fast_timers_started); 514 seq_printf(m, "Timers started: %i\n", fast_timers_started);
544 for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE) ; i++) 515 for (i = 0; i < num_to_show; i++) {
545 { 516 int cur = (fast_timers_started - i - 1) % NUM_TIMER_STATS;
546 int cur = (fast_timers_started - i - 1) % NUM_TIMER_STATS;
547 517
548#if 1 //ndef FAST_TIMER_LOG 518#if 1 //ndef FAST_TIMER_LOG
549 used += sprintf(bigbuf + used, "div: %i delay: %i" 519 seq_printf(m, "div: %i delay: %i"
550 "\n", 520 "\n",
551 timer_div_settings[cur], 521 timer_div_settings[cur],
552 timer_delay_settings[cur] 522 timer_delay_settings[cur]);
553 );
554#endif 523#endif
555#ifdef FAST_TIMER_LOG 524#ifdef FAST_TIMER_LOG
556 t = &timer_started_log[cur]; 525 t = &timer_started_log[cur];
557 used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " 526 if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
558 "d: %6li us data: 0x%08lX" 527 "d: %6li us data: 0x%08lX"
559 "\n", 528 "\n",
560 t->name, 529 t->name,
561 (unsigned long)t->tv_set.tv_jiff, 530 (unsigned long)t->tv_set.tv_jiff,
562 (unsigned long)t->tv_set.tv_usec, 531 (unsigned long)t->tv_set.tv_usec,
563 (unsigned long)t->tv_expires.tv_jiff, 532 (unsigned long)t->tv_expires.tv_jiff,
564 (unsigned long)t->tv_expires.tv_usec, 533 (unsigned long)t->tv_expires.tv_usec,
565 t->delay_us, 534 t->delay_us,
566 t->data 535 t->data) < 0)
567 ); 536 return 0;
568#endif 537#endif
569 } 538 }
570 used += sprintf(bigbuf + used, "\n"); 539 seq_putc(m, '\n');
571 540
572#ifdef FAST_TIMER_LOG 541#ifdef FAST_TIMER_LOG
573 num_to_show = (fast_timers_added < NUM_TIMER_STATS ? fast_timers_added: 542 num_to_show = (fast_timers_added < NUM_TIMER_STATS ? fast_timers_added:
574 NUM_TIMER_STATS); 543 NUM_TIMER_STATS);
575 used += sprintf(bigbuf + used, "Timers added: %i\n", fast_timers_added); 544 seq_printf(m, "Timers added: %i\n", fast_timers_added);
576 for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE); i++) 545 for (i = 0; i < num_to_show; i++) {
577 { 546 t = &timer_added_log[(fast_timers_added - i - 1) % NUM_TIMER_STATS];
578 t = &timer_added_log[(fast_timers_added - i - 1) % NUM_TIMER_STATS]; 547 if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
579 used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " 548 "d: %6li us data: 0x%08lX"
580 "d: %6li us data: 0x%08lX" 549 "\n",
581 "\n", 550 t->name,
582 t->name, 551 (unsigned long)t->tv_set.tv_jiff,
583 (unsigned long)t->tv_set.tv_jiff, 552 (unsigned long)t->tv_set.tv_usec,
584 (unsigned long)t->tv_set.tv_usec, 553 (unsigned long)t->tv_expires.tv_jiff,
585 (unsigned long)t->tv_expires.tv_jiff, 554 (unsigned long)t->tv_expires.tv_usec,
586 (unsigned long)t->tv_expires.tv_usec, 555 t->delay_us,
587 t->delay_us, 556 t->data) < 0)
588 t->data 557 return 0;
589 ); 558 }
590 } 559 seq_putc(m, '\n');
591 used += sprintf(bigbuf + used, "\n"); 560
592 561 num_to_show = (fast_timers_expired < NUM_TIMER_STATS ? fast_timers_expired:
593 num_to_show = (fast_timers_expired < NUM_TIMER_STATS ? fast_timers_expired: 562 NUM_TIMER_STATS);
594 NUM_TIMER_STATS); 563 seq_printf(m, "Timers expired: %i\n", fast_timers_expired);
595 used += sprintf(bigbuf + used, "Timers expired: %i\n", fast_timers_expired); 564 for (i = 0; i < num_to_show; i++){
596 for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE); i++) 565 t = &timer_expired_log[(fast_timers_expired - i - 1) % NUM_TIMER_STATS];
597 { 566 if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
598 t = &timer_expired_log[(fast_timers_expired - i - 1) % NUM_TIMER_STATS]; 567 "d: %6li us data: 0x%08lX"
599 used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " 568 "\n",
600 "d: %6li us data: 0x%08lX" 569 t->name,
601 "\n", 570 (unsigned long)t->tv_set.tv_jiff,
602 t->name, 571 (unsigned long)t->tv_set.tv_usec,
603 (unsigned long)t->tv_set.tv_jiff, 572 (unsigned long)t->tv_expires.tv_jiff,
604 (unsigned long)t->tv_set.tv_usec, 573 (unsigned long)t->tv_expires.tv_usec,
605 (unsigned long)t->tv_expires.tv_jiff, 574 t->delay_us,
606 (unsigned long)t->tv_expires.tv_usec, 575 t->data) < 0)
607 t->delay_us, 576 return 0;
608 t->data 577 }
609 ); 578 seq_putc(m, '\n');
610 }
611 used += sprintf(bigbuf + used, "\n");
612#endif 579#endif
613 580
614 used += sprintf(bigbuf + used, "Active timers:\n"); 581 seq_puts(m, "Active timers:\n");
615 local_irq_save(flags); 582 local_irq_save(flags);
616 t = fast_timer_list; 583 t = fast_timer_list;
617 while (t != NULL && (used+100 < BIG_BUF_SIZE)) 584 while (t != NULL){
618 { 585 nextt = t->next;
619 nextt = t->next; 586 local_irq_restore(flags);
620 local_irq_restore(flags); 587 if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
621 used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " 588 "d: %6li us data: 0x%08lX"
622 "d: %6li us data: 0x%08lX"
623/* " func: 0x%08lX" */ 589/* " func: 0x%08lX" */
624 "\n", 590 "\n",
625 t->name, 591 t->name,
626 (unsigned long)t->tv_set.tv_jiff, 592 (unsigned long)t->tv_set.tv_jiff,
627 (unsigned long)t->tv_set.tv_usec, 593 (unsigned long)t->tv_set.tv_usec,
628 (unsigned long)t->tv_expires.tv_jiff, 594 (unsigned long)t->tv_expires.tv_jiff,
629 (unsigned long)t->tv_expires.tv_usec, 595 (unsigned long)t->tv_expires.tv_usec,
630 t->delay_us, 596 t->delay_us,
631 t->data 597 t->data
632/* , t->function */ 598/* , t->function */
633 ); 599 ) < 0)
634 local_irq_save(flags); 600 return 0;
635 if (t->next != nextt) 601 local_irq_save(flags);
636 { 602 if (t->next != nextt)
637 printk("timer removed!\n"); 603 printk("timer removed!\n");
638 } 604 t = nextt;
639 t = nextt; 605 }
640 } 606 local_irq_restore(flags);
641 local_irq_restore(flags); 607 return 0;
642 } 608}
643 609
644 if (used - offset < len) 610static int proc_fasttimer_open(struct inode *inode, struct file *file)
645 { 611{
646 len = used - offset; 612 return single_open_size(file, proc_fasttimer_show, PDE_DATA(inode), BIG_BUF_SIZE);
647 } 613}
648 614
649 memcpy(buf, bigbuf + offset, len); 615static const struct file_operations proc_fasttimer_fops = {
650 *start = buf; 616 .open = proc_fasttimer_open,
651 *eof = 1; 617 .read = seq_read,
618 .llseek = seq_lseek,
619 .release = seq_release,
620};
652 621
653 return len;
654}
655#endif /* PROC_FS */ 622#endif /* PROC_FS */
656 623
657#ifdef FAST_TIMER_TEST 624#ifdef FAST_TIMER_TEST
@@ -816,9 +783,7 @@ int fast_timer_init(void)
816 printk("fast_timer_init()\n"); 783 printk("fast_timer_init()\n");
817 784
818#ifdef CONFIG_PROC_FS 785#ifdef CONFIG_PROC_FS
819 fasttimer_proc_entry = create_proc_entry("fasttimer", 0, 0); 786 proc_create("fasttimer", 0, NULL, &proc_fasttimer_fops);
820 if (fasttimer_proc_entry)
821 fasttimer_proc_entry->read_proc = proc_fasttimer_read;
822#endif /* PROC_FS */ 787#endif /* PROC_FS */
823 if (request_irq(TIMER0_INTR_VECT, timer_trig_interrupt, 788 if (request_irq(TIMER0_INTR_VECT, timer_trig_interrupt,
824 IRQF_SHARED | IRQF_DISABLED, 789 IRQF_SHARED | IRQF_DISABLED,
diff --git a/arch/h8300/kernel/gpio.c b/arch/h8300/kernel/gpio.c
index 6a25dd5530e7..b02c752cd326 100644
--- a/arch/h8300/kernel/gpio.c
+++ b/arch/h8300/kernel/gpio.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/stddef.h> 12#include <linux/stddef.h>
13#include <linux/proc_fs.h> 13#include <linux/proc_fs.h>
14#include <linux/seq_file.h>
14#include <linux/kernel.h> 15#include <linux/kernel.h>
15#include <linux/string.h> 16#include <linux/string.h>
16#include <linux/fs.h> 17#include <linux/fs.h>
@@ -138,30 +139,34 @@ static char *port_status(int portno)
138 return result; 139 return result;
139} 140}
140 141
141static int gpio_proc_read(char *buf, char **start, off_t offset, 142static int gpio_proc_show(struct seq_file *m, void *v)
142 int len, int *unused_i, void *unused_v)
143{ 143{
144 int c,outlen;
145 static const char port_name[]="123456789ABCDEFGH"; 144 static const char port_name[]="123456789ABCDEFGH";
146 outlen = 0; 145 int c;
146
147 for (c = 0; c < MAX_PORT; c++) { 147 for (c = 0; c < MAX_PORT; c++) {
148 if (ddrs[c] == NULL) 148 if (ddrs[c] == NULL)
149 continue ; 149 continue;
150 len = sprintf(buf,"P%c: %s\n",port_name[c],port_status(c)); 150 seq_printf(m, "P%c: %s\n", port_name[c], port_status(c));
151 buf += len;
152 outlen += len;
153 } 151 }
154 return outlen; 152 return 0;
155} 153}
156 154
157static __init int register_proc(void) 155static int gpio_proc_open(struct inode *inode, struct file *file)
158{ 156{
159 struct proc_dir_entry *proc_gpio; 157 return single_open(file, gpio_proc_show, PDE_DATA(inode));
158}
160 159
161 proc_gpio = create_proc_entry("gpio", S_IRUGO, NULL); 160static const struct file_operations gpio_proc_fops = {
162 if (proc_gpio) 161 .open = gpio_proc_open,
163 proc_gpio->read_proc = gpio_proc_read; 162 .read = seq_read,
164 return proc_gpio != NULL; 163 .llseek = seq_lseek,
164 .release = seq_release,
165};
166
167static __init int register_proc(void)
168{
169 return proc_create("gpio", S_IRUGO, NULL, &gpio_proc_fops) != NULL;
165} 170}
166 171
167__initcall(register_proc); 172__initcall(register_proc);
diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
index 79521d5499f9..b17129e3b7c8 100644
--- a/arch/ia64/kernel/palinfo.c
+++ b/arch/ia64/kernel/palinfo.c
@@ -22,6 +22,7 @@
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/proc_fs.h> 24#include <linux/proc_fs.h>
25#include <linux/seq_file.h>
25#include <linux/mm.h> 26#include <linux/mm.h>
26#include <linux/module.h> 27#include <linux/module.h>
27#include <linux/efi.h> 28#include <linux/efi.h>
@@ -41,7 +42,7 @@ MODULE_LICENSE("GPL");
41 42
42#define PALINFO_VERSION "0.5" 43#define PALINFO_VERSION "0.5"
43 44
44typedef int (*palinfo_func_t)(char*); 45typedef int (*palinfo_func_t)(struct seq_file *);
45 46
46typedef struct { 47typedef struct {
47 const char *name; /* name of the proc entry */ 48 const char *name; /* name of the proc entry */
@@ -54,7 +55,7 @@ typedef struct {
54 * A bunch of string array to get pretty printing 55 * A bunch of string array to get pretty printing
55 */ 56 */
56 57
57static char *cache_types[] = { 58static const char *cache_types[] = {
58 "", /* not used */ 59 "", /* not used */
59 "Instruction", 60 "Instruction",
60 "Data", 61 "Data",
@@ -122,19 +123,16 @@ static const char *mem_attrib[]={
122 * - a pointer to the end of the buffer 123 * - a pointer to the end of the buffer
123 * 124 *
124 */ 125 */
125static char * 126static void bitvector_process(struct seq_file *m, u64 vector)
126bitvector_process(char *p, u64 vector)
127{ 127{
128 int i,j; 128 int i,j;
129 const char *units[]={ "", "K", "M", "G", "T" }; 129 static const char *units[]={ "", "K", "M", "G", "T" };
130 130
131 for (i=0, j=0; i < 64; i++ , j=i/10) { 131 for (i=0, j=0; i < 64; i++ , j=i/10) {
132 if (vector & 0x1) { 132 if (vector & 0x1)
133 p += sprintf(p, "%d%s ", 1 << (i-j*10), units[j]); 133 seq_printf(m, "%d%s ", 1 << (i-j*10), units[j]);
134 }
135 vector >>= 1; 134 vector >>= 1;
136 } 135 }
137 return p;
138} 136}
139 137
140/* 138/*
@@ -149,8 +147,7 @@ bitvector_process(char *p, u64 vector)
149 * - a pointer to the end of the buffer 147 * - a pointer to the end of the buffer
150 * 148 *
151 */ 149 */
152static char * 150static void bitregister_process(struct seq_file *m, u64 *reg_info, int max)
153bitregister_process(char *p, u64 *reg_info, int max)
154{ 151{
155 int i, begin, skip = 0; 152 int i, begin, skip = 0;
156 u64 value = reg_info[0]; 153 u64 value = reg_info[0];
@@ -163,9 +160,9 @@ bitregister_process(char *p, u64 *reg_info, int max)
163 160
164 if ((value & 0x1) == 0 && skip == 0) { 161 if ((value & 0x1) == 0 && skip == 0) {
165 if (begin <= i - 2) 162 if (begin <= i - 2)
166 p += sprintf(p, "%d-%d ", begin, i-1); 163 seq_printf(m, "%d-%d ", begin, i-1);
167 else 164 else
168 p += sprintf(p, "%d ", i-1); 165 seq_printf(m, "%d ", i-1);
169 skip = 1; 166 skip = 1;
170 begin = -1; 167 begin = -1;
171 } else if ((value & 0x1) && skip == 1) { 168 } else if ((value & 0x1) && skip == 1) {
@@ -176,19 +173,15 @@ bitregister_process(char *p, u64 *reg_info, int max)
176 } 173 }
177 if (begin > -1) { 174 if (begin > -1) {
178 if (begin < 127) 175 if (begin < 127)
179 p += sprintf(p, "%d-127", begin); 176 seq_printf(m, "%d-127", begin);
180 else 177 else
181 p += sprintf(p, "127"); 178 seq_puts(m, "127");
182 } 179 }
183
184 return p;
185} 180}
186 181
187static int 182static int power_info(struct seq_file *m)
188power_info(char *page)
189{ 183{
190 s64 status; 184 s64 status;
191 char *p = page;
192 u64 halt_info_buffer[8]; 185 u64 halt_info_buffer[8];
193 pal_power_mgmt_info_u_t *halt_info =(pal_power_mgmt_info_u_t *)halt_info_buffer; 186 pal_power_mgmt_info_u_t *halt_info =(pal_power_mgmt_info_u_t *)halt_info_buffer;
194 int i; 187 int i;
@@ -198,26 +191,25 @@ power_info(char *page)
198 191
199 for (i=0; i < 8 ; i++ ) { 192 for (i=0; i < 8 ; i++ ) {
200 if (halt_info[i].pal_power_mgmt_info_s.im == 1) { 193 if (halt_info[i].pal_power_mgmt_info_s.im == 1) {
201 p += sprintf(p, "Power level %d:\n" 194 seq_printf(m,
202 "\tentry_latency : %d cycles\n" 195 "Power level %d:\n"
203 "\texit_latency : %d cycles\n" 196 "\tentry_latency : %d cycles\n"
204 "\tpower consumption : %d mW\n" 197 "\texit_latency : %d cycles\n"
205 "\tCache+TLB coherency : %s\n", i, 198 "\tpower consumption : %d mW\n"
206 halt_info[i].pal_power_mgmt_info_s.entry_latency, 199 "\tCache+TLB coherency : %s\n", i,
207 halt_info[i].pal_power_mgmt_info_s.exit_latency, 200 halt_info[i].pal_power_mgmt_info_s.entry_latency,
208 halt_info[i].pal_power_mgmt_info_s.power_consumption, 201 halt_info[i].pal_power_mgmt_info_s.exit_latency,
209 halt_info[i].pal_power_mgmt_info_s.co ? "Yes" : "No"); 202 halt_info[i].pal_power_mgmt_info_s.power_consumption,
203 halt_info[i].pal_power_mgmt_info_s.co ? "Yes" : "No");
210 } else { 204 } else {
211 p += sprintf(p,"Power level %d: not implemented\n",i); 205 seq_printf(m,"Power level %d: not implemented\n", i);
212 } 206 }
213 } 207 }
214 return p - page; 208 return 0;
215} 209}
216 210
217static int 211static int cache_info(struct seq_file *m)
218cache_info(char *page)
219{ 212{
220 char *p = page;
221 unsigned long i, levels, unique_caches; 213 unsigned long i, levels, unique_caches;
222 pal_cache_config_info_t cci; 214 pal_cache_config_info_t cci;
223 int j, k; 215 int j, k;
@@ -228,73 +220,74 @@ cache_info(char *page)
228 return 0; 220 return 0;
229 } 221 }
230 222
231 p += sprintf(p, "Cache levels : %ld\nUnique caches : %ld\n\n", levels, unique_caches); 223 seq_printf(m, "Cache levels : %ld\nUnique caches : %ld\n\n",
224 levels, unique_caches);
232 225
233 for (i=0; i < levels; i++) { 226 for (i=0; i < levels; i++) {
234
235 for (j=2; j >0 ; j--) { 227 for (j=2; j >0 ; j--) {
236
237 /* even without unification some level may not be present */ 228 /* even without unification some level may not be present */
238 if ((status=ia64_pal_cache_config_info(i,j, &cci)) != 0) { 229 if ((status=ia64_pal_cache_config_info(i,j, &cci)) != 0)
239 continue; 230 continue;
240 } 231
241 p += sprintf(p, 232 seq_printf(m,
242 "%s Cache level %lu:\n" 233 "%s Cache level %lu:\n"
243 "\tSize : %u bytes\n" 234 "\tSize : %u bytes\n"
244 "\tAttributes : ", 235 "\tAttributes : ",
245 cache_types[j+cci.pcci_unified], i+1, 236 cache_types[j+cci.pcci_unified], i+1,
246 cci.pcci_cache_size); 237 cci.pcci_cache_size);
247 238
248 if (cci.pcci_unified) p += sprintf(p, "Unified "); 239 if (cci.pcci_unified)
249 240 seq_puts(m, "Unified ");
250 p += sprintf(p, "%s\n", cache_mattrib[cci.pcci_cache_attr]); 241
251 242 seq_printf(m, "%s\n", cache_mattrib[cci.pcci_cache_attr]);
252 p += sprintf(p, 243
253 "\tAssociativity : %d\n" 244 seq_printf(m,
254 "\tLine size : %d bytes\n" 245 "\tAssociativity : %d\n"
255 "\tStride : %d bytes\n", 246 "\tLine size : %d bytes\n"
256 cci.pcci_assoc, 1<<cci.pcci_line_size, 1<<cci.pcci_stride); 247 "\tStride : %d bytes\n",
248 cci.pcci_assoc,
249 1<<cci.pcci_line_size,
250 1<<cci.pcci_stride);
257 if (j == 1) 251 if (j == 1)
258 p += sprintf(p, "\tStore latency : N/A\n"); 252 seq_puts(m, "\tStore latency : N/A\n");
259 else 253 else
260 p += sprintf(p, "\tStore latency : %d cycle(s)\n", 254 seq_printf(m, "\tStore latency : %d cycle(s)\n",
261 cci.pcci_st_latency); 255 cci.pcci_st_latency);
262 256
263 p += sprintf(p, 257 seq_printf(m,
264 "\tLoad latency : %d cycle(s)\n" 258 "\tLoad latency : %d cycle(s)\n"
265 "\tStore hints : ", cci.pcci_ld_latency); 259 "\tStore hints : ", cci.pcci_ld_latency);
266 260
267 for(k=0; k < 8; k++ ) { 261 for(k=0; k < 8; k++ ) {
268 if ( cci.pcci_st_hints & 0x1) 262 if ( cci.pcci_st_hints & 0x1)
269 p += sprintf(p, "[%s]", cache_st_hints[k]); 263 seq_printf(m, "[%s]", cache_st_hints[k]);
270 cci.pcci_st_hints >>=1; 264 cci.pcci_st_hints >>=1;
271 } 265 }
272 p += sprintf(p, "\n\tLoad hints : "); 266 seq_puts(m, "\n\tLoad hints : ");
273 267
274 for(k=0; k < 8; k++ ) { 268 for(k=0; k < 8; k++ ) {
275 if (cci.pcci_ld_hints & 0x1) 269 if (cci.pcci_ld_hints & 0x1)
276 p += sprintf(p, "[%s]", cache_ld_hints[k]); 270 seq_printf(m, "[%s]", cache_ld_hints[k]);
277 cci.pcci_ld_hints >>=1; 271 cci.pcci_ld_hints >>=1;
278 } 272 }
279 p += sprintf(p, 273 seq_printf(m,
280 "\n\tAlias boundary : %d byte(s)\n" 274 "\n\tAlias boundary : %d byte(s)\n"
281 "\tTag LSB : %d\n" 275 "\tTag LSB : %d\n"
282 "\tTag MSB : %d\n", 276 "\tTag MSB : %d\n",
283 1<<cci.pcci_alias_boundary, cci.pcci_tag_lsb, 277 1<<cci.pcci_alias_boundary, cci.pcci_tag_lsb,
284 cci.pcci_tag_msb); 278 cci.pcci_tag_msb);
285 279
286 /* when unified, data(j=2) is enough */ 280 /* when unified, data(j=2) is enough */
287 if (cci.pcci_unified) break; 281 if (cci.pcci_unified)
282 break;
288 } 283 }
289 } 284 }
290 return p - page; 285 return 0;
291} 286}
292 287
293 288
294static int 289static int vm_info(struct seq_file *m)
295vm_info(char *page)
296{ 290{
297 char *p = page;
298 u64 tr_pages =0, vw_pages=0, tc_pages; 291 u64 tr_pages =0, vw_pages=0, tc_pages;
299 u64 attrib; 292 u64 attrib;
300 pal_vm_info_1_u_t vm_info_1; 293 pal_vm_info_1_u_t vm_info_1;
@@ -309,7 +302,7 @@ vm_info(char *page)
309 printk(KERN_ERR "ia64_pal_vm_summary=%ld\n", status); 302 printk(KERN_ERR "ia64_pal_vm_summary=%ld\n", status);
310 } else { 303 } else {
311 304
312 p += sprintf(p, 305 seq_printf(m,
313 "Physical Address Space : %d bits\n" 306 "Physical Address Space : %d bits\n"
314 "Virtual Address Space : %d bits\n" 307 "Virtual Address Space : %d bits\n"
315 "Protection Key Registers(PKR) : %d\n" 308 "Protection Key Registers(PKR) : %d\n"
@@ -324,49 +317,49 @@ vm_info(char *page)
324 vm_info_1.pal_vm_info_1_s.hash_tag_id, 317 vm_info_1.pal_vm_info_1_s.hash_tag_id,
325 vm_info_2.pal_vm_info_2_s.rid_size); 318 vm_info_2.pal_vm_info_2_s.rid_size);
326 if (vm_info_2.pal_vm_info_2_s.max_purges == PAL_MAX_PURGES) 319 if (vm_info_2.pal_vm_info_2_s.max_purges == PAL_MAX_PURGES)
327 p += sprintf(p, "unlimited\n"); 320 seq_puts(m, "unlimited\n");
328 else 321 else
329 p += sprintf(p, "%d\n", 322 seq_printf(m, "%d\n",
330 vm_info_2.pal_vm_info_2_s.max_purges ? 323 vm_info_2.pal_vm_info_2_s.max_purges ?
331 vm_info_2.pal_vm_info_2_s.max_purges : 1); 324 vm_info_2.pal_vm_info_2_s.max_purges : 1);
332 } 325 }
333 326
334 if (ia64_pal_mem_attrib(&attrib) == 0) { 327 if (ia64_pal_mem_attrib(&attrib) == 0) {
335 p += sprintf(p, "Supported memory attributes : "); 328 seq_puts(m, "Supported memory attributes : ");
336 sep = ""; 329 sep = "";
337 for (i = 0; i < 8; i++) { 330 for (i = 0; i < 8; i++) {
338 if (attrib & (1 << i)) { 331 if (attrib & (1 << i)) {
339 p += sprintf(p, "%s%s", sep, mem_attrib[i]); 332 seq_printf(m, "%s%s", sep, mem_attrib[i]);
340 sep = ", "; 333 sep = ", ";
341 } 334 }
342 } 335 }
343 p += sprintf(p, "\n"); 336 seq_putc(m, '\n');
344 } 337 }
345 338
346 if ((status = ia64_pal_vm_page_size(&tr_pages, &vw_pages)) !=0) { 339 if ((status = ia64_pal_vm_page_size(&tr_pages, &vw_pages)) !=0) {
347 printk(KERN_ERR "ia64_pal_vm_page_size=%ld\n", status); 340 printk(KERN_ERR "ia64_pal_vm_page_size=%ld\n", status);
348 } else { 341 } else {
349 342
350 p += sprintf(p, 343 seq_printf(m,
351 "\nTLB walker : %simplemented\n" 344 "\nTLB walker : %simplemented\n"
352 "Number of DTR : %d\n" 345 "Number of DTR : %d\n"
353 "Number of ITR : %d\n" 346 "Number of ITR : %d\n"
354 "TLB insertable page sizes : ", 347 "TLB insertable page sizes : ",
355 vm_info_1.pal_vm_info_1_s.vw ? "" : "not ", 348 vm_info_1.pal_vm_info_1_s.vw ? "" : "not ",
356 vm_info_1.pal_vm_info_1_s.max_dtr_entry+1, 349 vm_info_1.pal_vm_info_1_s.max_dtr_entry+1,
357 vm_info_1.pal_vm_info_1_s.max_itr_entry+1); 350 vm_info_1.pal_vm_info_1_s.max_itr_entry+1);
358
359 351
360 p = bitvector_process(p, tr_pages); 352 bitvector_process(m, tr_pages);
361 353
362 p += sprintf(p, "\nTLB purgeable page sizes : "); 354 seq_puts(m, "\nTLB purgeable page sizes : ");
363 355
364 p = bitvector_process(p, vw_pages); 356 bitvector_process(m, vw_pages);
365 } 357 }
366 if ((status=ia64_get_ptce(&ptce)) != 0) { 358
359 if ((status = ia64_get_ptce(&ptce)) != 0) {
367 printk(KERN_ERR "ia64_get_ptce=%ld\n", status); 360 printk(KERN_ERR "ia64_get_ptce=%ld\n", status);
368 } else { 361 } else {
369 p += sprintf(p, 362 seq_printf(m,
370 "\nPurge base address : 0x%016lx\n" 363 "\nPurge base address : 0x%016lx\n"
371 "Purge outer loop count : %d\n" 364 "Purge outer loop count : %d\n"
372 "Purge inner loop count : %d\n" 365 "Purge inner loop count : %d\n"
@@ -375,7 +368,7 @@ vm_info(char *page)
375 ptce.base, ptce.count[0], ptce.count[1], 368 ptce.base, ptce.count[0], ptce.count[1],
376 ptce.stride[0], ptce.stride[1]); 369 ptce.stride[0], ptce.stride[1]);
377 370
378 p += sprintf(p, 371 seq_printf(m,
379 "TC Levels : %d\n" 372 "TC Levels : %d\n"
380 "Unique TC(s) : %d\n", 373 "Unique TC(s) : %d\n",
381 vm_info_1.pal_vm_info_1_s.num_tc_levels, 374 vm_info_1.pal_vm_info_1_s.num_tc_levels,
@@ -385,13 +378,11 @@ vm_info(char *page)
385 for (j=2; j>0 ; j--) { 378 for (j=2; j>0 ; j--) {
386 tc_pages = 0; /* just in case */ 379 tc_pages = 0; /* just in case */
387 380
388
389 /* even without unification, some levels may not be present */ 381 /* even without unification, some levels may not be present */
390 if ((status=ia64_pal_vm_info(i,j, &tc_info, &tc_pages)) != 0) { 382 if ((status=ia64_pal_vm_info(i,j, &tc_info, &tc_pages)) != 0)
391 continue; 383 continue;
392 }
393 384
394 p += sprintf(p, 385 seq_printf(m,
395 "\n%s Translation Cache Level %d:\n" 386 "\n%s Translation Cache Level %d:\n"
396 "\tHash sets : %d\n" 387 "\tHash sets : %d\n"
397 "\tAssociativity : %d\n" 388 "\tAssociativity : %d\n"
@@ -403,15 +394,15 @@ vm_info(char *page)
403 tc_info.tc_num_entries); 394 tc_info.tc_num_entries);
404 395
405 if (tc_info.tc_pf) 396 if (tc_info.tc_pf)
406 p += sprintf(p, "PreferredPageSizeOptimized "); 397 seq_puts(m, "PreferredPageSizeOptimized ");
407 if (tc_info.tc_unified) 398 if (tc_info.tc_unified)
408 p += sprintf(p, "Unified "); 399 seq_puts(m, "Unified ");
409 if (tc_info.tc_reduce_tr) 400 if (tc_info.tc_reduce_tr)
410 p += sprintf(p, "TCReduction"); 401 seq_puts(m, "TCReduction");
411 402
412 p += sprintf(p, "\n\tSupported page sizes: "); 403 seq_puts(m, "\n\tSupported page sizes: ");
413 404
414 p = bitvector_process(p, tc_pages); 405 bitvector_process(m, tc_pages);
415 406
416 /* when unified date (j=2) is enough */ 407 /* when unified date (j=2) is enough */
417 if (tc_info.tc_unified) 408 if (tc_info.tc_unified)
@@ -419,16 +410,14 @@ vm_info(char *page)
419 } 410 }
420 } 411 }
421 } 412 }
422 p += sprintf(p, "\n");
423 413
424 return p - page; 414 seq_putc(m, '\n');
415 return 0;
425} 416}
426 417
427 418
428static int 419static int register_info(struct seq_file *m)
429register_info(char *page)
430{ 420{
431 char *p = page;
432 u64 reg_info[2]; 421 u64 reg_info[2];
433 u64 info; 422 u64 info;
434 unsigned long phys_stacked; 423 unsigned long phys_stacked;
@@ -442,35 +431,31 @@ register_info(char *page)
442 }; 431 };
443 432
444 for(info=0; info < 4; info++) { 433 for(info=0; info < 4; info++) {
445 434 if (ia64_pal_register_info(info, &reg_info[0], &reg_info[1]) != 0)
446 if (ia64_pal_register_info(info, &reg_info[0], &reg_info[1]) != 0) return 0; 435 return 0;
447 436 seq_printf(m, "%-32s : ", info_type[info]);
448 p += sprintf(p, "%-32s : ", info_type[info]); 437 bitregister_process(m, reg_info, 128);
449 438 seq_putc(m, '\n');
450 p = bitregister_process(p, reg_info, 128);
451
452 p += sprintf(p, "\n");
453 } 439 }
454 440
455 if (ia64_pal_rse_info(&phys_stacked, &hints) == 0) { 441 if (ia64_pal_rse_info(&phys_stacked, &hints) == 0)
442 seq_printf(m,
443 "RSE stacked physical registers : %ld\n"
444 "RSE load/store hints : %ld (%s)\n",
445 phys_stacked, hints.ph_data,
446 hints.ph_data < RSE_HINTS_COUNT ? rse_hints[hints.ph_data]: "(??)");
456 447
457 p += sprintf(p,
458 "RSE stacked physical registers : %ld\n"
459 "RSE load/store hints : %ld (%s)\n",
460 phys_stacked, hints.ph_data,
461 hints.ph_data < RSE_HINTS_COUNT ? rse_hints[hints.ph_data]: "(??)");
462 }
463 if (ia64_pal_debug_info(&iregs, &dregs)) 448 if (ia64_pal_debug_info(&iregs, &dregs))
464 return 0; 449 return 0;
465 450
466 p += sprintf(p, 451 seq_printf(m,
467 "Instruction debug register pairs : %ld\n" 452 "Instruction debug register pairs : %ld\n"
468 "Data debug register pairs : %ld\n", iregs, dregs); 453 "Data debug register pairs : %ld\n", iregs, dregs);
469 454
470 return p - page; 455 return 0;
471} 456}
472 457
473static char *proc_features_0[]={ /* Feature set 0 */ 458static const char *const proc_features_0[]={ /* Feature set 0 */
474 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, 459 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
475 NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL, 460 NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,
476 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, 461 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
@@ -502,7 +487,7 @@ static char *proc_features_0[]={ /* Feature set 0 */
502 "Enable BERR promotion" 487 "Enable BERR promotion"
503}; 488};
504 489
505static char *proc_features_16[]={ /* Feature set 16 */ 490static const char *const proc_features_16[]={ /* Feature set 16 */
506 "Disable ETM", 491 "Disable ETM",
507 "Enable ETM", 492 "Enable ETM",
508 "Enable MCA on half-way timer", 493 "Enable MCA on half-way timer",
@@ -522,7 +507,7 @@ static char *proc_features_16[]={ /* Feature set 16 */
522 NULL, NULL, NULL, NULL, NULL 507 NULL, NULL, NULL, NULL, NULL
523}; 508};
524 509
525static char **proc_features[]={ 510static const char *const *const proc_features[]={
526 proc_features_0, 511 proc_features_0,
527 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 512 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
528 NULL, NULL, NULL, NULL, 513 NULL, NULL, NULL, NULL,
@@ -530,11 +515,10 @@ static char **proc_features[]={
530 NULL, NULL, NULL, NULL, 515 NULL, NULL, NULL, NULL,
531}; 516};
532 517
533static char * feature_set_info(char *page, u64 avail, u64 status, u64 control, 518static void feature_set_info(struct seq_file *m, u64 avail, u64 status, u64 control,
534 unsigned long set) 519 unsigned long set)
535{ 520{
536 char *p = page; 521 const char *const *vf, *const *v;
537 char **vf, **v;
538 int i; 522 int i;
539 523
540 vf = v = proc_features[set]; 524 vf = v = proc_features[set];
@@ -547,13 +531,13 @@ static char * feature_set_info(char *page, u64 avail, u64 status, u64 control,
547 if (vf) 531 if (vf)
548 v = vf + i; 532 v = vf + i;
549 if ( v && *v ) { 533 if ( v && *v ) {
550 p += sprintf(p, "%-40s : %s %s\n", *v, 534 seq_printf(m, "%-40s : %s %s\n", *v,
551 avail & 0x1 ? (status & 0x1 ? 535 avail & 0x1 ? (status & 0x1 ?
552 "On " : "Off"): "", 536 "On " : "Off"): "",
553 avail & 0x1 ? (control & 0x1 ? 537 avail & 0x1 ? (control & 0x1 ?
554 "Ctrl" : "NoCtrl"): ""); 538 "Ctrl" : "NoCtrl"): "");
555 } else { 539 } else {
556 p += sprintf(p, "Feature set %2ld bit %2d\t\t\t" 540 seq_printf(m, "Feature set %2ld bit %2d\t\t\t"
557 " : %s %s\n", 541 " : %s %s\n",
558 set, i, 542 set, i,
559 avail & 0x1 ? (status & 0x1 ? 543 avail & 0x1 ? (status & 0x1 ?
@@ -562,36 +546,32 @@ static char * feature_set_info(char *page, u64 avail, u64 status, u64 control,
562 "Ctrl" : "NoCtrl"): ""); 546 "Ctrl" : "NoCtrl"): "");
563 } 547 }
564 } 548 }
565 return p;
566} 549}
567 550
568static int 551static int processor_info(struct seq_file *m)
569processor_info(char *page)
570{ 552{
571 char *p = page;
572 u64 avail=1, status=1, control=1, feature_set=0; 553 u64 avail=1, status=1, control=1, feature_set=0;
573 s64 ret; 554 s64 ret;
574 555
575 do { 556 do {
576 ret = ia64_pal_proc_get_features(&avail, &status, &control, 557 ret = ia64_pal_proc_get_features(&avail, &status, &control,
577 feature_set); 558 feature_set);
578 if (ret < 0) { 559 if (ret < 0)
579 return p - page; 560 return 0;
580 } 561
581 if (ret == 1) { 562 if (ret == 1) {
582 feature_set++; 563 feature_set++;
583 continue; 564 continue;
584 } 565 }
585 566
586 p = feature_set_info(p, avail, status, control, feature_set); 567 feature_set_info(m, avail, status, control, feature_set);
587
588 feature_set++; 568 feature_set++;
589 } while(1); 569 } while(1);
590 570
591 return p - page; 571 return 0;
592} 572}
593 573
594static const char *bus_features[]={ 574static const char *const bus_features[]={
595 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, 575 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
596 NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL, 576 NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,
597 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, 577 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
@@ -617,125 +597,118 @@ static const char *bus_features[]={
617}; 597};
618 598
619 599
620static int 600static int bus_info(struct seq_file *m)
621bus_info(char *page)
622{ 601{
623 char *p = page; 602 const char *const *v = bus_features;
624 const char **v = bus_features;
625 pal_bus_features_u_t av, st, ct; 603 pal_bus_features_u_t av, st, ct;
626 u64 avail, status, control; 604 u64 avail, status, control;
627 int i; 605 int i;
628 s64 ret; 606 s64 ret;
629 607
630 if ((ret=ia64_pal_bus_get_features(&av, &st, &ct)) != 0) return 0; 608 if ((ret=ia64_pal_bus_get_features(&av, &st, &ct)) != 0)
609 return 0;
631 610
632 avail = av.pal_bus_features_val; 611 avail = av.pal_bus_features_val;
633 status = st.pal_bus_features_val; 612 status = st.pal_bus_features_val;
634 control = ct.pal_bus_features_val; 613 control = ct.pal_bus_features_val;
635 614
636 for(i=0; i < 64; i++, v++, avail >>=1, status >>=1, control >>=1) { 615 for(i=0; i < 64; i++, v++, avail >>=1, status >>=1, control >>=1) {
637 if ( ! *v ) continue; 616 if ( ! *v )
638 p += sprintf(p, "%-48s : %s%s %s\n", *v, 617 continue;
639 avail & 0x1 ? "" : "NotImpl", 618 seq_printf(m, "%-48s : %s%s %s\n", *v,
640 avail & 0x1 ? (status & 0x1 ? "On" : "Off"): "", 619 avail & 0x1 ? "" : "NotImpl",
641 avail & 0x1 ? (control & 0x1 ? "Ctrl" : "NoCtrl"): ""); 620 avail & 0x1 ? (status & 0x1 ? "On" : "Off"): "",
621 avail & 0x1 ? (control & 0x1 ? "Ctrl" : "NoCtrl"): "");
642 } 622 }
643 return p - page; 623 return 0;
644} 624}
645 625
646static int 626static int version_info(struct seq_file *m)
647version_info(char *page)
648{ 627{
649 pal_version_u_t min_ver, cur_ver; 628 pal_version_u_t min_ver, cur_ver;
650 char *p = page;
651 629
652 if (ia64_pal_version(&min_ver, &cur_ver) != 0) 630 if (ia64_pal_version(&min_ver, &cur_ver) != 0)
653 return 0; 631 return 0;
654 632
655 p += sprintf(p, 633 seq_printf(m,
656 "PAL_vendor : 0x%02x (min=0x%02x)\n" 634 "PAL_vendor : 0x%02x (min=0x%02x)\n"
657 "PAL_A : %02x.%02x (min=%02x.%02x)\n" 635 "PAL_A : %02x.%02x (min=%02x.%02x)\n"
658 "PAL_B : %02x.%02x (min=%02x.%02x)\n", 636 "PAL_B : %02x.%02x (min=%02x.%02x)\n",
659 cur_ver.pal_version_s.pv_pal_vendor, 637 cur_ver.pal_version_s.pv_pal_vendor,
660 min_ver.pal_version_s.pv_pal_vendor, 638 min_ver.pal_version_s.pv_pal_vendor,
661 cur_ver.pal_version_s.pv_pal_a_model, 639 cur_ver.pal_version_s.pv_pal_a_model,
662 cur_ver.pal_version_s.pv_pal_a_rev, 640 cur_ver.pal_version_s.pv_pal_a_rev,
663 min_ver.pal_version_s.pv_pal_a_model, 641 min_ver.pal_version_s.pv_pal_a_model,
664 min_ver.pal_version_s.pv_pal_a_rev, 642 min_ver.pal_version_s.pv_pal_a_rev,
665 cur_ver.pal_version_s.pv_pal_b_model, 643 cur_ver.pal_version_s.pv_pal_b_model,
666 cur_ver.pal_version_s.pv_pal_b_rev, 644 cur_ver.pal_version_s.pv_pal_b_rev,
667 min_ver.pal_version_s.pv_pal_b_model, 645 min_ver.pal_version_s.pv_pal_b_model,
668 min_ver.pal_version_s.pv_pal_b_rev); 646 min_ver.pal_version_s.pv_pal_b_rev);
669 return p - page; 647 return 0;
670} 648}
671 649
672static int 650static int perfmon_info(struct seq_file *m)
673perfmon_info(char *page)
674{ 651{
675 char *p = page;
676 u64 pm_buffer[16]; 652 u64 pm_buffer[16];
677 pal_perf_mon_info_u_t pm_info; 653 pal_perf_mon_info_u_t pm_info;
678 654
679 if (ia64_pal_perf_mon_info(pm_buffer, &pm_info) != 0) return 0; 655 if (ia64_pal_perf_mon_info(pm_buffer, &pm_info) != 0)
680 656 return 0;
681 p += sprintf(p,
682 "PMC/PMD pairs : %d\n"
683 "Counter width : %d bits\n"
684 "Cycle event number : %d\n"
685 "Retired event number : %d\n"
686 "Implemented PMC : ",
687 pm_info.pal_perf_mon_info_s.generic, pm_info.pal_perf_mon_info_s.width,
688 pm_info.pal_perf_mon_info_s.cycles, pm_info.pal_perf_mon_info_s.retired);
689 657
690 p = bitregister_process(p, pm_buffer, 256); 658 seq_printf(m,
691 p += sprintf(p, "\nImplemented PMD : "); 659 "PMC/PMD pairs : %d\n"
692 p = bitregister_process(p, pm_buffer+4, 256); 660 "Counter width : %d bits\n"
693 p += sprintf(p, "\nCycles count capable : "); 661 "Cycle event number : %d\n"
694 p = bitregister_process(p, pm_buffer+8, 256); 662 "Retired event number : %d\n"
695 p += sprintf(p, "\nRetired bundles count capable : "); 663 "Implemented PMC : ",
664 pm_info.pal_perf_mon_info_s.generic,
665 pm_info.pal_perf_mon_info_s.width,
666 pm_info.pal_perf_mon_info_s.cycles,
667 pm_info.pal_perf_mon_info_s.retired);
668
669 bitregister_process(m, pm_buffer, 256);
670 seq_puts(m, "\nImplemented PMD : ");
671 bitregister_process(m, pm_buffer+4, 256);
672 seq_puts(m, "\nCycles count capable : ");
673 bitregister_process(m, pm_buffer+8, 256);
674 seq_puts(m, "\nRetired bundles count capable : ");
696 675
697#ifdef CONFIG_ITANIUM 676#ifdef CONFIG_ITANIUM
698 /* 677 /*
699 * PAL_PERF_MON_INFO reports that only PMC4 can be used to count CPU_CYCLES 678 * PAL_PERF_MON_INFO reports that only PMC4 can be used to count CPU_CYCLES
700 * which is wrong, both PMC4 and PMD5 support it. 679 * which is wrong, both PMC4 and PMD5 support it.
701 */ 680 */
702 if (pm_buffer[12] == 0x10) pm_buffer[12]=0x30; 681 if (pm_buffer[12] == 0x10)
682 pm_buffer[12]=0x30;
703#endif 683#endif
704 684
705 p = bitregister_process(p, pm_buffer+12, 256); 685 bitregister_process(m, pm_buffer+12, 256);
706 686 seq_putc(m, '\n');
707 p += sprintf(p, "\n"); 687 return 0;
708
709 return p - page;
710} 688}
711 689
712static int 690static int frequency_info(struct seq_file *m)
713frequency_info(char *page)
714{ 691{
715 char *p = page;
716 struct pal_freq_ratio proc, itc, bus; 692 struct pal_freq_ratio proc, itc, bus;
717 unsigned long base; 693 unsigned long base;
718 694
719 if (ia64_pal_freq_base(&base) == -1) 695 if (ia64_pal_freq_base(&base) == -1)
720 p += sprintf(p, "Output clock : not implemented\n"); 696 seq_puts(m, "Output clock : not implemented\n");
721 else 697 else
722 p += sprintf(p, "Output clock : %ld ticks/s\n", base); 698 seq_printf(m, "Output clock : %ld ticks/s\n", base);
723 699
724 if (ia64_pal_freq_ratios(&proc, &bus, &itc) != 0) return 0; 700 if (ia64_pal_freq_ratios(&proc, &bus, &itc) != 0) return 0;
725 701
726 p += sprintf(p, 702 seq_printf(m,
727 "Processor/Clock ratio : %d/%d\n" 703 "Processor/Clock ratio : %d/%d\n"
728 "Bus/Clock ratio : %d/%d\n" 704 "Bus/Clock ratio : %d/%d\n"
729 "ITC/Clock ratio : %d/%d\n", 705 "ITC/Clock ratio : %d/%d\n",
730 proc.num, proc.den, bus.num, bus.den, itc.num, itc.den); 706 proc.num, proc.den, bus.num, bus.den, itc.num, itc.den);
731 707 return 0;
732 return p - page;
733} 708}
734 709
735static int 710static int tr_info(struct seq_file *m)
736tr_info(char *page)
737{ 711{
738 char *p = page;
739 long status; 712 long status;
740 pal_tr_valid_u_t tr_valid; 713 pal_tr_valid_u_t tr_valid;
741 u64 tr_buffer[4]; 714 u64 tr_buffer[4];
@@ -794,39 +767,40 @@ tr_info(char *page)
794 767
795 ifa_reg = (struct ifa_reg *)&tr_buffer[2]; 768 ifa_reg = (struct ifa_reg *)&tr_buffer[2];
796 769
797 if (ifa_reg->valid == 0) continue; 770 if (ifa_reg->valid == 0)
771 continue;
798 772
799 gr_reg = (struct gr_reg *)tr_buffer; 773 gr_reg = (struct gr_reg *)tr_buffer;
800 itir_reg = (struct itir_reg *)&tr_buffer[1]; 774 itir_reg = (struct itir_reg *)&tr_buffer[1];
801 rid_reg = (struct rid_reg *)&tr_buffer[3]; 775 rid_reg = (struct rid_reg *)&tr_buffer[3];
802 776
803 pgm = -1 << (itir_reg->ps - 12); 777 pgm = -1 << (itir_reg->ps - 12);
804 p += sprintf(p, 778 seq_printf(m,
805 "%cTR%lu: av=%d pv=%d dv=%d mv=%d\n" 779 "%cTR%lu: av=%d pv=%d dv=%d mv=%d\n"
806 "\tppn : 0x%lx\n" 780 "\tppn : 0x%lx\n"
807 "\tvpn : 0x%lx\n" 781 "\tvpn : 0x%lx\n"
808 "\tps : ", 782 "\tps : ",
809 "ID"[i], j, 783 "ID"[i], j,
810 tr_valid.pal_tr_valid_s.access_rights_valid, 784 tr_valid.pal_tr_valid_s.access_rights_valid,
811 tr_valid.pal_tr_valid_s.priv_level_valid, 785 tr_valid.pal_tr_valid_s.priv_level_valid,
812 tr_valid.pal_tr_valid_s.dirty_bit_valid, 786 tr_valid.pal_tr_valid_s.dirty_bit_valid,
813 tr_valid.pal_tr_valid_s.mem_attr_valid, 787 tr_valid.pal_tr_valid_s.mem_attr_valid,
814 (gr_reg->ppn & pgm)<< 12, (ifa_reg->vpn & pgm)<< 12); 788 (gr_reg->ppn & pgm)<< 12, (ifa_reg->vpn & pgm)<< 12);
815 789
816 p = bitvector_process(p, 1<< itir_reg->ps); 790 bitvector_process(m, 1<< itir_reg->ps);
817 791
818 p += sprintf(p, 792 seq_printf(m,
819 "\n\tpl : %d\n" 793 "\n\tpl : %d\n"
820 "\tar : %d\n" 794 "\tar : %d\n"
821 "\trid : %x\n" 795 "\trid : %x\n"
822 "\tp : %d\n" 796 "\tp : %d\n"
823 "\tma : %d\n" 797 "\tma : %d\n"
824 "\td : %d\n", 798 "\td : %d\n",
825 gr_reg->pl, gr_reg->ar, rid_reg->rid, gr_reg->p, gr_reg->ma, 799 gr_reg->pl, gr_reg->ar, rid_reg->rid, gr_reg->p, gr_reg->ma,
826 gr_reg->d); 800 gr_reg->d);
827 } 801 }
828 } 802 }
829 return p - page; 803 return 0;
830} 804}
831 805
832 806
@@ -834,7 +808,7 @@ tr_info(char *page)
834/* 808/*
835 * List {name,function} pairs for every entry in /proc/palinfo/cpu* 809 * List {name,function} pairs for every entry in /proc/palinfo/cpu*
836 */ 810 */
837static palinfo_entry_t palinfo_entries[]={ 811static const palinfo_entry_t palinfo_entries[]={
838 { "version_info", version_info, }, 812 { "version_info", version_info, },
839 { "vm_info", vm_info, }, 813 { "vm_info", vm_info, },
840 { "cache_info", cache_info, }, 814 { "cache_info", cache_info, },
@@ -876,7 +850,7 @@ typedef union {
876 */ 850 */
877typedef struct { 851typedef struct {
878 palinfo_func_t func; /* pointer to function to call */ 852 palinfo_func_t func; /* pointer to function to call */
879 char *page; /* buffer to store results */ 853 struct seq_file *m; /* buffer to store results */
880 int ret; /* return value from call */ 854 int ret; /* return value from call */
881} palinfo_smp_data_t; 855} palinfo_smp_data_t;
882 856
@@ -889,7 +863,7 @@ static void
889palinfo_smp_call(void *info) 863palinfo_smp_call(void *info)
890{ 864{
891 palinfo_smp_data_t *data = (palinfo_smp_data_t *)info; 865 palinfo_smp_data_t *data = (palinfo_smp_data_t *)info;
892 data->ret = (*data->func)(data->page); 866 data->ret = (*data->func)(data->m);
893} 867}
894 868
895/* 869/*
@@ -899,13 +873,13 @@ palinfo_smp_call(void *info)
899 * otherwise how many bytes in the "page" buffer were written 873 * otherwise how many bytes in the "page" buffer were written
900 */ 874 */
901static 875static
902int palinfo_handle_smp(pal_func_cpu_u_t *f, char *page) 876int palinfo_handle_smp(struct seq_file *m, pal_func_cpu_u_t *f)
903{ 877{
904 palinfo_smp_data_t ptr; 878 palinfo_smp_data_t ptr;
905 int ret; 879 int ret;
906 880
907 ptr.func = palinfo_entries[f->func_id].proc_read; 881 ptr.func = palinfo_entries[f->func_id].proc_read;
908 ptr.page = page; 882 ptr.m = m;
909 ptr.ret = 0; /* just in case */ 883 ptr.ret = 0; /* just in case */
910 884
911 885
@@ -919,7 +893,7 @@ int palinfo_handle_smp(pal_func_cpu_u_t *f, char *page)
919} 893}
920#else /* ! CONFIG_SMP */ 894#else /* ! CONFIG_SMP */
921static 895static
922int palinfo_handle_smp(pal_func_cpu_u_t *f, char *page) 896int palinfo_handle_smp(struct seq_file *m, pal_func_cpu_u_t *f)
923{ 897{
924 printk(KERN_ERR "palinfo: should not be called with non SMP kernel\n"); 898 printk(KERN_ERR "palinfo: should not be called with non SMP kernel\n");
925 return 0; 899 return 0;
@@ -929,34 +903,35 @@ int palinfo_handle_smp(pal_func_cpu_u_t *f, char *page)
929/* 903/*
930 * Entry point routine: all calls go through this function 904 * Entry point routine: all calls go through this function
931 */ 905 */
932static int 906static int proc_palinfo_show(struct seq_file *m, void *v)
933palinfo_read_entry(char *page, char **start, off_t off, int count, int *eof, void *data)
934{ 907{
935 int len=0; 908 pal_func_cpu_u_t *f = (pal_func_cpu_u_t *)&m->private;
936 pal_func_cpu_u_t *f = (pal_func_cpu_u_t *)&data;
937 909
938 /* 910 /*
939 * in SMP mode, we may need to call another CPU to get correct 911 * in SMP mode, we may need to call another CPU to get correct
940 * information. PAL, by definition, is processor specific 912 * information. PAL, by definition, is processor specific
941 */ 913 */
942 if (f->req_cpu == get_cpu()) 914 if (f->req_cpu == get_cpu())
943 len = (*palinfo_entries[f->func_id].proc_read)(page); 915 (*palinfo_entries[f->func_id].proc_read)(m);
944 else 916 else
945 len = palinfo_handle_smp(f, page); 917 palinfo_handle_smp(m, f);
946 918
947 put_cpu(); 919 put_cpu();
920 return 0;
921}
948 922
949 if (len <= off+count) *eof = 1; 923static int proc_palinfo_open(struct inode *inode, struct file *file)
950 924{
951 *start = page + off; 925 return single_open(file, proc_palinfo_show, PDE_DATA(inode));
952 len -= off;
953
954 if (len>count) len = count;
955 if (len<0) len = 0;
956
957 return len;
958} 926}
959 927
928static const struct file_operations proc_palinfo_fops = {
929 .open = proc_palinfo_open,
930 .read = seq_read,
931 .llseek = seq_lseek,
932 .release = seq_release,
933};
934
960static void __cpuinit 935static void __cpuinit
961create_palinfo_proc_entries(unsigned int cpu) 936create_palinfo_proc_entries(unsigned int cpu)
962{ 937{
@@ -974,9 +949,8 @@ create_palinfo_proc_entries(unsigned int cpu)
974 949
975 for (j=0; j < NR_PALINFO_ENTRIES; j++) { 950 for (j=0; j < NR_PALINFO_ENTRIES; j++) {
976 f.func_id = j; 951 f.func_id = j;
977 create_proc_read_entry( 952 proc_create_data(palinfo_entries[j].name, 0, cpu_dir,
978 palinfo_entries[j].name, 0, cpu_dir, 953 &proc_palinfo_fops, (void *)f.value);
979 palinfo_read_entry, (void *)f.value);
980 } 954 }
981} 955}
982 956
diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
index aa527d7e91f2..5035245cb258 100644
--- a/arch/ia64/kernel/salinfo.c
+++ b/arch/ia64/kernel/salinfo.c
@@ -40,6 +40,7 @@
40#include <linux/cpu.h> 40#include <linux/cpu.h>
41#include <linux/types.h> 41#include <linux/types.h>
42#include <linux/proc_fs.h> 42#include <linux/proc_fs.h>
43#include <linux/seq_file.h>
43#include <linux/module.h> 44#include <linux/module.h>
44#include <linux/smp.h> 45#include <linux/smp.h>
45#include <linux/timer.h> 46#include <linux/timer.h>
@@ -53,7 +54,7 @@ MODULE_AUTHOR("Jesse Barnes <jbarnes@sgi.com>");
53MODULE_DESCRIPTION("/proc interface to IA-64 SAL features"); 54MODULE_DESCRIPTION("/proc interface to IA-64 SAL features");
54MODULE_LICENSE("GPL"); 55MODULE_LICENSE("GPL");
55 56
56static int salinfo_read(char *page, char **start, off_t off, int count, int *eof, void *data); 57static const struct file_operations proc_salinfo_fops;
57 58
58typedef struct { 59typedef struct {
59 const char *name; /* name of the proc entry */ 60 const char *name; /* name of the proc entry */
@@ -65,7 +66,7 @@ typedef struct {
65 * List {name,feature} pairs for every entry in /proc/sal/<feature> 66 * List {name,feature} pairs for every entry in /proc/sal/<feature>
66 * that this module exports 67 * that this module exports
67 */ 68 */
68static salinfo_entry_t salinfo_entries[]={ 69static const salinfo_entry_t salinfo_entries[]={
69 { "bus_lock", IA64_SAL_PLATFORM_FEATURE_BUS_LOCK, }, 70 { "bus_lock", IA64_SAL_PLATFORM_FEATURE_BUS_LOCK, },
70 { "irq_redirection", IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT, }, 71 { "irq_redirection", IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT, },
71 { "ipi_redirection", IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT, }, 72 { "ipi_redirection", IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT, },
@@ -301,9 +302,7 @@ salinfo_event_open(struct inode *inode, struct file *file)
301static ssize_t 302static ssize_t
302salinfo_event_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) 303salinfo_event_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
303{ 304{
304 struct inode *inode = file_inode(file); 305 struct salinfo_data *data = PDE_DATA(file_inode(file));
305 struct proc_dir_entry *entry = PDE(inode);
306 struct salinfo_data *data = entry->data;
307 char cmd[32]; 306 char cmd[32];
308 size_t size; 307 size_t size;
309 int i, n, cpu = -1; 308 int i, n, cpu = -1;
@@ -360,8 +359,7 @@ static const struct file_operations salinfo_event_fops = {
360static int 359static int
361salinfo_log_open(struct inode *inode, struct file *file) 360salinfo_log_open(struct inode *inode, struct file *file)
362{ 361{
363 struct proc_dir_entry *entry = PDE(inode); 362 struct salinfo_data *data = PDE_DATA(inode);
364 struct salinfo_data *data = entry->data;
365 363
366 if (!capable(CAP_SYS_ADMIN)) 364 if (!capable(CAP_SYS_ADMIN))
367 return -EPERM; 365 return -EPERM;
@@ -386,8 +384,7 @@ salinfo_log_open(struct inode *inode, struct file *file)
386static int 384static int
387salinfo_log_release(struct inode *inode, struct file *file) 385salinfo_log_release(struct inode *inode, struct file *file)
388{ 386{
389 struct proc_dir_entry *entry = PDE(inode); 387 struct salinfo_data *data = PDE_DATA(inode);
390 struct salinfo_data *data = entry->data;
391 388
392 if (data->state == STATE_NO_DATA) { 389 if (data->state == STATE_NO_DATA) {
393 vfree(data->log_buffer); 390 vfree(data->log_buffer);
@@ -463,9 +460,7 @@ retry:
463static ssize_t 460static ssize_t
464salinfo_log_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) 461salinfo_log_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
465{ 462{
466 struct inode *inode = file_inode(file); 463 struct salinfo_data *data = PDE_DATA(file_inode(file));
467 struct proc_dir_entry *entry = PDE(inode);
468 struct salinfo_data *data = entry->data;
469 u8 *buf; 464 u8 *buf;
470 u64 bufsize; 465 u64 bufsize;
471 466
@@ -524,9 +519,7 @@ salinfo_log_clear(struct salinfo_data *data, int cpu)
524static ssize_t 519static ssize_t
525salinfo_log_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) 520salinfo_log_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
526{ 521{
527 struct inode *inode = file_inode(file); 522 struct salinfo_data *data = PDE_DATA(file_inode(file));
528 struct proc_dir_entry *entry = PDE(inode);
529 struct salinfo_data *data = entry->data;
530 char cmd[32]; 523 char cmd[32];
531 size_t size; 524 size_t size;
532 u32 offset; 525 u32 offset;
@@ -637,8 +630,9 @@ salinfo_init(void)
637 630
638 for (i=0; i < NR_SALINFO_ENTRIES; i++) { 631 for (i=0; i < NR_SALINFO_ENTRIES; i++) {
639 /* pass the feature bit in question as misc data */ 632 /* pass the feature bit in question as misc data */
640 *sdir++ = create_proc_read_entry (salinfo_entries[i].name, 0, salinfo_dir, 633 *sdir++ = proc_create_data(salinfo_entries[i].name, 0, salinfo_dir,
641 salinfo_read, (void *)salinfo_entries[i].feature); 634 &proc_salinfo_fops,
635 (void *)salinfo_entries[i].feature);
642 } 636 }
643 637
644 for (i = 0; i < ARRAY_SIZE(salinfo_log_name); i++) { 638 for (i = 0; i < ARRAY_SIZE(salinfo_log_name); i++) {
@@ -684,22 +678,23 @@ salinfo_init(void)
684 * 'data' contains an integer that corresponds to the feature we're 678 * 'data' contains an integer that corresponds to the feature we're
685 * testing 679 * testing
686 */ 680 */
687static int 681static int proc_salinfo_show(struct seq_file *m, void *v)
688salinfo_read(char *page, char **start, off_t off, int count, int *eof, void *data)
689{ 682{
690 int len = 0; 683 unsigned long data = (unsigned long)v;
691 684 seq_puts(m, (sal_platform_features & data) ? "1\n" : "0\n");
692 len = sprintf(page, (sal_platform_features & (unsigned long)data) ? "1\n" : "0\n"); 685 return 0;
693 686}
694 if (len <= off+count) *eof = 1;
695
696 *start = page + off;
697 len -= off;
698
699 if (len>count) len = count;
700 if (len<0) len = 0;
701 687
702 return len; 688static int proc_salinfo_open(struct inode *inode, struct file *file)
689{
690 return single_open(file, proc_salinfo_show, PDE_DATA(inode));
703} 691}
704 692
693static const struct file_operations proc_salinfo_fops = {
694 .open = proc_salinfo_open,
695 .read = seq_read,
696 .llseek = seq_lseek,
697 .release = seq_release,
698};
699
705module_init(salinfo_init); 700module_init(salinfo_init);
diff --git a/arch/ia64/sn/kernel/sn2/prominfo_proc.c b/arch/ia64/sn/kernel/sn2/prominfo_proc.c
index 20b88cb1881a..daa8d6badb16 100644
--- a/arch/ia64/sn/kernel/sn2/prominfo_proc.c
+++ b/arch/ia64/sn/kernel/sn2/prominfo_proc.c
@@ -11,6 +11,7 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/proc_fs.h> 13#include <linux/proc_fs.h>
14#include <linux/seq_file.h>
14#include <linux/nodemask.h> 15#include <linux/nodemask.h>
15#include <asm/io.h> 16#include <asm/io.h>
16#include <asm/sn/sn_sal.h> 17#include <asm/sn/sn_sal.h>
@@ -101,18 +102,18 @@ get_fit_entry(unsigned long nasid, int index, unsigned long *fentry,
101/* 102/*
102 * These two routines display the FIT table for each node. 103 * These two routines display the FIT table for each node.
103 */ 104 */
104static int dump_fit_entry(char *page, unsigned long *fentry) 105static void dump_fit_entry(struct seq_file *m, unsigned long *fentry)
105{ 106{
106 unsigned type; 107 unsigned type;
107 108
108 type = FIT_TYPE(fentry[1]); 109 type = FIT_TYPE(fentry[1]);
109 return sprintf(page, "%02x %-25s %x.%02x %016lx %u\n", 110 seq_printf(m, "%02x %-25s %x.%02x %016lx %u\n",
110 type, 111 type,
111 fit_type_name(type), 112 fit_type_name(type),
112 FIT_MAJOR(fentry[1]), FIT_MINOR(fentry[1]), 113 FIT_MAJOR(fentry[1]), FIT_MINOR(fentry[1]),
113 fentry[0], 114 fentry[0],
114 /* mult by sixteen to get size in bytes */ 115 /* mult by sixteen to get size in bytes */
115 (unsigned)(fentry[1] & 0xffffff) * 16); 116 (unsigned)(fentry[1] & 0xffffff) * 16);
116} 117}
117 118
118 119
@@ -124,31 +125,39 @@ static int dump_fit_entry(char *page, unsigned long *fentry)
124 * OK except for 4kB pages (and no one is going to do that on SN 125 * OK except for 4kB pages (and no one is going to do that on SN
125 * anyway). 126 * anyway).
126 */ 127 */
127static int 128static int proc_fit_show(struct seq_file *m, void *v)
128dump_fit(char *page, unsigned long nasid)
129{ 129{
130 unsigned long nasid = (unsigned long)m->private;
130 unsigned long fentry[2]; 131 unsigned long fentry[2];
131 int index; 132 int index;
132 char *p;
133 133
134 p = page;
135 for (index=0;;index++) { 134 for (index=0;;index++) {
136 BUG_ON(index * 60 > PAGE_SIZE); 135 BUG_ON(index * 60 > PAGE_SIZE);
137 if (get_fit_entry(nasid, index, fentry, NULL, 0)) 136 if (get_fit_entry(nasid, index, fentry, NULL, 0))
138 break; 137 break;
139 p += dump_fit_entry(p, fentry); 138 dump_fit_entry(m, fentry);
140 } 139 }
140 return 0;
141}
141 142
142 return p - page; 143static int proc_fit_open(struct inode *inode, struct file *file)
144{
145 return single_open(file, proc_fit_show, PDE_DATA(inode));
143} 146}
144 147
145static int 148static const struct file_operations proc_fit_fops = {
146dump_version(char *page, unsigned long nasid) 149 .open = proc_fit_open,
150 .read = seq_read,
151 .llseek = seq_lseek,
152 .release = seq_release,
153};
154
155static int proc_version_show(struct seq_file *m, void *v)
147{ 156{
157 unsigned long nasid = (unsigned long)m->private;
148 unsigned long fentry[2]; 158 unsigned long fentry[2];
149 char banner[128]; 159 char banner[128];
150 int index; 160 int index;
151 int len;
152 161
153 for (index = 0; ; index++) { 162 for (index = 0; ; index++) {
154 if (get_fit_entry(nasid, index, fentry, banner, 163 if (get_fit_entry(nasid, index, fentry, banner,
@@ -158,56 +167,24 @@ dump_version(char *page, unsigned long nasid)
158 break; 167 break;
159 } 168 }
160 169
161 len = sprintf(page, "%x.%02x\n", FIT_MAJOR(fentry[1]), 170 seq_printf(m, "%x.%02x\n", FIT_MAJOR(fentry[1]), FIT_MINOR(fentry[1]));
162 FIT_MINOR(fentry[1]));
163 page += len;
164 171
165 if (banner[0]) 172 if (banner[0])
166 len += snprintf(page, PAGE_SIZE-len, "%s\n", banner); 173 seq_printf(m, "%s\n", banner);
167 174 return 0;
168 return len;
169}
170
171/* same as in proc_misc.c */
172static int
173proc_calc_metrics(char *page, char **start, off_t off, int count, int *eof,
174 int len)
175{
176 if (len <= off + count)
177 *eof = 1;
178 *start = page + off;
179 len -= off;
180 if (len > count)
181 len = count;
182 if (len < 0)
183 len = 0;
184 return len;
185} 175}
186 176
187static int 177static int proc_version_open(struct inode *inode, struct file *file)
188read_version_entry(char *page, char **start, off_t off, int count, int *eof,
189 void *data)
190{ 178{
191 int len; 179 return single_open(file, proc_version_show, PDE_DATA(inode));
192
193 /* data holds the NASID of the node */
194 len = dump_version(page, (unsigned long)data);
195 len = proc_calc_metrics(page, start, off, count, eof, len);
196 return len;
197} 180}
198 181
199static int 182static const struct file_operations proc_version_fops = {
200read_fit_entry(char *page, char **start, off_t off, int count, int *eof, 183 .open = proc_version_open,
201 void *data) 184 .read = seq_read,
202{ 185 .llseek = seq_lseek,
203 int len; 186 .release = seq_release,
204 187};
205 /* data holds the NASID of the node */
206 len = dump_fit(page, (unsigned long)data);
207 len = proc_calc_metrics(page, start, off, count, eof, len);
208
209 return len;
210}
211 188
212/* module entry points */ 189/* module entry points */
213int __init prominfo_init(void); 190int __init prominfo_init(void);
@@ -216,58 +193,39 @@ void __exit prominfo_exit(void);
216module_init(prominfo_init); 193module_init(prominfo_init);
217module_exit(prominfo_exit); 194module_exit(prominfo_exit);
218 195
219static struct proc_dir_entry **proc_entries;
220static struct proc_dir_entry *sgi_prominfo_entry;
221
222#define NODE_NAME_LEN 11 196#define NODE_NAME_LEN 11
223 197
224int __init prominfo_init(void) 198int __init prominfo_init(void)
225{ 199{
226 struct proc_dir_entry **entp; 200 struct proc_dir_entry *sgi_prominfo_entry;
227 cnodeid_t cnodeid; 201 cnodeid_t cnodeid;
228 unsigned long nasid;
229 int size;
230 char name[NODE_NAME_LEN];
231 202
232 if (!ia64_platform_is("sn2")) 203 if (!ia64_platform_is("sn2"))
233 return 0; 204 return 0;
234 205
235 size = num_online_nodes() * sizeof(struct proc_dir_entry *);
236 proc_entries = kzalloc(size, GFP_KERNEL);
237 if (!proc_entries)
238 return -ENOMEM;
239
240 sgi_prominfo_entry = proc_mkdir("sgi_prominfo", NULL); 206 sgi_prominfo_entry = proc_mkdir("sgi_prominfo", NULL);
207 if (!sgi_prominfo_entry)
208 return -ENOMEM;
241 209
242 entp = proc_entries;
243 for_each_online_node(cnodeid) { 210 for_each_online_node(cnodeid) {
211 struct proc_dir_entry *dir;
212 unsigned long nasid;
213 char name[NODE_NAME_LEN];
214
244 sprintf(name, "node%d", cnodeid); 215 sprintf(name, "node%d", cnodeid);
245 *entp = proc_mkdir(name, sgi_prominfo_entry); 216 dir = proc_mkdir(name, sgi_prominfo_entry);
217 if (!dir)
218 continue;
246 nasid = cnodeid_to_nasid(cnodeid); 219 nasid = cnodeid_to_nasid(cnodeid);
247 create_proc_read_entry("fit", 0, *entp, read_fit_entry, 220 proc_create_data("fit", 0, dir,
248 (void *)nasid); 221 &proc_fit_fops, (void *)nasid);
249 create_proc_read_entry("version", 0, *entp, 222 proc_create_data("version", 0, dir,
250 read_version_entry, (void *)nasid); 223 &proc_version_fops, (void *)nasid);
251 entp++;
252 } 224 }
253
254 return 0; 225 return 0;
255} 226}
256 227
257void __exit prominfo_exit(void) 228void __exit prominfo_exit(void)
258{ 229{
259 struct proc_dir_entry **entp; 230 remove_proc_subtree("sgi_prominfo", NULL);
260 unsigned int cnodeid;
261 char name[NODE_NAME_LEN];
262
263 entp = proc_entries;
264 for_each_online_node(cnodeid) {
265 remove_proc_entry("fit", *entp);
266 remove_proc_entry("version", *entp);
267 sprintf(name, "node%d", cnodeid);
268 remove_proc_entry(name, sgi_prominfo_entry);
269 entp++;
270 }
271 remove_proc_entry("sgi_prominfo", NULL);
272 kfree(proc_entries);
273} 231}
diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
index aee7c8177b5d..9fb714450e95 100644
--- a/arch/mips/kernel/smtc-proc.c
+++ b/arch/mips/kernel/smtc-proc.c
@@ -16,6 +16,7 @@
16#include <asm/mipsregs.h> 16#include <asm/mipsregs.h>
17#include <asm/cacheflush.h> 17#include <asm/cacheflush.h>
18#include <linux/proc_fs.h> 18#include <linux/proc_fs.h>
19#include <linux/seq_file.h>
19 20
20#include <asm/smtc_proc.h> 21#include <asm/smtc_proc.h>
21 22
@@ -30,51 +31,39 @@ unsigned long selfipis[NR_CPUS];
30 31
31struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS]; 32struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
32 33
33static struct proc_dir_entry *smtc_stats;
34
35atomic_t smtc_fpu_recoveries; 34atomic_t smtc_fpu_recoveries;
36 35
37static int proc_read_smtc(char *page, char **start, off_t off, 36static int smtc_proc_show(struct seq_file *m, void *v)
38 int count, int *eof, void *data)
39{ 37{
40 int totalen = 0;
41 int len;
42 int i; 38 int i;
43 extern unsigned long ebase; 39 extern unsigned long ebase;
44 40
45 len = sprintf(page, "SMTC Status Word: 0x%08x\n", smtc_status); 41 seq_printf(m, "SMTC Status Word: 0x%08x\n", smtc_status);
46 totalen += len; 42 seq_printf(m, "Config7: 0x%08x\n", read_c0_config7());
47 page += len; 43 seq_printf(m, "EBASE: 0x%08lx\n", ebase);
48 len = sprintf(page, "Config7: 0x%08x\n", read_c0_config7()); 44 seq_printf(m, "Counter Interrupts taken per CPU (TC)\n");
49 totalen += len; 45 for (i=0; i < NR_CPUS; i++)
50 page += len; 46 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].timerints);
51 len = sprintf(page, "EBASE: 0x%08lx\n", ebase); 47 seq_printf(m, "Self-IPIs by CPU:\n");
52 totalen += len; 48 for(i = 0; i < NR_CPUS; i++)
53 page += len; 49 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
54 len = sprintf(page, "Counter Interrupts taken per CPU (TC)\n"); 50 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
55 totalen += len; 51 atomic_read(&smtc_fpu_recoveries));
56 page += len; 52 return 0;
57 for (i=0; i < NR_CPUS; i++) { 53}
58 len = sprintf(page, "%d: %ld\n", i, smtc_cpu_stats[i].timerints);
59 totalen += len;
60 page += len;
61 }
62 len = sprintf(page, "Self-IPIs by CPU:\n");
63 totalen += len;
64 page += len;
65 for(i = 0; i < NR_CPUS; i++) {
66 len = sprintf(page, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
67 totalen += len;
68 page += len;
69 }
70 len = sprintf(page, "%d Recoveries of \"stolen\" FPU\n",
71 atomic_read(&smtc_fpu_recoveries));
72 totalen += len;
73 page += len;
74 54
75 return totalen; 55static int smtc_proc_open(struct inode *inode, struct file *file)
56{
57 return single_open(file, smtc_proc_show, NULL);
76} 58}
77 59
60static const struct file_operations smtc_proc_fops = {
61 .open = smtc_proc_open,
62 .read = seq_read,
63 .llseek = seq_lseek,
64 .release = seq_release,
65};
66
78void init_smtc_stats(void) 67void init_smtc_stats(void)
79{ 68{
80 int i; 69 int i;
@@ -86,6 +75,5 @@ void init_smtc_stats(void)
86 75
87 atomic_set(&smtc_fpu_recoveries, 0); 76 atomic_set(&smtc_fpu_recoveries, 0);
88 77
89 smtc_stats = create_proc_read_entry("smtc", 0444, NULL, 78 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
90 proc_read_smtc, NULL);
91} 79}
diff --git a/arch/mips/lasat/picvue_proc.c b/arch/mips/lasat/picvue_proc.c
index c592bc8b8c99..638c5db122c9 100644
--- a/arch/mips/lasat/picvue_proc.c
+++ b/arch/mips/lasat/picvue_proc.c
@@ -58,13 +58,13 @@ static int pvc_line_proc_show(struct seq_file *m, void *v)
58 58
59static int pvc_line_proc_open(struct inode *inode, struct file *file) 59static int pvc_line_proc_open(struct inode *inode, struct file *file)
60{ 60{
61 return single_open(file, pvc_line_proc_show, PDE(inode)->data); 61 return single_open(file, pvc_line_proc_show, PDE_DATA(inode));
62} 62}
63 63
64static ssize_t pvc_line_proc_write(struct file *file, const char __user *buf, 64static ssize_t pvc_line_proc_write(struct file *file, const char __user *buf,
65 size_t count, loff_t *pos) 65 size_t count, loff_t *pos)
66{ 66{
67 int lineno = *(int *)PDE(file_inode(file))->data; 67 int lineno = *(int *)PDE_DATA(file_inode(file));
68 char kbuf[PVC_LINELEN]; 68 char kbuf[PVC_LINELEN];
69 size_t len; 69 size_t len;
70 70
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 3d0346dbccf4..9b973e0af9cb 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -29,6 +29,7 @@
29#include <linux/pfn.h> 29#include <linux/pfn.h>
30#include <linux/hardirq.h> 30#include <linux/hardirq.h>
31#include <linux/gfp.h> 31#include <linux/gfp.h>
32#include <linux/kcore.h>
32 33
33#include <asm/asm-offsets.h> 34#include <asm/asm-offsets.h>
34#include <asm/bootinfo.h> 35#include <asm/bootinfo.h>
diff --git a/arch/mips/pci/ops-pmcmsp.c b/arch/mips/pci/ops-pmcmsp.c
index d0b6f8399b07..4eaab6327369 100644
--- a/arch/mips/pci/ops-pmcmsp.c
+++ b/arch/mips/pci/ops-pmcmsp.c
@@ -53,56 +53,51 @@ static void pci_proc_init(void);
53 53
54/***************************************************************************** 54/*****************************************************************************
55 * 55 *
56 * FUNCTION: read_msp_pci_counts 56 * FUNCTION: show_msp_pci_counts
57 * _________________________________________________________________________ 57 * _________________________________________________________________________
58 * 58 *
59 * DESCRIPTION: Prints the count of how many times each PCI 59 * DESCRIPTION: Prints the count of how many times each PCI
60 * interrupt has asserted. Can be invoked by the 60 * interrupt has asserted. Can be invoked by the
61 * /proc filesystem. 61 * /proc filesystem.
62 * 62 *
63 * INPUTS: page - part of STDOUT calculation 63 * INPUTS: m - synthetic file construction data
64 * off - part of STDOUT calculation 64 * v - iterator
65 * count - part of STDOUT calculation
66 * data - unused
67 * 65 *
68 * OUTPUTS: start - new start location 66 * RETURNS: 0 or error
69 * eof - end of file pointer
70 *
71 * RETURNS: len - STDOUT length
72 * 67 *
73 ****************************************************************************/ 68 ****************************************************************************/
74static int read_msp_pci_counts(char *page, char **start, off_t off, 69static int show_msp_pci_counts(struct seq_file *m, void *v)
75 int count, int *eof, void *data)
76{ 70{
77 int i; 71 int i;
78 int len = 0;
79 unsigned int intcount, total = 0; 72 unsigned int intcount, total = 0;
80 73
81 for (i = 0; i < 32; ++i) { 74 for (i = 0; i < 32; ++i) {
82 intcount = pci_int_count[i]; 75 intcount = pci_int_count[i];
83 if (intcount != 0) { 76 if (intcount != 0) {
84 len += sprintf(page + len, "[%d] = %u\n", i, intcount); 77 seq_printf(m, "[%d] = %u\n", i, intcount);
85 total += intcount; 78 total += intcount;
86 } 79 }
87 } 80 }
88 81
89 len += sprintf(page + len, "total = %u\n", total); 82 seq_printf(m, "total = %u\n", total);
90 if (len <= off+count) 83 return 0;
91 *eof = 1; 84}
92
93 *start = page + off;
94 len -= off;
95 if (len > count)
96 len = count;
97 if (len < 0)
98 len = 0;
99 85
100 return len; 86static int msp_pci_rd_cnt_open(struct inode *inode, struct file *file)
87{
88 return single_open(file, show_msp_pci_counts, NULL);
101} 89}
102 90
91static const struct file_operations msp_pci_rd_cnt_fops = {
92 .open = msp_pci_rd_cnt_open,
93 .read = seq_read,
94 .llseek = seq_lseek,
95 .release = seq_release,
96};
97
103/***************************************************************************** 98/*****************************************************************************
104 * 99 *
105 * FUNCTION: gen_pci_cfg_wr 100 * FUNCTION: gen_pci_cfg_wr_show
106 * _________________________________________________________________________ 101 * _________________________________________________________________________
107 * 102 *
108 * DESCRIPTION: Generates a configuration write cycle for debug purposes. 103 * DESCRIPTION: Generates a configuration write cycle for debug purposes.
@@ -112,37 +107,30 @@ static int read_msp_pci_counts(char *page, char **start, off_t off,
112 * PCI bus. Intent is that this function by invocable from 107 * PCI bus. Intent is that this function by invocable from
113 * the /proc filesystem. 108 * the /proc filesystem.
114 * 109 *
115 * INPUTS: page - part of STDOUT calculation 110 * INPUTS: m - synthetic file construction data
116 * off - part of STDOUT calculation 111 * v - iterator
117 * count - part of STDOUT calculation
118 * data - unused
119 * 112 *
120 * OUTPUTS: start - new start location 113 * RETURNS: 0 or error
121 * eof - end of file pointer
122 *
123 * RETURNS: len - STDOUT length
124 * 114 *
125 ****************************************************************************/ 115 ****************************************************************************/
126static int gen_pci_cfg_wr(char *page, char **start, off_t off, 116static int gen_pci_cfg_wr_show(struct seq_file *m, void *v)
127 int count, int *eof, void *data)
128{ 117{
129 unsigned char where = 0; /* Write to static Device/Vendor ID */ 118 unsigned char where = 0; /* Write to static Device/Vendor ID */
130 unsigned char bus_num = 0; /* Bus 0 */ 119 unsigned char bus_num = 0; /* Bus 0 */
131 unsigned char dev_fn = 0xF; /* Arbitrary device number */ 120 unsigned char dev_fn = 0xF; /* Arbitrary device number */
132 u32 wr_data = 0xFF00AA00; /* Arbitrary data */ 121 u32 wr_data = 0xFF00AA00; /* Arbitrary data */
133 struct msp_pci_regs *preg = (void *)PCI_BASE_REG; 122 struct msp_pci_regs *preg = (void *)PCI_BASE_REG;
134 int len = 0;
135 unsigned long value; 123 unsigned long value;
136 int intr; 124 int intr;
137 125
138 len += sprintf(page + len, "PMC MSP PCI: Beginning\n"); 126 seq_puts(m, "PMC MSP PCI: Beginning\n");
139 127
140 if (proc_init == 0) { 128 if (proc_init == 0) {
141 pci_proc_init(); 129 pci_proc_init();
142 proc_init = ~0; 130 proc_init = ~0;
143 } 131 }
144 132
145 len += sprintf(page + len, "PMC MSP PCI: Before Cfg Wr\n"); 133 seq_puts(m, "PMC MSP PCI: Before Cfg Wr\n");
146 134
147 /* 135 /*
148 * Generate PCI Configuration Write Cycle 136 * Generate PCI Configuration Write Cycle
@@ -168,21 +156,22 @@ static int gen_pci_cfg_wr(char *page, char **start, off_t off,
168 */ 156 */
169 intr = preg->if_status; 157 intr = preg->if_status;
170 158
171 len += sprintf(page + len, "PMC MSP PCI: After Cfg Wr\n"); 159 seq_puts(m, "PMC MSP PCI: After Cfg Wr\n");
172 160 return 0;
173 /* Handle STDOUT calculations */ 161}
174 if (len <= off+count)
175 *eof = 1;
176 *start = page + off;
177 len -= off;
178 if (len > count)
179 len = count;
180 if (len < 0)
181 len = 0;
182 162
183 return len; 163static int gen_pci_cfg_wr_open(struct inode *inode, struct file *file)
164{
165 return single_open(file, gen_pci_cfg_wr_show, NULL);
184} 166}
185 167
168static const struct file_operations gen_pci_cfg_wr_fops = {
169 .open = gen_pci_cfg_wr_open,
170 .read = seq_read,
171 .llseek = seq_lseek,
172 .release = seq_release,
173};
174
186/***************************************************************************** 175/*****************************************************************************
187 * 176 *
188 * FUNCTION: pci_proc_init 177 * FUNCTION: pci_proc_init
@@ -199,10 +188,8 @@ static int gen_pci_cfg_wr(char *page, char **start, off_t off,
199 ****************************************************************************/ 188 ****************************************************************************/
200static void pci_proc_init(void) 189static void pci_proc_init(void)
201{ 190{
202 create_proc_read_entry("pmc_msp_pci_rd_cnt", 0, NULL, 191 proc_create("pmc_msp_pci_rd_cnt", 0, NULL, &msp_pci_rd_cnt_fops);
203 read_msp_pci_counts, NULL); 192 proc_create("pmc_msp_pci_cfg_wr", 0, NULL, &gen_pci_cfg_wr_fops);
204 create_proc_read_entry("pmc_msp_pci_cfg_wr", 0, NULL,
205 gen_pci_cfg_wr, NULL);
206} 193}
207#endif /* CONFIG_PROC_FS && PCI_COUNTERS */ 194#endif /* CONFIG_PROC_FS && PCI_COUNTERS */
208 195
diff --git a/arch/mips/sibyte/sb1250/bus_watcher.c b/arch/mips/sibyte/sb1250/bus_watcher.c
index e651105b3f0b..cb1e3cb37d70 100644
--- a/arch/mips/sibyte/sb1250/bus_watcher.c
+++ b/arch/mips/sibyte/sb1250/bus_watcher.c
@@ -30,6 +30,7 @@
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/sched.h> 31#include <linux/sched.h>
32#include <linux/proc_fs.h> 32#include <linux/proc_fs.h>
33#include <linux/seq_file.h>
33#include <asm/io.h> 34#include <asm/io.h>
34 35
35#include <asm/sibyte/sb1250.h> 36#include <asm/sibyte/sb1250.h>
@@ -99,63 +100,60 @@ void check_bus_watcher(void)
99 printk("Bus watcher indicates no error\n"); 100 printk("Bus watcher indicates no error\n");
100} 101}
101 102
102static int bw_print_buffer(char *page, struct bw_stats_struct *stats) 103#ifdef CONFIG_PROC_FS
104
105/* For simplicity, I want to assume a single read is required each
106 time */
107static int bw_proc_show(struct seq_file *m, void *v)
103{ 108{
104 int len; 109 struct bw_stats_struct *stats = m->private;
105 110
106 len = sprintf(page, "SiByte Bus Watcher statistics\n"); 111 seq_puts(m, "SiByte Bus Watcher statistics\n");
107 len += sprintf(page+len, "-----------------------------\n"); 112 seq_puts(m, "-----------------------------\n");
108 len += sprintf(page+len, "L2-d-cor %8ld\nL2-d-bad %8ld\n", 113 seq_printf(m, "L2-d-cor %8ld\nL2-d-bad %8ld\n",
109 stats->l2_cor_d, stats->l2_bad_d); 114 stats->l2_cor_d, stats->l2_bad_d);
110 len += sprintf(page+len, "L2-t-cor %8ld\nL2-t-bad %8ld\n", 115 seq_printf(m, "L2-t-cor %8ld\nL2-t-bad %8ld\n",
111 stats->l2_cor_t, stats->l2_bad_t); 116 stats->l2_cor_t, stats->l2_bad_t);
112 len += sprintf(page+len, "MC-d-cor %8ld\nMC-d-bad %8ld\n", 117 seq_printf(m, "MC-d-cor %8ld\nMC-d-bad %8ld\n",
113 stats->mem_cor_d, stats->mem_bad_d); 118 stats->mem_cor_d, stats->mem_bad_d);
114 len += sprintf(page+len, "IO-err %8ld\n", stats->bus_error); 119 seq_printf(m, "IO-err %8ld\n", stats->bus_error);
115 len += sprintf(page+len, "\nLast recorded signature:\n"); 120 seq_puts(m, "\nLast recorded signature:\n");
116 len += sprintf(page+len, "Request %02x from %d, answered by %d with Dcode %d\n", 121 seq_printf(m, "Request %02x from %d, answered by %d with Dcode %d\n",
117 (unsigned int)(G_SCD_BERR_TID(stats->status) & 0x3f), 122 (unsigned int)(G_SCD_BERR_TID(stats->status) & 0x3f),
118 (int)(G_SCD_BERR_TID(stats->status) >> 6), 123 (int)(G_SCD_BERR_TID(stats->status) >> 6),
119 (int)G_SCD_BERR_RID(stats->status), 124 (int)G_SCD_BERR_RID(stats->status),
120 (int)G_SCD_BERR_DCODE(stats->status)); 125 (int)G_SCD_BERR_DCODE(stats->status));
121 /* XXXKW indicate multiple errors between printings, or stats 126 /* XXXKW indicate multiple errors between printings, or stats
122 collection (or both)? */ 127 collection (or both)? */
123 if (stats->status & M_SCD_BERR_MULTERRS) 128 if (stats->status & M_SCD_BERR_MULTERRS)
124 len += sprintf(page+len, "Multiple errors observed since last check.\n"); 129 seq_puts(m, "Multiple errors observed since last check.\n");
125 if (stats->status_printed) { 130 if (stats->status_printed) {
126 len += sprintf(page+len, "(no change since last printing)\n"); 131 seq_puts(m, "(no change since last printing)\n");
127 } else { 132 } else {
128 stats->status_printed = 1; 133 stats->status_printed = 1;
129 } 134 }
130 135
131 return len; 136 return 0;
132} 137}
133 138
134#ifdef CONFIG_PROC_FS 139static int bw_proc_open(struct inode *inode, struct file *file)
135
136/* For simplicity, I want to assume a single read is required each
137 time */
138static int bw_read_proc(char *page, char **start, off_t off,
139 int count, int *eof, void *data)
140{ 140{
141 int len; 141 return single_open(file, bw_proc_show, PDE_DATA(inode));
142
143 if (off == 0) {
144 len = bw_print_buffer(page, data);
145 *start = page;
146 } else {
147 len = 0;
148 *eof = 1;
149 }
150 return len;
151} 142}
152 143
144static const struct file_operations bw_proc_fops = {
145 .open = bw_proc_open,
146 .read = seq_read,
147 .llseek = seq_lseek,
148 .release = seq_release,
149};
150
153static void create_proc_decoder(struct bw_stats_struct *stats) 151static void create_proc_decoder(struct bw_stats_struct *stats)
154{ 152{
155 struct proc_dir_entry *ent; 153 struct proc_dir_entry *ent;
156 154
157 ent = create_proc_read_entry("bus_watcher", S_IWUSR | S_IRUGO, NULL, 155 ent = proc_create_data("bus_watcher", S_IWUSR | S_IRUGO, NULL,
158 bw_read_proc, stats); 156 &bw_proc_fops, stats);
159 if (!ent) { 157 if (!ent) {
160 printk(KERN_INFO "Unable to initialize bus_watcher /proc entry\n"); 158 printk(KERN_INFO "Unable to initialize bus_watcher /proc entry\n");
161 return; 159 return;
@@ -210,11 +208,6 @@ static irqreturn_t sibyte_bw_int(int irq, void *data)
210 stats->bus_error += G_SCD_MEM_BUSERR(cntr); 208 stats->bus_error += G_SCD_MEM_BUSERR(cntr);
211 csr_out32(0, IOADDR(A_BUS_MEM_IO_ERRORS)); 209 csr_out32(0, IOADDR(A_BUS_MEM_IO_ERRORS));
212 210
213#ifndef CONFIG_PROC_FS
214 bw_print_buffer(bw_buf, stats);
215 printk(bw_buf);
216#endif
217
218 return IRQ_HANDLED; 211 return IRQ_HANDLED;
219} 212}
220 213
diff --git a/arch/parisc/kernel/pdc_chassis.c b/arch/parisc/kernel/pdc_chassis.c
index d47ba1aa8253..8fa314fbfb18 100644
--- a/arch/parisc/kernel/pdc_chassis.c
+++ b/arch/parisc/kernel/pdc_chassis.c
@@ -30,11 +30,13 @@
30#endif 30#endif
31 31
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/module.h>
33#include <linux/kernel.h> 34#include <linux/kernel.h>
34#include <linux/reboot.h> 35#include <linux/reboot.h>
35#include <linux/notifier.h> 36#include <linux/notifier.h>
36#include <linux/cache.h> 37#include <linux/cache.h>
37#include <linux/proc_fs.h> 38#include <linux/proc_fs.h>
39#include <linux/seq_file.h>
38 40
39#include <asm/pdc_chassis.h> 41#include <asm/pdc_chassis.h>
40#include <asm/processor.h> 42#include <asm/processor.h>
@@ -244,38 +246,38 @@ int pdc_chassis_send_status(int message)
244 246
245#ifdef CONFIG_PDC_CHASSIS_WARN 247#ifdef CONFIG_PDC_CHASSIS_WARN
246#ifdef CONFIG_PROC_FS 248#ifdef CONFIG_PROC_FS
247static int pdc_chassis_warn_pread(char *page, char **start, off_t off, 249static int pdc_chassis_warn_show(struct seq_file *m, void *v)
248 int count, int *eof, void *data)
249{ 250{
250 char *out = page;
251 int len, ret;
252 unsigned long warn; 251 unsigned long warn;
253 u32 warnreg; 252 u32 warnreg;
254 253
255 ret = pdc_chassis_warn(&warn); 254 if (pdc_chassis_warn(&warn) != PDC_OK)
256 if (ret != PDC_OK)
257 return -EIO; 255 return -EIO;
258 256
259 warnreg = (warn & 0xFFFFFFFF); 257 warnreg = (warn & 0xFFFFFFFF);
260 258
261 if ((warnreg >> 24) & 0xFF) 259 if ((warnreg >> 24) & 0xFF)
262 out += sprintf(out, "Chassis component failure! (eg fan or PSU): 0x%.2x\n", ((warnreg >> 24) & 0xFF)); 260 seq_printf(m, "Chassis component failure! (eg fan or PSU): 0x%.2x\n",
263 261 (warnreg >> 24) & 0xFF);
264 out += sprintf(out, "Battery: %s\n", (warnreg & 0x04) ? "Low!" : "OK"); 262
265 out += sprintf(out, "Temp low: %s\n", (warnreg & 0x02) ? "Exceeded!" : "OK"); 263 seq_printf(m, "Battery: %s\n", (warnreg & 0x04) ? "Low!" : "OK");
266 out += sprintf(out, "Temp mid: %s\n", (warnreg & 0x01) ? "Exceeded!" : "OK"); 264 seq_printf(m, "Temp low: %s\n", (warnreg & 0x02) ? "Exceeded!" : "OK");
267 265 seq_printf(m, "Temp mid: %s\n", (warnreg & 0x01) ? "Exceeded!" : "OK");
268 len = out - page - off; 266 return 0;
269 if (len < count) { 267}
270 *eof = 1; 268
271 if (len <= 0) return 0; 269static int pdc_chassis_warn_open(struct inode *inode, struct file *file)
272 } else { 270{
273 len = count; 271 return single_open(file, pdc_chassis_warn_show, NULL);
274 }
275 *start = page + off;
276 return len;
277} 272}
278 273
274static const struct file_operations pdc_chassis_warn_fops = {
275 .open = pdc_chassis_warn_open,
276 .read = seq_read,
277 .llseek = seq_lseek,
278 .release = seq_release,
279};
280
279static int __init pdc_chassis_create_procfs(void) 281static int __init pdc_chassis_create_procfs(void)
280{ 282{
281 unsigned long test; 283 unsigned long test;
@@ -290,8 +292,7 @@ static int __init pdc_chassis_create_procfs(void)
290 292
291 printk(KERN_INFO "Enabling PDC chassis warnings support v%s\n", 293 printk(KERN_INFO "Enabling PDC chassis warnings support v%s\n",
292 PDC_CHASSIS_VER); 294 PDC_CHASSIS_VER);
293 create_proc_read_entry("chassis", 0400, NULL, pdc_chassis_warn_pread, 295 proc_create("chassis", 0400, NULL, &pdc_chassis_warn_fops);
294 NULL);
295 return 0; 296 return 0;
296} 297}
297 298
diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c
index f5725bce9ed2..801a757c3630 100644
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -41,8 +41,6 @@
41 41
42/* #define LPARCFG_DEBUG */ 42/* #define LPARCFG_DEBUG */
43 43
44static struct proc_dir_entry *proc_ppc64_lparcfg;
45
46/* 44/*
47 * Track sum of all purrs across all processors. This is used to further 45 * Track sum of all purrs across all processors. This is used to further
48 * calculate usage values by different applications 46 * calculate usage values by different applications
@@ -688,27 +686,22 @@ static const struct file_operations lparcfg_fops = {
688 686
689static int __init lparcfg_init(void) 687static int __init lparcfg_init(void)
690{ 688{
691 struct proc_dir_entry *ent;
692 umode_t mode = S_IRUSR | S_IRGRP | S_IROTH; 689 umode_t mode = S_IRUSR | S_IRGRP | S_IROTH;
693 690
694 /* Allow writing if we have FW_FEATURE_SPLPAR */ 691 /* Allow writing if we have FW_FEATURE_SPLPAR */
695 if (firmware_has_feature(FW_FEATURE_SPLPAR)) 692 if (firmware_has_feature(FW_FEATURE_SPLPAR))
696 mode |= S_IWUSR; 693 mode |= S_IWUSR;
697 694
698 ent = proc_create("powerpc/lparcfg", mode, NULL, &lparcfg_fops); 695 if (!proc_create("powerpc/lparcfg", mode, NULL, &lparcfg_fops)) {
699 if (!ent) {
700 printk(KERN_ERR "Failed to create powerpc/lparcfg\n"); 696 printk(KERN_ERR "Failed to create powerpc/lparcfg\n");
701 return -EIO; 697 return -EIO;
702 } 698 }
703
704 proc_ppc64_lparcfg = ent;
705 return 0; 699 return 0;
706} 700}
707 701
708static void __exit lparcfg_cleanup(void) 702static void __exit lparcfg_cleanup(void)
709{ 703{
710 if (proc_ppc64_lparcfg) 704 remove_proc_subtree("powerpc/lparcfg", NULL);
711 remove_proc_entry("lparcfg", proc_ppc64_lparcfg->parent);
712} 705}
713 706
714module_init(lparcfg_init); 707module_init(lparcfg_init);
diff --git a/arch/powerpc/kernel/proc_powerpc.c b/arch/powerpc/kernel/proc_powerpc.c
index f19d0bdc3241..feb8580fdc84 100644
--- a/arch/powerpc/kernel/proc_powerpc.c
+++ b/arch/powerpc/kernel/proc_powerpc.c
@@ -32,8 +32,6 @@
32static loff_t page_map_seek( struct file *file, loff_t off, int whence) 32static loff_t page_map_seek( struct file *file, loff_t off, int whence)
33{ 33{
34 loff_t new; 34 loff_t new;
35 struct proc_dir_entry *dp = PDE(file_inode(file));
36
37 switch(whence) { 35 switch(whence) {
38 case 0: 36 case 0:
39 new = off; 37 new = off;
@@ -42,12 +40,12 @@ static loff_t page_map_seek( struct file *file, loff_t off, int whence)
42 new = file->f_pos + off; 40 new = file->f_pos + off;
43 break; 41 break;
44 case 2: 42 case 2:
45 new = dp->size + off; 43 new = PAGE_SIZE + off;
46 break; 44 break;
47 default: 45 default:
48 return -EINVAL; 46 return -EINVAL;
49 } 47 }
50 if ( new < 0 || new > dp->size ) 48 if ( new < 0 || new > PAGE_SIZE )
51 return -EINVAL; 49 return -EINVAL;
52 return (file->f_pos = new); 50 return (file->f_pos = new);
53} 51}
@@ -55,19 +53,18 @@ static loff_t page_map_seek( struct file *file, loff_t off, int whence)
55static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes, 53static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes,
56 loff_t *ppos) 54 loff_t *ppos)
57{ 55{
58 struct proc_dir_entry *dp = PDE(file_inode(file)); 56 return simple_read_from_buffer(buf, nbytes, ppos,
59 return simple_read_from_buffer(buf, nbytes, ppos, dp->data, dp->size); 57 PDE_DATA(file_inode(file)), PAGE_SIZE);
60} 58}
61 59
62static int page_map_mmap( struct file *file, struct vm_area_struct *vma ) 60static int page_map_mmap( struct file *file, struct vm_area_struct *vma )
63{ 61{
64 struct proc_dir_entry *dp = PDE(file_inode(file)); 62 if ((vma->vm_end - vma->vm_start) > PAGE_SIZE)
65
66 if ((vma->vm_end - vma->vm_start) > dp->size)
67 return -EINVAL; 63 return -EINVAL;
68 64
69 remap_pfn_range(vma, vma->vm_start, __pa(dp->data) >> PAGE_SHIFT, 65 remap_pfn_range(vma, vma->vm_start,
70 dp->size, vma->vm_page_prot); 66 __pa(PDE_DATA(file_inode(file))) >> PAGE_SHIFT,
67 PAGE_SIZE, vma->vm_page_prot);
71 return 0; 68 return 0;
72} 69}
73 70
@@ -86,7 +83,7 @@ static int __init proc_ppc64_init(void)
86 &page_map_fops, vdso_data); 83 &page_map_fops, vdso_data);
87 if (!pde) 84 if (!pde)
88 return 1; 85 return 1;
89 pde->size = PAGE_SIZE; 86 proc_set_size(pde, PAGE_SIZE);
90 87
91 return 0; 88 return 0;
92} 89}
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index c642f0132988..5b770262c673 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -102,9 +102,10 @@ static struct kmem_cache *flash_block_cache = NULL;
102 102
103#define FLASH_BLOCK_LIST_VERSION (1UL) 103#define FLASH_BLOCK_LIST_VERSION (1UL)
104 104
105/* Local copy of the flash block list. 105/*
106 * We only allow one open of the flash proc file and create this 106 * Local copy of the flash block list.
107 * list as we go. The rtas_firmware_flash_list varable will be 107 *
108 * The rtas_firmware_flash_list varable will be
108 * set once the data is fully read. 109 * set once the data is fully read.
109 * 110 *
110 * For convenience as we build the list we use virtual addrs, 111 * For convenience as we build the list we use virtual addrs,
@@ -125,23 +126,23 @@ struct rtas_update_flash_t
125struct rtas_manage_flash_t 126struct rtas_manage_flash_t
126{ 127{
127 int status; /* Returned status */ 128 int status; /* Returned status */
128 unsigned int op; /* Reject or commit image */
129}; 129};
130 130
131/* Status int must be first member of struct */ 131/* Status int must be first member of struct */
132struct rtas_validate_flash_t 132struct rtas_validate_flash_t
133{ 133{
134 int status; /* Returned status */ 134 int status; /* Returned status */
135 char buf[VALIDATE_BUF_SIZE]; /* Candidate image buffer */ 135 char *buf; /* Candidate image buffer */
136 unsigned int buf_size; /* Size of image buf */ 136 unsigned int buf_size; /* Size of image buf */
137 unsigned int update_results; /* Update results token */ 137 unsigned int update_results; /* Update results token */
138}; 138};
139 139
140static DEFINE_SPINLOCK(flash_file_open_lock); 140static struct rtas_update_flash_t rtas_update_flash_data;
141static struct proc_dir_entry *firmware_flash_pde; 141static struct rtas_manage_flash_t rtas_manage_flash_data;
142static struct proc_dir_entry *firmware_update_pde; 142static struct rtas_validate_flash_t rtas_validate_flash_data;
143static struct proc_dir_entry *validate_pde; 143static DEFINE_MUTEX(rtas_update_flash_mutex);
144static struct proc_dir_entry *manage_pde; 144static DEFINE_MUTEX(rtas_manage_flash_mutex);
145static DEFINE_MUTEX(rtas_validate_flash_mutex);
145 146
146/* Do simple sanity checks on the flash image. */ 147/* Do simple sanity checks on the flash image. */
147static int flash_list_valid(struct flash_block_list *flist) 148static int flash_list_valid(struct flash_block_list *flist)
@@ -191,10 +192,10 @@ static void free_flash_list(struct flash_block_list *f)
191 192
192static int rtas_flash_release(struct inode *inode, struct file *file) 193static int rtas_flash_release(struct inode *inode, struct file *file)
193{ 194{
194 struct proc_dir_entry *dp = PDE(file_inode(file)); 195 struct rtas_update_flash_t *const uf = &rtas_update_flash_data;
195 struct rtas_update_flash_t *uf; 196
196 197 mutex_lock(&rtas_update_flash_mutex);
197 uf = (struct rtas_update_flash_t *) dp->data; 198
198 if (uf->flist) { 199 if (uf->flist) {
199 /* File was opened in write mode for a new flash attempt */ 200 /* File was opened in write mode for a new flash attempt */
200 /* Clear saved list */ 201 /* Clear saved list */
@@ -214,13 +215,14 @@ static int rtas_flash_release(struct inode *inode, struct file *file)
214 uf->flist = NULL; 215 uf->flist = NULL;
215 } 216 }
216 217
217 atomic_dec(&dp->count); 218 mutex_unlock(&rtas_update_flash_mutex);
218 return 0; 219 return 0;
219} 220}
220 221
221static void get_flash_status_msg(int status, char *buf) 222static size_t get_flash_status_msg(int status, char *buf)
222{ 223{
223 char *msg; 224 const char *msg;
225 size_t len;
224 226
225 switch (status) { 227 switch (status) {
226 case FLASH_AUTH: 228 case FLASH_AUTH:
@@ -242,34 +244,51 @@ static void get_flash_status_msg(int status, char *buf)
242 msg = "ready: firmware image ready for flash on reboot\n"; 244 msg = "ready: firmware image ready for flash on reboot\n";
243 break; 245 break;
244 default: 246 default:
245 sprintf(buf, "error: unexpected status value %d\n", status); 247 return sprintf(buf, "error: unexpected status value %d\n",
246 return; 248 status);
247 } 249 }
248 250
249 strcpy(buf, msg); 251 len = strlen(msg);
252 memcpy(buf, msg, len + 1);
253 return len;
250} 254}
251 255
252/* Reading the proc file will show status (not the firmware contents) */ 256/* Reading the proc file will show status (not the firmware contents) */
253static ssize_t rtas_flash_read(struct file *file, char __user *buf, 257static ssize_t rtas_flash_read_msg(struct file *file, char __user *buf,
254 size_t count, loff_t *ppos) 258 size_t count, loff_t *ppos)
255{ 259{
256 struct proc_dir_entry *dp = PDE(file_inode(file)); 260 struct rtas_update_flash_t *const uf = &rtas_update_flash_data;
257 struct rtas_update_flash_t *uf;
258 char msg[RTAS_MSG_MAXLEN]; 261 char msg[RTAS_MSG_MAXLEN];
262 size_t len;
263 int status;
259 264
260 uf = dp->data; 265 mutex_lock(&rtas_update_flash_mutex);
266 status = uf->status;
267 mutex_unlock(&rtas_update_flash_mutex);
261 268
262 if (!strcmp(dp->name, FIRMWARE_FLASH_NAME)) { 269 /* Read as text message */
263 get_flash_status_msg(uf->status, msg); 270 len = get_flash_status_msg(status, msg);
264 } else { /* FIRMWARE_UPDATE_NAME */ 271 return simple_read_from_buffer(buf, count, ppos, msg, len);
265 sprintf(msg, "%d\n", uf->status); 272}
266 } 273
274static ssize_t rtas_flash_read_num(struct file *file, char __user *buf,
275 size_t count, loff_t *ppos)
276{
277 struct rtas_update_flash_t *const uf = &rtas_update_flash_data;
278 char msg[RTAS_MSG_MAXLEN];
279 int status;
267 280
281 mutex_lock(&rtas_update_flash_mutex);
282 status = uf->status;
283 mutex_unlock(&rtas_update_flash_mutex);
284
285 /* Read as number */
286 sprintf(msg, "%d\n", status);
268 return simple_read_from_buffer(buf, count, ppos, msg, strlen(msg)); 287 return simple_read_from_buffer(buf, count, ppos, msg, strlen(msg));
269} 288}
270 289
271/* constructor for flash_block_cache */ 290/* constructor for flash_block_cache */
272void rtas_block_ctor(void *ptr) 291static void rtas_block_ctor(void *ptr)
273{ 292{
274 memset(ptr, 0, RTAS_BLK_SIZE); 293 memset(ptr, 0, RTAS_BLK_SIZE);
275} 294}
@@ -282,16 +301,15 @@ void rtas_block_ctor(void *ptr)
282static ssize_t rtas_flash_write(struct file *file, const char __user *buffer, 301static ssize_t rtas_flash_write(struct file *file, const char __user *buffer,
283 size_t count, loff_t *off) 302 size_t count, loff_t *off)
284{ 303{
285 struct proc_dir_entry *dp = PDE(file_inode(file)); 304 struct rtas_update_flash_t *const uf = &rtas_update_flash_data;
286 struct rtas_update_flash_t *uf;
287 char *p; 305 char *p;
288 int next_free; 306 int next_free, rc;
289 struct flash_block_list *fl; 307 struct flash_block_list *fl;
290 308
291 uf = (struct rtas_update_flash_t *) dp->data; 309 mutex_lock(&rtas_update_flash_mutex);
292 310
293 if (uf->status == FLASH_AUTH || count == 0) 311 if (uf->status == FLASH_AUTH || count == 0)
294 return count; /* discard data */ 312 goto out; /* discard data */
295 313
296 /* In the case that the image is not ready for flashing, the memory 314 /* In the case that the image is not ready for flashing, the memory
297 * allocated for the block list will be freed upon the release of the 315 * allocated for the block list will be freed upon the release of the
@@ -300,7 +318,7 @@ static ssize_t rtas_flash_write(struct file *file, const char __user *buffer,
300 if (uf->flist == NULL) { 318 if (uf->flist == NULL) {
301 uf->flist = kmem_cache_alloc(flash_block_cache, GFP_KERNEL); 319 uf->flist = kmem_cache_alloc(flash_block_cache, GFP_KERNEL);
302 if (!uf->flist) 320 if (!uf->flist)
303 return -ENOMEM; 321 goto nomem;
304 } 322 }
305 323
306 fl = uf->flist; 324 fl = uf->flist;
@@ -311,7 +329,7 @@ static ssize_t rtas_flash_write(struct file *file, const char __user *buffer,
311 /* Need to allocate another block_list */ 329 /* Need to allocate another block_list */
312 fl->next = kmem_cache_alloc(flash_block_cache, GFP_KERNEL); 330 fl->next = kmem_cache_alloc(flash_block_cache, GFP_KERNEL);
313 if (!fl->next) 331 if (!fl->next)
314 return -ENOMEM; 332 goto nomem;
315 fl = fl->next; 333 fl = fl->next;
316 next_free = 0; 334 next_free = 0;
317 } 335 }
@@ -320,52 +338,37 @@ static ssize_t rtas_flash_write(struct file *file, const char __user *buffer,
320 count = RTAS_BLK_SIZE; 338 count = RTAS_BLK_SIZE;
321 p = kmem_cache_alloc(flash_block_cache, GFP_KERNEL); 339 p = kmem_cache_alloc(flash_block_cache, GFP_KERNEL);
322 if (!p) 340 if (!p)
323 return -ENOMEM; 341 goto nomem;
324 342
325 if(copy_from_user(p, buffer, count)) { 343 if(copy_from_user(p, buffer, count)) {
326 kmem_cache_free(flash_block_cache, p); 344 kmem_cache_free(flash_block_cache, p);
327 return -EFAULT; 345 rc = -EFAULT;
346 goto error;
328 } 347 }
329 fl->blocks[next_free].data = p; 348 fl->blocks[next_free].data = p;
330 fl->blocks[next_free].length = count; 349 fl->blocks[next_free].length = count;
331 fl->num_blocks++; 350 fl->num_blocks++;
332 351out:
352 mutex_unlock(&rtas_update_flash_mutex);
333 return count; 353 return count;
334}
335
336static int rtas_excl_open(struct inode *inode, struct file *file)
337{
338 struct proc_dir_entry *dp = PDE(inode);
339
340 /* Enforce exclusive open with use count of PDE */
341 spin_lock(&flash_file_open_lock);
342 if (atomic_read(&dp->count) > 2) {
343 spin_unlock(&flash_file_open_lock);
344 return -EBUSY;
345 }
346
347 atomic_inc(&dp->count);
348 spin_unlock(&flash_file_open_lock);
349
350 return 0;
351}
352
353static int rtas_excl_release(struct inode *inode, struct file *file)
354{
355 struct proc_dir_entry *dp = PDE(inode);
356 354
357 atomic_dec(&dp->count); 355nomem:
358 356 rc = -ENOMEM;
359 return 0; 357error:
358 mutex_unlock(&rtas_update_flash_mutex);
359 return rc;
360} 360}
361 361
362static void manage_flash(struct rtas_manage_flash_t *args_buf) 362/*
363 * Flash management routines.
364 */
365static void manage_flash(struct rtas_manage_flash_t *args_buf, unsigned int op)
363{ 366{
364 s32 rc; 367 s32 rc;
365 368
366 do { 369 do {
367 rc = rtas_call(rtas_token("ibm,manage-flash-image"), 1, 370 rc = rtas_call(rtas_token("ibm,manage-flash-image"), 1, 1,
368 1, NULL, args_buf->op); 371 NULL, op);
369 } while (rtas_busy_delay(rc)); 372 } while (rtas_busy_delay(rc));
370 373
371 args_buf->status = rc; 374 args_buf->status = rc;
@@ -374,55 +377,62 @@ static void manage_flash(struct rtas_manage_flash_t *args_buf)
374static ssize_t manage_flash_read(struct file *file, char __user *buf, 377static ssize_t manage_flash_read(struct file *file, char __user *buf,
375 size_t count, loff_t *ppos) 378 size_t count, loff_t *ppos)
376{ 379{
377 struct proc_dir_entry *dp = PDE(file_inode(file)); 380 struct rtas_manage_flash_t *const args_buf = &rtas_manage_flash_data;
378 struct rtas_manage_flash_t *args_buf;
379 char msg[RTAS_MSG_MAXLEN]; 381 char msg[RTAS_MSG_MAXLEN];
380 int msglen; 382 int msglen, status;
381 383
382 args_buf = dp->data; 384 mutex_lock(&rtas_manage_flash_mutex);
383 if (args_buf == NULL) 385 status = args_buf->status;
384 return 0; 386 mutex_unlock(&rtas_manage_flash_mutex);
385
386 msglen = sprintf(msg, "%d\n", args_buf->status);
387 387
388 msglen = sprintf(msg, "%d\n", status);
388 return simple_read_from_buffer(buf, count, ppos, msg, msglen); 389 return simple_read_from_buffer(buf, count, ppos, msg, msglen);
389} 390}
390 391
391static ssize_t manage_flash_write(struct file *file, const char __user *buf, 392static ssize_t manage_flash_write(struct file *file, const char __user *buf,
392 size_t count, loff_t *off) 393 size_t count, loff_t *off)
393{ 394{
394 struct proc_dir_entry *dp = PDE(file_inode(file)); 395 struct rtas_manage_flash_t *const args_buf = &rtas_manage_flash_data;
395 struct rtas_manage_flash_t *args_buf; 396 static const char reject_str[] = "0";
396 const char reject_str[] = "0"; 397 static const char commit_str[] = "1";
397 const char commit_str[] = "1";
398 char stkbuf[10]; 398 char stkbuf[10];
399 int op; 399 int op, rc;
400
401 mutex_lock(&rtas_manage_flash_mutex);
400 402
401 args_buf = (struct rtas_manage_flash_t *) dp->data;
402 if ((args_buf->status == MANAGE_AUTH) || (count == 0)) 403 if ((args_buf->status == MANAGE_AUTH) || (count == 0))
403 return count; 404 goto out;
404 405
405 op = -1; 406 op = -1;
406 if (buf) { 407 if (buf) {
407 if (count > 9) count = 9; 408 if (count > 9) count = 9;
408 if (copy_from_user (stkbuf, buf, count)) { 409 rc = -EFAULT;
409 return -EFAULT; 410 if (copy_from_user (stkbuf, buf, count))
410 } 411 goto error;
411 if (strncmp(stkbuf, reject_str, strlen(reject_str)) == 0) 412 if (strncmp(stkbuf, reject_str, strlen(reject_str)) == 0)
412 op = RTAS_REJECT_TMP_IMG; 413 op = RTAS_REJECT_TMP_IMG;
413 else if (strncmp(stkbuf, commit_str, strlen(commit_str)) == 0) 414 else if (strncmp(stkbuf, commit_str, strlen(commit_str)) == 0)
414 op = RTAS_COMMIT_TMP_IMG; 415 op = RTAS_COMMIT_TMP_IMG;
415 } 416 }
416 417
417 if (op == -1) /* buf is empty, or contains invalid string */ 418 if (op == -1) { /* buf is empty, or contains invalid string */
418 return -EINVAL; 419 rc = -EINVAL;
419 420 goto error;
420 args_buf->op = op; 421 }
421 manage_flash(args_buf);
422 422
423 manage_flash(args_buf, op);
424out:
425 mutex_unlock(&rtas_manage_flash_mutex);
423 return count; 426 return count;
427
428error:
429 mutex_unlock(&rtas_manage_flash_mutex);
430 return rc;
424} 431}
425 432
433/*
434 * Validation routines.
435 */
426static void validate_flash(struct rtas_validate_flash_t *args_buf) 436static void validate_flash(struct rtas_validate_flash_t *args_buf)
427{ 437{
428 int token = rtas_token("ibm,validate-flash-image"); 438 int token = rtas_token("ibm,validate-flash-image");
@@ -462,14 +472,14 @@ static int get_validate_flash_msg(struct rtas_validate_flash_t *args_buf,
462static ssize_t validate_flash_read(struct file *file, char __user *buf, 472static ssize_t validate_flash_read(struct file *file, char __user *buf,
463 size_t count, loff_t *ppos) 473 size_t count, loff_t *ppos)
464{ 474{
465 struct proc_dir_entry *dp = PDE(file_inode(file)); 475 struct rtas_validate_flash_t *const args_buf =
466 struct rtas_validate_flash_t *args_buf; 476 &rtas_validate_flash_data;
467 char msg[RTAS_MSG_MAXLEN]; 477 char msg[RTAS_MSG_MAXLEN];
468 int msglen; 478 int msglen;
469 479
470 args_buf = dp->data; 480 mutex_lock(&rtas_validate_flash_mutex);
471
472 msglen = get_validate_flash_msg(args_buf, msg); 481 msglen = get_validate_flash_msg(args_buf, msg);
482 mutex_unlock(&rtas_validate_flash_mutex);
473 483
474 return simple_read_from_buffer(buf, count, ppos, msg, msglen); 484 return simple_read_from_buffer(buf, count, ppos, msg, msglen);
475} 485}
@@ -477,24 +487,18 @@ static ssize_t validate_flash_read(struct file *file, char __user *buf,
477static ssize_t validate_flash_write(struct file *file, const char __user *buf, 487static ssize_t validate_flash_write(struct file *file, const char __user *buf,
478 size_t count, loff_t *off) 488 size_t count, loff_t *off)
479{ 489{
480 struct proc_dir_entry *dp = PDE(file_inode(file)); 490 struct rtas_validate_flash_t *const args_buf =
481 struct rtas_validate_flash_t *args_buf; 491 &rtas_validate_flash_data;
482 int rc; 492 int rc;
483 493
484 args_buf = (struct rtas_validate_flash_t *) dp->data; 494 mutex_lock(&rtas_validate_flash_mutex);
485
486 if (dp->data == NULL) {
487 dp->data = kmalloc(sizeof(struct rtas_validate_flash_t),
488 GFP_KERNEL);
489 if (dp->data == NULL)
490 return -ENOMEM;
491 }
492 495
493 /* We are only interested in the first 4K of the 496 /* We are only interested in the first 4K of the
494 * candidate image */ 497 * candidate image */
495 if ((*off >= VALIDATE_BUF_SIZE) || 498 if ((*off >= VALIDATE_BUF_SIZE) ||
496 (args_buf->status == VALIDATE_AUTH)) { 499 (args_buf->status == VALIDATE_AUTH)) {
497 *off += count; 500 *off += count;
501 mutex_unlock(&rtas_validate_flash_mutex);
498 return count; 502 return count;
499 } 503 }
500 504
@@ -517,31 +521,29 @@ static ssize_t validate_flash_write(struct file *file, const char __user *buf,
517 *off += count; 521 *off += count;
518 rc = count; 522 rc = count;
519done: 523done:
520 if (rc < 0) { 524 mutex_unlock(&rtas_validate_flash_mutex);
521 kfree(dp->data);
522 dp->data = NULL;
523 }
524 return rc; 525 return rc;
525} 526}
526 527
527static int validate_flash_release(struct inode *inode, struct file *file) 528static int validate_flash_release(struct inode *inode, struct file *file)
528{ 529{
529 struct proc_dir_entry *dp = PDE(file_inode(file)); 530 struct rtas_validate_flash_t *const args_buf =
530 struct rtas_validate_flash_t *args_buf; 531 &rtas_validate_flash_data;
531 532
532 args_buf = (struct rtas_validate_flash_t *) dp->data; 533 mutex_lock(&rtas_validate_flash_mutex);
533 534
534 if (args_buf->status == VALIDATE_READY) { 535 if (args_buf->status == VALIDATE_READY) {
535 args_buf->buf_size = VALIDATE_BUF_SIZE; 536 args_buf->buf_size = VALIDATE_BUF_SIZE;
536 validate_flash(args_buf); 537 validate_flash(args_buf);
537 } 538 }
538 539
539 /* The matching atomic_inc was in rtas_excl_open() */ 540 mutex_unlock(&rtas_validate_flash_mutex);
540 atomic_dec(&dp->count);
541
542 return 0; 541 return 0;
543} 542}
544 543
544/*
545 * On-reboot flash update applicator.
546 */
545static void rtas_flash_firmware(int reboot_type) 547static void rtas_flash_firmware(int reboot_type)
546{ 548{
547 unsigned long image_size; 549 unsigned long image_size;
@@ -634,75 +636,57 @@ static void rtas_flash_firmware(int reboot_type)
634 spin_unlock(&rtas_data_buf_lock); 636 spin_unlock(&rtas_data_buf_lock);
635} 637}
636 638
637static void remove_flash_pde(struct proc_dir_entry *dp) 639/*
638{ 640 * Manifest of proc files to create
639 if (dp) { 641 */
640 kfree(dp->data); 642struct rtas_flash_file {
641 remove_proc_entry(dp->name, dp->parent); 643 const char *filename;
642 } 644 const char *rtas_call_name;
643}
644
645static int initialize_flash_pde_data(const char *rtas_call_name,
646 size_t buf_size,
647 struct proc_dir_entry *dp)
648{
649 int *status; 645 int *status;
650 int token; 646 const struct file_operations fops;
651
652 dp->data = kzalloc(buf_size, GFP_KERNEL);
653 if (dp->data == NULL)
654 return -ENOMEM;
655
656 /*
657 * This code assumes that the status int is the first member of the
658 * struct
659 */
660 status = (int *) dp->data;
661 token = rtas_token(rtas_call_name);
662 if (token == RTAS_UNKNOWN_SERVICE)
663 *status = FLASH_AUTH;
664 else
665 *status = FLASH_NO_OP;
666
667 return 0;
668}
669
670static struct proc_dir_entry *create_flash_pde(const char *filename,
671 const struct file_operations *fops)
672{
673 return proc_create(filename, S_IRUSR | S_IWUSR, NULL, fops);
674}
675
676static const struct file_operations rtas_flash_operations = {
677 .owner = THIS_MODULE,
678 .read = rtas_flash_read,
679 .write = rtas_flash_write,
680 .open = rtas_excl_open,
681 .release = rtas_flash_release,
682 .llseek = default_llseek,
683};
684
685static const struct file_operations manage_flash_operations = {
686 .owner = THIS_MODULE,
687 .read = manage_flash_read,
688 .write = manage_flash_write,
689 .open = rtas_excl_open,
690 .release = rtas_excl_release,
691 .llseek = default_llseek,
692}; 647};
693 648
694static const struct file_operations validate_flash_operations = { 649static const struct rtas_flash_file rtas_flash_files[] = {
695 .owner = THIS_MODULE, 650 {
696 .read = validate_flash_read, 651 .filename = "powerpc/rtas/" FIRMWARE_FLASH_NAME,
697 .write = validate_flash_write, 652 .rtas_call_name = "ibm,update-flash-64-and-reboot",
698 .open = rtas_excl_open, 653 .status = &rtas_update_flash_data.status,
699 .release = validate_flash_release, 654 .fops.read = rtas_flash_read_msg,
700 .llseek = default_llseek, 655 .fops.write = rtas_flash_write,
656 .fops.release = rtas_flash_release,
657 .fops.llseek = default_llseek,
658 },
659 {
660 .filename = "powerpc/rtas/" FIRMWARE_UPDATE_NAME,
661 .rtas_call_name = "ibm,update-flash-64-and-reboot",
662 .status = &rtas_update_flash_data.status,
663 .fops.read = rtas_flash_read_num,
664 .fops.write = rtas_flash_write,
665 .fops.release = rtas_flash_release,
666 .fops.llseek = default_llseek,
667 },
668 {
669 .filename = "powerpc/rtas/" VALIDATE_FLASH_NAME,
670 .rtas_call_name = "ibm,validate-flash-image",
671 .status = &rtas_validate_flash_data.status,
672 .fops.read = validate_flash_read,
673 .fops.write = validate_flash_write,
674 .fops.release = validate_flash_release,
675 .fops.llseek = default_llseek,
676 },
677 {
678 .filename = "powerpc/rtas/" MANAGE_FLASH_NAME,
679 .rtas_call_name = "ibm,manage-flash-image",
680 .status = &rtas_manage_flash_data.status,
681 .fops.read = manage_flash_read,
682 .fops.write = manage_flash_write,
683 .fops.llseek = default_llseek,
684 }
701}; 685};
702 686
703static int __init rtas_flash_init(void) 687static int __init rtas_flash_init(void)
704{ 688{
705 int rc; 689 int i;
706 690
707 if (rtas_token("ibm,update-flash-64-and-reboot") == 691 if (rtas_token("ibm,update-flash-64-and-reboot") ==
708 RTAS_UNKNOWN_SERVICE) { 692 RTAS_UNKNOWN_SERVICE) {
@@ -710,93 +694,65 @@ static int __init rtas_flash_init(void)
710 return 1; 694 return 1;
711 } 695 }
712 696
713 firmware_flash_pde = create_flash_pde("powerpc/rtas/" 697 rtas_validate_flash_data.buf = kzalloc(VALIDATE_BUF_SIZE, GFP_KERNEL);
714 FIRMWARE_FLASH_NAME, 698 if (!rtas_validate_flash_data.buf)
715 &rtas_flash_operations); 699 return -ENOMEM;
716 if (firmware_flash_pde == NULL) {
717 rc = -ENOMEM;
718 goto cleanup;
719 }
720 700
721 rc = initialize_flash_pde_data("ibm,update-flash-64-and-reboot", 701 flash_block_cache = kmem_cache_create("rtas_flash_cache",
722 sizeof(struct rtas_update_flash_t), 702 RTAS_BLK_SIZE, RTAS_BLK_SIZE, 0,
723 firmware_flash_pde); 703 rtas_block_ctor);
724 if (rc != 0) 704 if (!flash_block_cache) {
725 goto cleanup; 705 printk(KERN_ERR "%s: failed to create block cache\n",
726 706 __func__);
727 firmware_update_pde = create_flash_pde("powerpc/rtas/" 707 goto enomem_buf;
728 FIRMWARE_UPDATE_NAME,
729 &rtas_flash_operations);
730 if (firmware_update_pde == NULL) {
731 rc = -ENOMEM;
732 goto cleanup;
733 } 708 }
734 709
735 rc = initialize_flash_pde_data("ibm,update-flash-64-and-reboot", 710 for (i = 0; i < ARRAY_SIZE(rtas_flash_files); i++) {
736 sizeof(struct rtas_update_flash_t), 711 const struct rtas_flash_file *f = &rtas_flash_files[i];
737 firmware_update_pde); 712 int token;
738 if (rc != 0)
739 goto cleanup;
740
741 validate_pde = create_flash_pde("powerpc/rtas/" VALIDATE_FLASH_NAME,
742 &validate_flash_operations);
743 if (validate_pde == NULL) {
744 rc = -ENOMEM;
745 goto cleanup;
746 }
747 713
748 rc = initialize_flash_pde_data("ibm,validate-flash-image", 714 if (!proc_create(f->filename, S_IRUSR | S_IWUSR, NULL, &f->fops))
749 sizeof(struct rtas_validate_flash_t), 715 goto enomem;
750 validate_pde);
751 if (rc != 0)
752 goto cleanup;
753
754 manage_pde = create_flash_pde("powerpc/rtas/" MANAGE_FLASH_NAME,
755 &manage_flash_operations);
756 if (manage_pde == NULL) {
757 rc = -ENOMEM;
758 goto cleanup;
759 }
760 716
761 rc = initialize_flash_pde_data("ibm,manage-flash-image", 717 /*
762 sizeof(struct rtas_manage_flash_t), 718 * This code assumes that the status int is the first member of the
763 manage_pde); 719 * struct
764 if (rc != 0) 720 */
765 goto cleanup; 721 token = rtas_token(f->rtas_call_name);
722 if (token == RTAS_UNKNOWN_SERVICE)
723 *f->status = FLASH_AUTH;
724 else
725 *f->status = FLASH_NO_OP;
726 }
766 727
767 rtas_flash_term_hook = rtas_flash_firmware; 728 rtas_flash_term_hook = rtas_flash_firmware;
768
769 flash_block_cache = kmem_cache_create("rtas_flash_cache",
770 RTAS_BLK_SIZE, RTAS_BLK_SIZE, 0,
771 rtas_block_ctor);
772 if (!flash_block_cache) {
773 printk(KERN_ERR "%s: failed to create block cache\n",
774 __func__);
775 rc = -ENOMEM;
776 goto cleanup;
777 }
778 return 0; 729 return 0;
779 730
780cleanup: 731enomem:
781 remove_flash_pde(firmware_flash_pde); 732 while (--i >= 0) {
782 remove_flash_pde(firmware_update_pde); 733 const struct rtas_flash_file *f = &rtas_flash_files[i];
783 remove_flash_pde(validate_pde); 734 remove_proc_entry(f->filename, NULL);
784 remove_flash_pde(manage_pde); 735 }
785 736
786 return rc; 737 kmem_cache_destroy(flash_block_cache);
738enomem_buf:
739 kfree(rtas_validate_flash_data.buf);
740 return -ENOMEM;
787} 741}
788 742
789static void __exit rtas_flash_cleanup(void) 743static void __exit rtas_flash_cleanup(void)
790{ 744{
745 int i;
746
791 rtas_flash_term_hook = NULL; 747 rtas_flash_term_hook = NULL;
792 748
793 if (flash_block_cache) 749 for (i = 0; i < ARRAY_SIZE(rtas_flash_files); i++) {
794 kmem_cache_destroy(flash_block_cache); 750 const struct rtas_flash_file *f = &rtas_flash_files[i];
751 remove_proc_entry(f->filename, NULL);
752 }
795 753
796 remove_flash_pde(firmware_flash_pde); 754 kmem_cache_destroy(flash_block_cache);
797 remove_flash_pde(firmware_update_pde); 755 kfree(rtas_validate_flash_data.buf);
798 remove_flash_pde(validate_pde);
799 remove_flash_pde(manage_pde);
800} 756}
801 757
802module_init(rtas_flash_init); 758module_init(rtas_flash_init);
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
index 8cc18abd6dde..da98e26f6e45 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -1467,7 +1467,7 @@ static int kvm_htab_release(struct inode *inode, struct file *filp)
1467 return 0; 1467 return 0;
1468} 1468}
1469 1469
1470static struct file_operations kvm_htab_fops = { 1470static const struct file_operations kvm_htab_fops = {
1471 .read = kvm_htab_read, 1471 .read = kvm_htab_read,
1472 .write = kvm_htab_write, 1472 .write = kvm_htab_write,
1473 .llseek = default_llseek, 1473 .llseek = default_llseek,
diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
index 72ffc899c082..b2d3f3b2de72 100644
--- a/arch/powerpc/kvm/book3s_64_vio.c
+++ b/arch/powerpc/kvm/book3s_64_vio.c
@@ -92,7 +92,7 @@ static int kvm_spapr_tce_release(struct inode *inode, struct file *filp)
92 return 0; 92 return 0;
93} 93}
94 94
95static struct file_operations kvm_spapr_tce_fops = { 95static const struct file_operations kvm_spapr_tce_fops = {
96 .mmap = kvm_spapr_tce_mmap, 96 .mmap = kvm_spapr_tce_mmap,
97 .release = kvm_spapr_tce_release, 97 .release = kvm_spapr_tce_release,
98}; 98};
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 80dcc53a1aba..b62bd1b97c68 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -1483,7 +1483,7 @@ static int kvm_rma_release(struct inode *inode, struct file *filp)
1483 return 0; 1483 return 0;
1484} 1484}
1485 1485
1486static struct file_operations kvm_rma_fops = { 1486static const struct file_operations kvm_rma_fops = {
1487 .mmap = kvm_rma_mmap, 1487 .mmap = kvm_rma_mmap,
1488 .release = kvm_rma_release, 1488 .release = kvm_rma_release,
1489}; 1489};
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 68c57d38745a..d43d2d0b90e3 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -149,7 +149,6 @@ static int __fops ## _open(struct inode *inode, struct file *file) \
149 return spufs_attr_open(inode, file, __get, __set, __fmt); \ 149 return spufs_attr_open(inode, file, __get, __set, __fmt); \
150} \ 150} \
151static const struct file_operations __fops = { \ 151static const struct file_operations __fops = { \
152 .owner = THIS_MODULE, \
153 .open = __fops ## _open, \ 152 .open = __fops ## _open, \
154 .release = spufs_attr_release, \ 153 .release = spufs_attr_release, \
155 .read = spufs_attr_read, \ 154 .read = spufs_attr_read, \
@@ -2591,7 +2590,6 @@ static unsigned int spufs_switch_log_poll(struct file *file, poll_table *wait)
2591} 2590}
2592 2591
2593static const struct file_operations spufs_switch_log_fops = { 2592static const struct file_operations spufs_switch_log_fops = {
2594 .owner = THIS_MODULE,
2595 .open = spufs_switch_log_open, 2593 .open = spufs_switch_log_open,
2596 .read = spufs_switch_log_read, 2594 .read = spufs_switch_log_read,
2597 .poll = spufs_switch_log_poll, 2595 .poll = spufs_switch_log_poll,
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index d6491bd481d0..f93cdf55628c 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -452,7 +452,7 @@ static int proc_ppc64_create_ofdt(void)
452 452
453 ent = proc_create("powerpc/ofdt", S_IWUSR, NULL, &ofdt_fops); 453 ent = proc_create("powerpc/ofdt", S_IWUSR, NULL, &ofdt_fops);
454 if (ent) 454 if (ent)
455 ent->size = 0; 455 proc_set_size(ent, 0);
456 456
457 return 0; 457 return 0;
458} 458}
diff --git a/arch/powerpc/platforms/pseries/scanlog.c b/arch/powerpc/platforms/pseries/scanlog.c
index 47f3cda2a68b..b502ab61aafa 100644
--- a/arch/powerpc/platforms/pseries/scanlog.c
+++ b/arch/powerpc/platforms/pseries/scanlog.c
@@ -41,13 +41,12 @@
41 41
42 42
43static unsigned int ibm_scan_log_dump; /* RTAS token */ 43static unsigned int ibm_scan_log_dump; /* RTAS token */
44static struct proc_dir_entry *proc_ppc64_scan_log_dump; /* The proc file */ 44static unsigned int *scanlog_buffer; /* The data buffer */
45 45
46static ssize_t scanlog_read(struct file *file, char __user *buf, 46static ssize_t scanlog_read(struct file *file, char __user *buf,
47 size_t count, loff_t *ppos) 47 size_t count, loff_t *ppos)
48{ 48{
49 struct proc_dir_entry *dp = PDE(file_inode(file)); 49 unsigned int *data = scanlog_buffer;
50 unsigned int *data = (unsigned int *)dp->data;
51 int status; 50 int status;
52 unsigned long len, off; 51 unsigned long len, off;
53 unsigned int wait_time; 52 unsigned int wait_time;
@@ -135,8 +134,7 @@ static ssize_t scanlog_write(struct file * file, const char __user * buf,
135 134
136static int scanlog_open(struct inode * inode, struct file * file) 135static int scanlog_open(struct inode * inode, struct file * file)
137{ 136{
138 struct proc_dir_entry *dp = PDE(inode); 137 unsigned int *data = scanlog_buffer;
139 unsigned int *data = (unsigned int *)dp->data;
140 138
141 if (data[0] != 0) { 139 if (data[0] != 0) {
142 /* This imperfect test stops a second copy of the 140 /* This imperfect test stops a second copy of the
@@ -152,11 +150,9 @@ static int scanlog_open(struct inode * inode, struct file * file)
152 150
153static int scanlog_release(struct inode * inode, struct file * file) 151static int scanlog_release(struct inode * inode, struct file * file)
154{ 152{
155 struct proc_dir_entry *dp = PDE(inode); 153 unsigned int *data = scanlog_buffer;
156 unsigned int *data = (unsigned int *)dp->data;
157 154
158 data[0] = 0; 155 data[0] = 0;
159
160 return 0; 156 return 0;
161} 157}
162 158
@@ -172,7 +168,6 @@ const struct file_operations scanlog_fops = {
172static int __init scanlog_init(void) 168static int __init scanlog_init(void)
173{ 169{
174 struct proc_dir_entry *ent; 170 struct proc_dir_entry *ent;
175 void *data;
176 int err = -ENOMEM; 171 int err = -ENOMEM;
177 172
178 ibm_scan_log_dump = rtas_token("ibm,scan-log-dump"); 173 ibm_scan_log_dump = rtas_token("ibm,scan-log-dump");
@@ -180,29 +175,24 @@ static int __init scanlog_init(void)
180 return -ENODEV; 175 return -ENODEV;
181 176
182 /* Ideally we could allocate a buffer < 4G */ 177 /* Ideally we could allocate a buffer < 4G */
183 data = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL); 178 scanlog_buffer = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL);
184 if (!data) 179 if (!scanlog_buffer)
185 goto err; 180 goto err;
186 181
187 ent = proc_create_data("powerpc/rtas/scan-log-dump", S_IRUSR, NULL, 182 ent = proc_create("powerpc/rtas/scan-log-dump", S_IRUSR, NULL,
188 &scanlog_fops, data); 183 &scanlog_fops);
189 if (!ent) 184 if (!ent)
190 goto err; 185 goto err;
191
192 proc_ppc64_scan_log_dump = ent;
193
194 return 0; 186 return 0;
195err: 187err:
196 kfree(data); 188 kfree(scanlog_buffer);
197 return err; 189 return err;
198} 190}
199 191
200static void __exit scanlog_cleanup(void) 192static void __exit scanlog_cleanup(void)
201{ 193{
202 if (proc_ppc64_scan_log_dump) { 194 remove_proc_entry("powerpc/rtas/scan-log-dump", NULL);
203 kfree(proc_ppc64_scan_log_dump->data); 195 kfree(scanlog_buffer);
204 remove_proc_entry("scan-log-dump", proc_ppc64_scan_log_dump->parent);
205 }
206} 196}
207 197
208module_init(scanlog_init); 198module_init(scanlog_init);
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index 17644c8e10e1..2d72d9e96c15 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -1323,22 +1323,6 @@ ENTRY(compat_sys_keyctl_wrapper)
1323 llgfr %r6,%r6 # u32 1323 llgfr %r6,%r6 # u32
1324 jg compat_sys_keyctl # branch to system call 1324 jg compat_sys_keyctl # branch to system call
1325 1325
1326ENTRY(compat_sys_preadv_wrapper)
1327 llgfr %r2,%r2 # unsigned long
1328 llgtr %r3,%r3 # compat_iovec *
1329 llgfr %r4,%r4 # unsigned long
1330 llgfr %r5,%r5 # u32
1331 llgfr %r6,%r6 # u32
1332 jg compat_sys_preadv # branch to system call
1333
1334ENTRY(compat_sys_pwritev_wrapper)
1335 llgfr %r2,%r2 # unsigned long
1336 llgtr %r3,%r3 # compat_iovec *
1337 llgfr %r4,%r4 # unsigned long
1338 llgfr %r5,%r5 # u32
1339 llgfr %r6,%r6 # u32
1340 jg compat_sys_pwritev # branch to system call
1341
1342ENTRY(sys_perf_event_open_wrapper) 1326ENTRY(sys_perf_event_open_wrapper)
1343 llgtr %r2,%r2 # const struct perf_event_attr * 1327 llgtr %r2,%r2 # const struct perf_event_attr *
1344 lgfr %r3,%r3 # pid_t 1328 lgfr %r3,%r3 # pid_t
diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
index 4f5ef62934a4..f7fb58903f6a 100644
--- a/arch/s390/kernel/irq.c
+++ b/arch/s390/kernel/irq.c
@@ -162,10 +162,8 @@ asmlinkage void do_softirq(void)
162#ifdef CONFIG_PROC_FS 162#ifdef CONFIG_PROC_FS
163void init_irq_proc(void) 163void init_irq_proc(void)
164{ 164{
165 struct proc_dir_entry *root_irq_dir; 165 if (proc_mkdir("irq", NULL))
166 166 create_prof_cpu_mask();
167 root_irq_dir = proc_mkdir("irq", NULL);
168 create_prof_cpu_mask(root_irq_dir);
169} 167}
170#endif 168#endif
171 169
diff --git a/arch/s390/kernel/os_info.c b/arch/s390/kernel/os_info.c
index 46480d81df00..d112fc66f993 100644
--- a/arch/s390/kernel/os_info.c
+++ b/arch/s390/kernel/os_info.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/crash_dump.h> 11#include <linux/crash_dump.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/slab.h>
13#include <asm/checksum.h> 14#include <asm/checksum.h>
14#include <asm/lowcore.h> 15#include <asm/lowcore.h>
15#include <asm/os_info.h> 16#include <asm/os_info.h>
diff --git a/arch/s390/kernel/syscalls.S b/arch/s390/kernel/syscalls.S
index d2baabed7148..9f214e992eed 100644
--- a/arch/s390/kernel/syscalls.S
+++ b/arch/s390/kernel/syscalls.S
@@ -336,8 +336,8 @@ SYSCALL(sys_inotify_init1,sys_inotify_init1,sys_inotify_init1_wrapper)
336SYSCALL(sys_pipe2,sys_pipe2,sys_pipe2_wrapper) /* 325 */ 336SYSCALL(sys_pipe2,sys_pipe2,sys_pipe2_wrapper) /* 325 */
337SYSCALL(sys_dup3,sys_dup3,sys_dup3_wrapper) 337SYSCALL(sys_dup3,sys_dup3,sys_dup3_wrapper)
338SYSCALL(sys_epoll_create1,sys_epoll_create1,sys_epoll_create1_wrapper) 338SYSCALL(sys_epoll_create1,sys_epoll_create1,sys_epoll_create1_wrapper)
339SYSCALL(sys_preadv,sys_preadv,compat_sys_preadv_wrapper) 339SYSCALL(sys_preadv,sys_preadv,compat_sys_preadv)
340SYSCALL(sys_pwritev,sys_pwritev,compat_sys_pwritev_wrapper) 340SYSCALL(sys_pwritev,sys_pwritev,compat_sys_pwritev)
341SYSCALL(sys_rt_tgsigqueueinfo,sys_rt_tgsigqueueinfo,compat_sys_rt_tgsigqueueinfo) /* 330 */ 341SYSCALL(sys_rt_tgsigqueueinfo,sys_rt_tgsigqueueinfo,compat_sys_rt_tgsigqueueinfo) /* 330 */
342SYSCALL(sys_perf_event_open,sys_perf_event_open,sys_perf_event_open_wrapper) 342SYSCALL(sys_perf_event_open,sys_perf_event_open,sys_perf_event_open_wrapper)
343SYSCALL(sys_fanotify_init,sys_fanotify_init,sys_fanotify_init_wrapper) 343SYSCALL(sys_fanotify_init,sys_fanotify_init,sys_fanotify_init_wrapper)
diff --git a/arch/score/mm/init.c b/arch/score/mm/init.c
index 1592aad7dbc4..d8f988a37d16 100644
--- a/arch/score/mm/init.c
+++ b/arch/score/mm/init.c
@@ -31,7 +31,7 @@
31#include <linux/mm.h> 31#include <linux/mm.h>
32#include <linux/mman.h> 32#include <linux/mman.h>
33#include <linux/pagemap.h> 33#include <linux/pagemap.h>
34#include <linux/proc_fs.h> 34#include <linux/kcore.h>
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/initrd.h> 36#include <linux/initrd.h>
37 37
diff --git a/arch/sh/drivers/dma/dma-api.c b/arch/sh/drivers/dma/dma-api.c
index f46848f088e4..851e5106e580 100644
--- a/arch/sh/drivers/dma/dma-api.c
+++ b/arch/sh/drivers/dma/dma-api.c
@@ -13,6 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <linux/proc_fs.h> 15#include <linux/proc_fs.h>
16#include <linux/seq_file.h>
16#include <linux/list.h> 17#include <linux/list.h>
17#include <linux/platform_device.h> 18#include <linux/platform_device.h>
18#include <linux/mm.h> 19#include <linux/mm.h>
@@ -308,11 +309,9 @@ int dma_extend(unsigned int chan, unsigned long op, void *param)
308} 309}
309EXPORT_SYMBOL(dma_extend); 310EXPORT_SYMBOL(dma_extend);
310 311
311static int dma_read_proc(char *buf, char **start, off_t off, 312static int dma_proc_show(struct seq_file *m, void *v)
312 int len, int *eof, void *data)
313{ 313{
314 struct dma_info *info; 314 struct dma_info *info = v;
315 char *p = buf;
316 315
317 if (list_empty(&registered_dmac_list)) 316 if (list_empty(&registered_dmac_list))
318 return 0; 317 return 0;
@@ -332,14 +331,26 @@ static int dma_read_proc(char *buf, char **start, off_t off,
332 if (!(channel->flags & DMA_CONFIGURED)) 331 if (!(channel->flags & DMA_CONFIGURED))
333 continue; 332 continue;
334 333
335 p += sprintf(p, "%2d: %14s %s\n", i, 334 seq_printf(m, "%2d: %14s %s\n", i,
336 info->name, channel->dev_id); 335 info->name, channel->dev_id);
337 } 336 }
338 } 337 }
339 338
340 return p - buf; 339 return 0;
340}
341
342static int dma_proc_open(struct inode *inode, struct file *file)
343{
344 return single_open(file, dma_proc_show, NULL);
341} 345}
342 346
347static const struct file_operations dma_proc_fops = {
348 .open = dma_proc_open,
349 .read = seq_read,
350 .llseek = seq_lseek,
351 .release = seq_release,
352};
353
343int register_dmac(struct dma_info *info) 354int register_dmac(struct dma_info *info)
344{ 355{
345 unsigned int total_channels, i; 356 unsigned int total_channels, i;
@@ -412,8 +423,7 @@ EXPORT_SYMBOL(unregister_dmac);
412static int __init dma_api_init(void) 423static int __init dma_api_init(void)
413{ 424{
414 printk(KERN_NOTICE "DMA: Registering DMA API.\n"); 425 printk(KERN_NOTICE "DMA: Registering DMA API.\n");
415 return create_proc_read_entry("dma", 0, 0, dma_read_proc, 0) 426 return proc_create("dma", 0, NULL, &dma_proc_fops) ? 0 : -ENOMEM;
416 ? 0 : -ENOMEM;
417} 427}
418subsys_initcall(dma_api_init); 428subsys_initcall(dma_api_init);
419 429
diff --git a/arch/sh/mm/alignment.c b/arch/sh/mm/alignment.c
index aea14855e656..ec2b25302427 100644
--- a/arch/sh/mm/alignment.c
+++ b/arch/sh/mm/alignment.c
@@ -140,7 +140,7 @@ static int alignment_proc_open(struct inode *inode, struct file *file)
140static ssize_t alignment_proc_write(struct file *file, 140static ssize_t alignment_proc_write(struct file *file,
141 const char __user *buffer, size_t count, loff_t *pos) 141 const char __user *buffer, size_t count, loff_t *pos)
142{ 142{
143 int *data = PDE(file_inode(file))->data; 143 int *data = PDE_DATA(file_inode(file));
144 char mode; 144 char mode;
145 145
146 if (count > 0) { 146 if (count > 0) {
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 0f094db918c7..2096468de9b2 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -693,7 +693,7 @@ static int sparc_io_proc_show(struct seq_file *m, void *v)
693 693
694static int sparc_io_proc_open(struct inode *inode, struct file *file) 694static int sparc_io_proc_open(struct inode *inode, struct file *file)
695{ 695{
696 return single_open(file, sparc_io_proc_show, PDE(inode)->data); 696 return single_open(file, sparc_io_proc_show, PDE_DATA(inode));
697} 697}
698 698
699static const struct file_operations sparc_io_proc_fops = { 699static const struct file_operations sparc_io_proc_fops = {
diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c
index e490ac9327c7..f8933be3ca8b 100644
--- a/arch/sparc/kernel/sun4d_irq.c
+++ b/arch/sparc/kernel/sun4d_irq.c
@@ -6,6 +6,7 @@
6 */ 6 */
7 7
8#include <linux/kernel_stat.h> 8#include <linux/kernel_stat.h>
9#include <linux/slab.h>
9#include <linux/seq_file.h> 10#include <linux/seq_file.h>
10 11
11#include <asm/timer.h> 12#include <asm/timer.h>
diff --git a/arch/tile/kernel/hardwall.c b/arch/tile/kernel/hardwall.c
index 20273ee37deb..38ac189d9575 100644
--- a/arch/tile/kernel/hardwall.c
+++ b/arch/tile/kernel/hardwall.c
@@ -914,7 +914,7 @@ static int hardwall_proc_show(struct seq_file *sf, void *v)
914static int hardwall_proc_open(struct inode *inode, 914static int hardwall_proc_open(struct inode *inode,
915 struct file *file) 915 struct file *file)
916{ 916{
917 return single_open(file, hardwall_proc_show, PDE(inode)->data); 917 return single_open(file, hardwall_proc_show, PDE_DATA(inode));
918} 918}
919 919
920static const struct file_operations hardwall_proc_fops = { 920static const struct file_operations hardwall_proc_fops = {
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 4bd82ac0210f..d7d21851e60c 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -782,8 +782,7 @@ static int create_proc_mconsole(void)
782 782
783 ent = proc_create("mconsole", 0200, NULL, &mconsole_proc_fops); 783 ent = proc_create("mconsole", 0200, NULL, &mconsole_proc_fops);
784 if (ent == NULL) { 784 if (ent == NULL) {
785 printk(KERN_INFO "create_proc_mconsole : create_proc_entry " 785 printk(KERN_INFO "create_proc_mconsole : proc_create failed\n");
786 "failed\n");
787 return 0; 786 return 0;
788 } 787 }
789 return 0; 788 return 0;
diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
index 81e94d972f1b..805078e08013 100644
--- a/arch/x86/ia32/ia32_aout.c
+++ b/arch/x86/ia32/ia32_aout.c
@@ -322,11 +322,8 @@ static int load_aout_binary(struct linux_binprm *bprm)
322 322
323 if (N_MAGIC(ex) == OMAGIC) { 323 if (N_MAGIC(ex) == OMAGIC) {
324 unsigned long text_addr, map_size; 324 unsigned long text_addr, map_size;
325 loff_t pos;
326 325
327 text_addr = N_TXTADDR(ex); 326 text_addr = N_TXTADDR(ex);
328
329 pos = 32;
330 map_size = ex.a_text+ex.a_data; 327 map_size = ex.a_text+ex.a_data;
331 328
332 error = vm_brk(text_addr & PAGE_MASK, map_size); 329 error = vm_brk(text_addr & PAGE_MASK, map_size);
@@ -336,15 +333,12 @@ static int load_aout_binary(struct linux_binprm *bprm)
336 return error; 333 return error;
337 } 334 }
338 335
339 error = bprm->file->f_op->read(bprm->file, 336 error = read_code(bprm->file, text_addr, 32,
340 (char __user *)text_addr, 337 ex.a_text + ex.a_data);
341 ex.a_text+ex.a_data, &pos);
342 if ((signed long)error < 0) { 338 if ((signed long)error < 0) {
343 send_sig(SIGKILL, current, 0); 339 send_sig(SIGKILL, current, 0);
344 return error; 340 return error;
345 } 341 }
346
347 flush_icache_range(text_addr, text_addr+ex.a_text+ex.a_data);
348 } else { 342 } else {
349#ifdef WARN_OLD 343#ifdef WARN_OLD
350 static unsigned long error_time, error_time2; 344 static unsigned long error_time, error_time2;
@@ -366,15 +360,9 @@ static int load_aout_binary(struct linux_binprm *bprm)
366#endif 360#endif
367 361
368 if (!bprm->file->f_op->mmap || (fd_offset & ~PAGE_MASK) != 0) { 362 if (!bprm->file->f_op->mmap || (fd_offset & ~PAGE_MASK) != 0) {
369 loff_t pos = fd_offset;
370
371 vm_brk(N_TXTADDR(ex), ex.a_text+ex.a_data); 363 vm_brk(N_TXTADDR(ex), ex.a_text+ex.a_data);
372 bprm->file->f_op->read(bprm->file, 364 read_code(bprm->file, N_TXTADDR(ex), fd_offset,
373 (char __user *)N_TXTADDR(ex), 365 ex.a_text+ex.a_data);
374 ex.a_text+ex.a_data, &pos);
375 flush_icache_range((unsigned long) N_TXTADDR(ex),
376 (unsigned long) N_TXTADDR(ex) +
377 ex.a_text+ex.a_data);
378 goto beyond_if; 366 goto beyond_if;
379 } 367 }
380 368
@@ -451,8 +439,6 @@ static int load_aout_library(struct file *file)
451 start_addr = ex.a_entry & 0xfffff000; 439 start_addr = ex.a_entry & 0xfffff000;
452 440
453 if ((N_TXTOFF(ex) & ~PAGE_MASK) != 0) { 441 if ((N_TXTOFF(ex) & ~PAGE_MASK) != 0) {
454 loff_t pos = N_TXTOFF(ex);
455
456#ifdef WARN_OLD 442#ifdef WARN_OLD
457 static unsigned long error_time; 443 static unsigned long error_time;
458 if (time_after(jiffies, error_time + 5*HZ)) { 444 if (time_after(jiffies, error_time + 5*HZ)) {
@@ -465,12 +451,8 @@ static int load_aout_library(struct file *file)
465#endif 451#endif
466 vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); 452 vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss);
467 453
468 file->f_op->read(file, (char __user *)start_addr, 454 read_code(file, start_addr, N_TXTOFF(ex),
469 ex.a_text + ex.a_data, &pos); 455 ex.a_text + ex.a_data);
470 flush_icache_range((unsigned long) start_addr,
471 (unsigned long) start_addr + ex.a_text +
472 ex.a_data);
473
474 retval = 0; 456 retval = 0;
475 goto out; 457 goto out;
476 } 458 }
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index caad9a0ee19f..bb00c4672ad6 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -32,6 +32,7 @@
32#include <linux/memory_hotplug.h> 32#include <linux/memory_hotplug.h>
33#include <linux/nmi.h> 33#include <linux/nmi.h>
34#include <linux/gfp.h> 34#include <linux/gfp.h>
35#include <linux/kcore.h>
35 36
36#include <asm/processor.h> 37#include <asm/processor.h>
37#include <asm/bios_ebda.h> 38#include <asm/bios_ebda.h>
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 6b85db0a7ccc..55856b2310d3 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -34,6 +34,7 @@
34#include <linux/efi-bgrt.h> 34#include <linux/efi-bgrt.h>
35#include <linux/export.h> 35#include <linux/export.h>
36#include <linux/bootmem.h> 36#include <linux/bootmem.h>
37#include <linux/slab.h>
37#include <linux/memblock.h> 38#include <linux/memblock.h>
38#include <linux/spinlock.h> 39#include <linux/spinlock.h>
39#include <linux/uaccess.h> 40#include <linux/uaccess.h>
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index 2b2003860615..39a0e7f1f0a3 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -27,6 +27,7 @@
27#include <linux/uaccess.h> 27#include <linux/uaccess.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/reboot.h> 29#include <linux/reboot.h>
30#include <linux/slab.h>
30 31
31#include <asm/setup.h> 32#include <asm/setup.h>
32#include <asm/page.h> 33#include <asm/page.h>
diff --git a/arch/xtensa/platforms/iss/simdisk.c b/arch/xtensa/platforms/iss/simdisk.c
index f58ffc3b68a8..4a06d70ddf5e 100644
--- a/arch/xtensa/platforms/iss/simdisk.c
+++ b/arch/xtensa/platforms/iss/simdisk.c
@@ -214,20 +214,27 @@ static int simdisk_detach(struct simdisk *dev)
214 return err; 214 return err;
215} 215}
216 216
217static int proc_read_simdisk(char *page, char **start, off_t off, 217static ssize_t proc_read_simdisk(struct file *file, char __user *buf,
218 int count, int *eof, void *data) 218 size_t size, loff_t *ppos)
219{ 219{
220 int len; 220 struct simdisk *dev = PDE_DATA(file_inode(file));
221 struct simdisk *dev = (struct simdisk *) data; 221 char *s = dev->filename;
222 len = sprintf(page, "%s\n", dev->filename ? dev->filename : ""); 222 if (s) {
223 return len; 223 ssize_t n = simple_read_from_buffer(buf, size, ppos,
224 s, strlen(s));
225 if (n < 0)
226 return n;
227 buf += n;
228 size -= n;
229 }
230 return simple_read_from_buffer(buf, size, ppos, "\n", 1);
224} 231}
225 232
226static int proc_write_simdisk(struct file *file, const char *buffer, 233static ssize_t proc_write_simdisk(struct file *file, const char __user *buf,
227 unsigned long count, void *data) 234 size_t size, loff_t *ppos)
228{ 235{
229 char *tmp = kmalloc(count + 1, GFP_KERNEL); 236 char *tmp = kmalloc(count + 1, GFP_KERNEL);
230 struct simdisk *dev = (struct simdisk *) data; 237 struct simdisk *dev = PDE_DATA(file_inode(file));
231 int err; 238 int err;
232 239
233 if (tmp == NULL) 240 if (tmp == NULL)
@@ -256,6 +263,12 @@ out_free:
256 return err; 263 return err;
257} 264}
258 265
266static const struct file_operations fops = {
267 .read = proc_read_simdisk,
268 .write = proc_write_simdisk,
269 .llseek = default_llseek,
270};
271
259static int __init simdisk_setup(struct simdisk *dev, int which, 272static int __init simdisk_setup(struct simdisk *dev, int which,
260 struct proc_dir_entry *procdir) 273 struct proc_dir_entry *procdir)
261{ 274{
@@ -289,10 +302,7 @@ static int __init simdisk_setup(struct simdisk *dev, int which,
289 set_capacity(dev->gd, 0); 302 set_capacity(dev->gd, 0);
290 add_disk(dev->gd); 303 add_disk(dev->gd);
291 304
292 dev->procfile = create_proc_entry(tmp, 0644, procdir); 305 dev->procfile = proc_create_data(tmp, 0644, procdir, &fops, dev);
293 dev->procfile->data = dev;
294 dev->procfile->read_proc = proc_read_simdisk;
295 dev->procfile->write_proc = proc_write_simdisk;
296 return 0; 306 return 0;
297 307
298out_alloc_disk: 308out_alloc_disk: