Blackfin: cplbinfo: drop d_path() hacks
The cplbinfo was using d_path() to figure out which cpu/cplb was being parsed. As Al pointed out, this isn't exactly reliable as it assumes the static VFS path to be unchanged, and it's just poor form. So use the proc_create_data() to properly (and internally) pass the exact cpu/cplb requested to the parser function. Reported-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
@@ -112,24 +112,21 @@ static const struct seq_operations cplbinfo_sops = {
|
|||||||
.show = cplbinfo_show,
|
.show = cplbinfo_show,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define CPLBINFO_DCPLB_FLAG 0x80000000
|
||||||
|
|
||||||
static int cplbinfo_open(struct inode *inode, struct file *file)
|
static int cplbinfo_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
char buf[256], *path, *p;
|
struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
|
||||||
|
char cplb_type;
|
||||||
unsigned int cpu;
|
unsigned int cpu;
|
||||||
char *s_cpu, *s_cplb;
|
|
||||||
int ret;
|
int ret;
|
||||||
struct seq_file *m;
|
struct seq_file *m;
|
||||||
struct cplbinfo_data *cdata;
|
struct cplbinfo_data *cdata;
|
||||||
|
|
||||||
path = d_path(&file->f_path, buf, sizeof(buf));
|
cpu = (unsigned int)pde->data;
|
||||||
if (IS_ERR(path))
|
cplb_type = cpu & CPLBINFO_DCPLB_FLAG ? 'D' : 'I';
|
||||||
return PTR_ERR(path);
|
cpu &= ~CPLBINFO_DCPLB_FLAG;
|
||||||
s_cpu = strstr(path, "/cpu");
|
|
||||||
s_cplb = strrchr(path, '/');
|
|
||||||
if (!s_cpu || !s_cplb)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
cpu = simple_strtoul(s_cpu + 4, &p, 10);
|
|
||||||
if (!cpu_online(cpu))
|
if (!cpu_online(cpu))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
@@ -140,7 +137,7 @@ static int cplbinfo_open(struct inode *inode, struct file *file)
|
|||||||
cdata = m->private;
|
cdata = m->private;
|
||||||
|
|
||||||
cdata->pos = 0;
|
cdata->pos = 0;
|
||||||
cdata->cplb_type = toupper(s_cplb[1]);
|
cdata->cplb_type = cplb_type;
|
||||||
cplbinfo_seq_init(cdata, cpu);
|
cplbinfo_seq_init(cdata, cpu);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -169,8 +166,10 @@ static int __init cplbinfo_init(void)
|
|||||||
if (!cpu_dir)
|
if (!cpu_dir)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
proc_create("icplb", S_IRUGO, cpu_dir, &cplbinfo_fops);
|
proc_create_data("icplb", S_IRUGO, cpu_dir, &cplbinfo_fops,
|
||||||
proc_create("dcplb", S_IRUGO, cpu_dir, &cplbinfo_fops);
|
(void *)cpu);
|
||||||
|
proc_create_data("dcplb", S_IRUGO, cpu_dir, &cplbinfo_fops,
|
||||||
|
(void *)(cpu | CPLBINFO_DCPLB_FLAG));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user