aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/proc_devtree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/proc_devtree.c')
-rw-r--r--fs/proc/proc_devtree.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c
index 7ba79a54948c..ce94801f48ca 100644
--- a/fs/proc/proc_devtree.c
+++ b/fs/proc/proc_devtree.c
@@ -7,44 +7,50 @@
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/time.h> 8#include <linux/time.h>
9#include <linux/proc_fs.h> 9#include <linux/proc_fs.h>
10#include <linux/seq_file.h>
10#include <linux/stat.h> 11#include <linux/stat.h>
11#include <linux/string.h> 12#include <linux/string.h>
13#include <linux/of.h>
14#include <linux/module.h>
15#include <linux/slab.h>
12#include <asm/prom.h> 16#include <asm/prom.h>
13#include <asm/uaccess.h> 17#include <asm/uaccess.h>
14#include "internal.h" 18#include "internal.h"
15 19
16#ifndef HAVE_ARCH_DEVTREE_FIXUPS
17static inline void set_node_proc_entry(struct device_node *np, 20static inline void set_node_proc_entry(struct device_node *np,
18 struct proc_dir_entry *de) 21 struct proc_dir_entry *de)
19{ 22{
20} 23#ifdef HAVE_ARCH_DEVTREE_FIXUPS
24 np->pde = de;
21#endif 25#endif
26}
22 27
23static struct proc_dir_entry *proc_device_tree; 28static struct proc_dir_entry *proc_device_tree;
24 29
25/* 30/*
26 * Supply data on a read from /proc/device-tree/node/property. 31 * Supply data on a read from /proc/device-tree/node/property.
27 */ 32 */
28static int property_read_proc(char *page, char **start, off_t off, 33static int property_proc_show(struct seq_file *m, void *v)
29 int count, int *eof, void *data)
30{ 34{
31 struct property *pp = data; 35 struct property *pp = m->private;
32 int n;
33 36
34 if (off >= pp->length) { 37 seq_write(m, pp->value, pp->length);
35 *eof = 1; 38 return 0;
36 return 0;
37 }
38 n = pp->length - off;
39 if (n > count)
40 n = count;
41 else
42 *eof = 1;
43 memcpy(page, (char *)pp->value + off, n);
44 *start = page;
45 return n;
46} 39}
47 40
41static int property_proc_open(struct inode *inode, struct file *file)
42{
43 return single_open(file, property_proc_show, PDE(inode)->data);
44}
45
46static const struct file_operations property_proc_fops = {
47 .owner = THIS_MODULE,
48 .open = property_proc_open,
49 .read = seq_read,
50 .llseek = seq_lseek,
51 .release = single_release,
52};
53
48/* 54/*
49 * For a node with a name like "gc@10", we make symlinks called "gc" 55 * For a node with a name like "gc@10", we make symlinks called "gc"
50 * and "@10" to it. 56 * and "@10" to it.
@@ -63,10 +69,9 @@ __proc_device_tree_add_prop(struct proc_dir_entry *de, struct property *pp,
63 * Unfortunately proc_register puts each new entry 69 * Unfortunately proc_register puts each new entry
64 * at the beginning of the list. So we rearrange them. 70 * at the beginning of the list. So we rearrange them.
65 */ 71 */
66 ent = create_proc_read_entry(name, 72 ent = proc_create_data(name,
67 strncmp(name, "security-", 9) 73 strncmp(name, "security-", 9) ? S_IRUGO : S_IRUSR,
68 ? S_IRUGO : S_IRUSR, de, 74 de, &property_proc_fops, pp);
69 property_read_proc, pp);
70 if (ent == NULL) 75 if (ent == NULL)
71 return NULL; 76 return NULL;
72 77