Skip to content

Commit

Permalink
resource: switch to proc_create_seq_data
Browse files Browse the repository at this point in the history
And use the root resource directly from the proc private data.

Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
Christoph Hellwig committed May 16, 2018
1 parent dba5e42 commit 4e292a9
Showing 1 changed file with 5 additions and 38 deletions.
43 changes: 5 additions & 38 deletions kernel/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ enum { MAX_IORES_LEVEL = 5 };
static void *r_start(struct seq_file *m, loff_t *pos)
__acquires(resource_lock)
{
struct resource *p = m->private;
struct resource *p = PDE_DATA(file_inode(m->file));
loff_t l = 0;
read_lock(&resource_lock);
for (p = p->child; p && l < *pos; p = r_next(m, p, &l))
Expand All @@ -103,7 +103,7 @@ static void r_stop(struct seq_file *m, void *v)

static int r_show(struct seq_file *m, void *v)
{
struct resource *root = m->private;
struct resource *root = PDE_DATA(file_inode(m->file));
struct resource *r = v, *p;
unsigned long long start, end;
int width = root->end < 0x10000 ? 4 : 8;
Expand Down Expand Up @@ -135,44 +135,11 @@ static const struct seq_operations resource_op = {
.show = r_show,
};

static int ioports_open(struct inode *inode, struct file *file)
{
int res = seq_open(file, &resource_op);
if (!res) {
struct seq_file *m = file->private_data;
m->private = &ioport_resource;
}
return res;
}

static int iomem_open(struct inode *inode, struct file *file)
{
int res = seq_open(file, &resource_op);
if (!res) {
struct seq_file *m = file->private_data;
m->private = &iomem_resource;
}
return res;
}

static const struct file_operations proc_ioports_operations = {
.open = ioports_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

static const struct file_operations proc_iomem_operations = {
.open = iomem_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

static int __init ioresources_init(void)
{
proc_create("ioports", 0, NULL, &proc_ioports_operations);
proc_create("iomem", 0, NULL, &proc_iomem_operations);
proc_create_seq_data("ioports", 0, NULL, &resource_op,
&ioport_resource);
proc_create_seq_data("iomem", 0, NULL, &resource_op, &iomem_resource);
return 0;
}
__initcall(ioresources_init);
Expand Down

0 comments on commit 4e292a9

Please sign in to comment.