proc: introduce proc_create_single{,_data}
Variants of proc_create{,_data} that directly take a seq_file show callback and drastically reduces the boilerplate code in the callers. All trivial callers converted over. Signed-off-by: Christoph Hellwig <hch@lst.de>
Este commit está contenido en:
@@ -1340,19 +1340,6 @@ static int capi20_proc_show(struct seq_file *m, void *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int capi20_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, capi20_proc_show, NULL);
|
||||
}
|
||||
|
||||
static const struct file_operations capi20_proc_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = capi20_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
/*
|
||||
* /proc/capi/capi20ncci:
|
||||
* applid ncci
|
||||
@@ -1373,23 +1360,10 @@ static int capi20ncci_proc_show(struct seq_file *m, void *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int capi20ncci_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, capi20ncci_proc_show, NULL);
|
||||
}
|
||||
|
||||
static const struct file_operations capi20ncci_proc_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = capi20ncci_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
static void __init proc_init(void)
|
||||
{
|
||||
proc_create("capi/capi20", 0, NULL, &capi20_proc_fops);
|
||||
proc_create("capi/capi20ncci", 0, NULL, &capi20ncci_proc_fops);
|
||||
proc_create_single("capi/capi20", 0, NULL, capi20_proc_show);
|
||||
proc_create_single("capi/capi20ncci", 0, NULL, capi20ncci_proc_show);
|
||||
}
|
||||
|
||||
static void __exit proc_exit(void)
|
||||
|
@@ -2460,22 +2460,9 @@ static int capidrv_proc_show(struct seq_file *m, void *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int capidrv_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, capidrv_proc_show, NULL);
|
||||
}
|
||||
|
||||
static const struct file_operations capidrv_proc_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = capidrv_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
static void __init proc_init(void)
|
||||
{
|
||||
proc_create("capi/capidrv", 0, NULL, &capidrv_proc_fops);
|
||||
proc_create_single("capi/capidrv", 0, NULL, capidrv_proc_show);
|
||||
}
|
||||
|
||||
static void __exit proc_exit(void)
|
||||
|
@@ -78,26 +78,13 @@ static int divadidd_proc_show(struct seq_file *m, void *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int divadidd_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, divadidd_proc_show, NULL);
|
||||
}
|
||||
|
||||
static const struct file_operations divadidd_proc_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = divadidd_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
static int __init create_proc(void)
|
||||
{
|
||||
proc_net_eicon = proc_mkdir("eicon", init_net.proc_net);
|
||||
|
||||
if (proc_net_eicon) {
|
||||
proc_didd = proc_create(DRIVERLNAME, S_IRUGO, proc_net_eicon,
|
||||
&divadidd_proc_fops);
|
||||
proc_didd = proc_create_single(DRIVERLNAME, S_IRUGO,
|
||||
proc_net_eicon, divadidd_proc_show);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
|
@@ -101,23 +101,10 @@ static int um_idi_proc_show(struct seq_file *m, void *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int um_idi_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, um_idi_proc_show, NULL);
|
||||
}
|
||||
|
||||
static const struct file_operations um_idi_proc_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = um_idi_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
static int __init create_um_idi_proc(void)
|
||||
{
|
||||
um_idi_proc_entry = proc_create(DRIVERLNAME, S_IRUGO, proc_net_eicon,
|
||||
&um_idi_proc_fops);
|
||||
um_idi_proc_entry = proc_create_single(DRIVERLNAME, S_IRUGO,
|
||||
proc_net_eicon, um_idi_proc_show);
|
||||
if (!um_idi_proc_entry)
|
||||
return (0);
|
||||
return (1);
|
||||
|
Referencia en una nueva incidencia
Block a user