diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-03-31 18:16:14 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-09 14:13:32 -0400 |
commit | d9dda78bad879595d8c4220a067fc029d6484a16 (patch) | |
tree | 376c47ed566b719009e753e917104b150a639b11 /arch | |
parent | 8510e30b46cd5467b2f930bef68a276dbc2c7d7c (diff) |
procfs: new helper - PDE_DATA(inode)
The only part of proc_dir_entry the code outside of fs/proc
really cares about is PDE(inode)->data. Provide a helper
for that; static inline for now, eventually will be moved
to fs/proc, along with the knowledge of struct proc_dir_entry
layout.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/alpha/kernel/srm_env.c | 4 | ||||
-rw-r--r-- | arch/arm/kernel/atags_proc.c | 2 | ||||
-rw-r--r-- | arch/blackfin/kernel/cplbinfo.c | 4 | ||||
-rw-r--r-- | arch/ia64/kernel/salinfo.c | 18 | ||||
-rw-r--r-- | arch/mips/lasat/picvue_proc.c | 4 | ||||
-rw-r--r-- | arch/powerpc/kernel/proc_powerpc.c | 19 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/scanlog.c | 9 | ||||
-rw-r--r-- | arch/sh/mm/alignment.c | 2 | ||||
-rw-r--r-- | arch/sparc/kernel/ioport.c | 2 | ||||
-rw-r--r-- | arch/tile/kernel/hardwall.c | 2 | ||||
-rw-r--r-- | arch/xtensa/platforms/iss/simdisk.c | 4 |
11 files changed, 27 insertions, 43 deletions
diff --git a/arch/alpha/kernel/srm_env.c b/arch/alpha/kernel/srm_env.c index e64559f0a82d..ef8769b6c98b 100644 --- a/arch/alpha/kernel/srm_env.c +++ b/arch/alpha/kernel/srm_env.c | |||
@@ -104,14 +104,14 @@ static int srm_env_proc_show(struct seq_file *m, void *v) | |||
104 | 104 | ||
105 | static int srm_env_proc_open(struct inode *inode, struct file *file) | 105 | static int srm_env_proc_open(struct inode *inode, struct file *file) |
106 | { | 106 | { |
107 | return single_open(file, srm_env_proc_show, PDE(inode)->data); | 107 | return single_open(file, srm_env_proc_show, PDE_DATA(inode)); |
108 | } | 108 | } |
109 | 109 | ||
110 | static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer, | 110 | static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer, |
111 | size_t count, loff_t *pos) | 111 | size_t count, loff_t *pos) |
112 | { | 112 | { |
113 | int res; | 113 | int res; |
114 | srm_env_t *entry = PDE(file_inode(file))->data; | 114 | srm_env_t *entry = PDE_DATA(file_inode(file)); |
115 | char *buf = (char *) __get_free_page(GFP_USER); | 115 | char *buf = (char *) __get_free_page(GFP_USER); |
116 | unsigned long ret1, ret2; | 116 | unsigned long ret1, ret2; |
117 | 117 | ||
diff --git a/arch/arm/kernel/atags_proc.c b/arch/arm/kernel/atags_proc.c index 8c00f75bf1ab..c7ff8073416f 100644 --- a/arch/arm/kernel/atags_proc.c +++ b/arch/arm/kernel/atags_proc.c | |||
@@ -12,7 +12,7 @@ struct buffer { | |||
12 | static ssize_t atags_read(struct file *file, char __user *buf, | 12 | static ssize_t atags_read(struct file *file, char __user *buf, |
13 | size_t count, loff_t *ppos) | 13 | size_t count, loff_t *ppos) |
14 | { | 14 | { |
15 | struct buffer *b = PDE(file_inode(file))->data; | 15 | struct buffer *b = PDE_DATA(file_inode(file)); |
16 | return simple_read_from_buffer(buf, count, ppos, b->data, b->size); | 16 | return simple_read_from_buffer(buf, count, ppos, b->data, b->size); |
17 | } | 17 | } |
18 | 18 | ||
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 | ||
117 | static int cplbinfo_open(struct inode *inode, struct file *file) | 117 | static 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/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c index aa527d7e91f2..a97d75b9c5ec 100644 --- a/arch/ia64/kernel/salinfo.c +++ b/arch/ia64/kernel/salinfo.c | |||
@@ -301,9 +301,7 @@ salinfo_event_open(struct inode *inode, struct file *file) | |||
301 | static ssize_t | 301 | static ssize_t |
302 | salinfo_event_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) | 302 | salinfo_event_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) |
303 | { | 303 | { |
304 | struct inode *inode = file_inode(file); | 304 | 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]; | 305 | char cmd[32]; |
308 | size_t size; | 306 | size_t size; |
309 | int i, n, cpu = -1; | 307 | int i, n, cpu = -1; |
@@ -360,8 +358,7 @@ static const struct file_operations salinfo_event_fops = { | |||
360 | static int | 358 | static int |
361 | salinfo_log_open(struct inode *inode, struct file *file) | 359 | salinfo_log_open(struct inode *inode, struct file *file) |
362 | { | 360 | { |
363 | struct proc_dir_entry *entry = PDE(inode); | 361 | struct salinfo_data *data = PDE_DATA(inode); |
364 | struct salinfo_data *data = entry->data; | ||
365 | 362 | ||
366 | if (!capable(CAP_SYS_ADMIN)) | 363 | if (!capable(CAP_SYS_ADMIN)) |
367 | return -EPERM; | 364 | return -EPERM; |
@@ -386,8 +383,7 @@ salinfo_log_open(struct inode *inode, struct file *file) | |||
386 | static int | 383 | static int |
387 | salinfo_log_release(struct inode *inode, struct file *file) | 384 | salinfo_log_release(struct inode *inode, struct file *file) |
388 | { | 385 | { |
389 | struct proc_dir_entry *entry = PDE(inode); | 386 | struct salinfo_data *data = PDE_DATA(inode); |
390 | struct salinfo_data *data = entry->data; | ||
391 | 387 | ||
392 | if (data->state == STATE_NO_DATA) { | 388 | if (data->state == STATE_NO_DATA) { |
393 | vfree(data->log_buffer); | 389 | vfree(data->log_buffer); |
@@ -463,9 +459,7 @@ retry: | |||
463 | static ssize_t | 459 | static ssize_t |
464 | salinfo_log_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) | 460 | salinfo_log_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) |
465 | { | 461 | { |
466 | struct inode *inode = file_inode(file); | 462 | 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; | 463 | u8 *buf; |
470 | u64 bufsize; | 464 | u64 bufsize; |
471 | 465 | ||
@@ -524,9 +518,7 @@ salinfo_log_clear(struct salinfo_data *data, int cpu) | |||
524 | static ssize_t | 518 | static ssize_t |
525 | salinfo_log_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) | 519 | salinfo_log_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) |
526 | { | 520 | { |
527 | struct inode *inode = file_inode(file); | 521 | 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]; | 522 | char cmd[32]; |
531 | size_t size; | 523 | size_t size; |
532 | u32 offset; | 524 | u32 offset; |
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 | ||
59 | static int pvc_line_proc_open(struct inode *inode, struct file *file) | 59 | static 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 | ||
64 | static ssize_t pvc_line_proc_write(struct file *file, const char __user *buf, | 64 | static 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/powerpc/kernel/proc_powerpc.c b/arch/powerpc/kernel/proc_powerpc.c index f19d0bdc3241..41d8ee9c82f1 100644 --- a/arch/powerpc/kernel/proc_powerpc.c +++ b/arch/powerpc/kernel/proc_powerpc.c | |||
@@ -32,8 +32,6 @@ | |||
32 | static loff_t page_map_seek( struct file *file, loff_t off, int whence) | 32 | static 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) | |||
55 | static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes, | 53 | static 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 | ||
62 | static int page_map_mmap( struct file *file, struct vm_area_struct *vma ) | 60 | static 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 | ||
diff --git a/arch/powerpc/platforms/pseries/scanlog.c b/arch/powerpc/platforms/pseries/scanlog.c index 47f3cda2a68b..cc220d2061b2 100644 --- a/arch/powerpc/platforms/pseries/scanlog.c +++ b/arch/powerpc/platforms/pseries/scanlog.c | |||
@@ -46,8 +46,7 @@ static struct proc_dir_entry *proc_ppc64_scan_log_dump; /* The proc file */ | |||
46 | static ssize_t scanlog_read(struct file *file, char __user *buf, | 46 | static 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 = PDE_DATA(file_inode(file)); |
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 | ||
136 | static int scanlog_open(struct inode * inode, struct file * file) | 135 | static int scanlog_open(struct inode * inode, struct file * file) |
137 | { | 136 | { |
138 | struct proc_dir_entry *dp = PDE(inode); | 137 | unsigned int *data = PDE_DATA(file_inode(file)); |
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,8 +150,7 @@ static int scanlog_open(struct inode * inode, struct file * file) | |||
152 | 150 | ||
153 | static int scanlog_release(struct inode * inode, struct file * file) | 151 | static int scanlog_release(struct inode * inode, struct file * file) |
154 | { | 152 | { |
155 | struct proc_dir_entry *dp = PDE(inode); | 153 | unsigned int *data = PDE_DATA(file_inode(file)); |
156 | unsigned int *data = (unsigned int *)dp->data; | ||
157 | 154 | ||
158 | data[0] = 0; | 155 | data[0] = 0; |
159 | 156 | ||
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) | |||
140 | static ssize_t alignment_proc_write(struct file *file, | 140 | static 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 | ||
694 | static int sparc_io_proc_open(struct inode *inode, struct file *file) | 694 | static 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 | ||
699 | static const struct file_operations sparc_io_proc_fops = { | 699 | static const struct file_operations sparc_io_proc_fops = { |
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) | |||
914 | static int hardwall_proc_open(struct inode *inode, | 914 | static 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 | ||
920 | static const struct file_operations hardwall_proc_fops = { | 920 | static const struct file_operations hardwall_proc_fops = { |
diff --git a/arch/xtensa/platforms/iss/simdisk.c b/arch/xtensa/platforms/iss/simdisk.c index 47ccef7839c9..4a06d70ddf5e 100644 --- a/arch/xtensa/platforms/iss/simdisk.c +++ b/arch/xtensa/platforms/iss/simdisk.c | |||
@@ -217,7 +217,7 @@ static int simdisk_detach(struct simdisk *dev) | |||
217 | static ssize_t proc_read_simdisk(struct file *file, char __user *buf, | 217 | static ssize_t proc_read_simdisk(struct file *file, char __user *buf, |
218 | size_t size, loff_t *ppos) | 218 | size_t size, loff_t *ppos) |
219 | { | 219 | { |
220 | struct simdisk *dev = PDE(file_inode(file))->data; | 220 | struct simdisk *dev = PDE_DATA(file_inode(file)); |
221 | char *s = dev->filename; | 221 | char *s = dev->filename; |
222 | if (s) { | 222 | if (s) { |
223 | ssize_t n = simple_read_from_buffer(buf, size, ppos, | 223 | ssize_t n = simple_read_from_buffer(buf, size, ppos, |
@@ -234,7 +234,7 @@ static ssize_t proc_write_simdisk(struct file *file, const char __user *buf, | |||
234 | size_t size, loff_t *ppos) | 234 | size_t size, loff_t *ppos) |
235 | { | 235 | { |
236 | char *tmp = kmalloc(count + 1, GFP_KERNEL); | 236 | char *tmp = kmalloc(count + 1, GFP_KERNEL); |
237 | struct simdisk *dev = PDE(file_inode(file))->data; | 237 | struct simdisk *dev = PDE_DATA(file_inode(file)); |
238 | int err; | 238 | int err; |
239 | 239 | ||
240 | if (tmp == NULL) | 240 | if (tmp == NULL) |