mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
Convert /proc/device-tree/ to seq_file
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
parent
5a1eb5c445
commit
e22f628395
1 changed files with 21 additions and 20 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/time.h>
|
#include <linux/time.h>
|
||||||
#include <linux/proc_fs.h>
|
#include <linux/proc_fs.h>
|
||||||
|
#include <linux/seq_file.h>
|
||||||
#include <linux/stat.h>
|
#include <linux/stat.h>
|
||||||
#include <linux/string.h>
|
#include <linux/string.h>
|
||||||
#include <asm/prom.h>
|
#include <asm/prom.h>
|
||||||
|
@ -25,26 +26,27 @@ static struct proc_dir_entry *proc_device_tree;
|
||||||
/*
|
/*
|
||||||
* Supply data on a read from /proc/device-tree/node/property.
|
* Supply data on a read from /proc/device-tree/node/property.
|
||||||
*/
|
*/
|
||||||
static int property_read_proc(char *page, char **start, off_t off,
|
static int property_proc_show(struct seq_file *m, void *v)
|
||||||
int count, int *eof, void *data)
|
|
||||||
{
|
{
|
||||||
struct property *pp = data;
|
struct property *pp = m->private;
|
||||||
int n;
|
|
||||||
|
|
||||||
if (off >= pp->length) {
|
seq_write(m, pp->value, pp->length);
|
||||||
*eof = 1;
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
n = pp->length - off;
|
|
||||||
if (n > count)
|
|
||||||
n = count;
|
|
||||||
else
|
|
||||||
*eof = 1;
|
|
||||||
memcpy(page, (char *)pp->value + off, n);
|
|
||||||
*start = page;
|
|
||||||
return n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int property_proc_open(struct inode *inode, struct file *file)
|
||||||
|
{
|
||||||
|
return single_open(file, property_proc_show, PDE(inode)->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct file_operations property_proc_fops = {
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
.open = property_proc_open,
|
||||||
|
.read = seq_read,
|
||||||
|
.llseek = seq_lseek,
|
||||||
|
.release = single_release,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For a node with a name like "gc@10", we make symlinks called "gc"
|
* For a node with a name like "gc@10", we make symlinks called "gc"
|
||||||
* and "@10" to it.
|
* and "@10" to it.
|
||||||
|
@ -63,10 +65,9 @@ __proc_device_tree_add_prop(struct proc_dir_entry *de, struct property *pp,
|
||||||
* Unfortunately proc_register puts each new entry
|
* Unfortunately proc_register puts each new entry
|
||||||
* at the beginning of the list. So we rearrange them.
|
* at the beginning of the list. So we rearrange them.
|
||||||
*/
|
*/
|
||||||
ent = create_proc_read_entry(name,
|
ent = proc_create_data(name,
|
||||||
strncmp(name, "security-", 9)
|
strncmp(name, "security-", 9) ? S_IRUGO : S_IRUSR,
|
||||||
? S_IRUGO : S_IRUSR, de,
|
de, &property_proc_fops, pp);
|
||||||
property_read_proc, pp);
|
|
||||||
if (ent == NULL)
|
if (ent == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue