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 <[email protected]>
This commit is contained in:
Christoph Hellwig 2018-05-15 15:57:23 +02:00
commit 3f3942aca6
85 changed files with 235 additions and 1509 deletions

View file

@ -6451,19 +6451,6 @@ static int dac960_proc_show(struct seq_file *m, void *v)
return 0;
}
static int dac960_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, dac960_proc_show, NULL);
}
static const struct file_operations dac960_proc_fops = {
.owner = THIS_MODULE,
.open = dac960_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int dac960_initial_status_proc_show(struct seq_file *m, void *v)
{
DAC960_Controller_T *Controller = (DAC960_Controller_T *)m->private;
@ -6471,19 +6458,6 @@ static int dac960_initial_status_proc_show(struct seq_file *m, void *v)
return 0;
}
static int dac960_initial_status_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, dac960_initial_status_proc_show, PDE_DATA(inode));
}
static const struct file_operations dac960_initial_status_proc_fops = {
.owner = THIS_MODULE,
.open = dac960_initial_status_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int dac960_current_status_proc_show(struct seq_file *m, void *v)
{
DAC960_Controller_T *Controller = (DAC960_Controller_T *) m->private;
@ -6517,19 +6491,6 @@ static int dac960_current_status_proc_show(struct seq_file *m, void *v)
return 0;
}
static int dac960_current_status_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, dac960_current_status_proc_show, PDE_DATA(inode));
}
static const struct file_operations dac960_current_status_proc_fops = {
.owner = THIS_MODULE,
.open = dac960_current_status_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int dac960_user_command_proc_show(struct seq_file *m, void *v)
{
DAC960_Controller_T *Controller = (DAC960_Controller_T *)m->private;
@ -6584,16 +6545,18 @@ static void DAC960_CreateProcEntries(DAC960_Controller_T *Controller)
if (DAC960_ProcDirectoryEntry == NULL) {
DAC960_ProcDirectoryEntry = proc_mkdir("rd", NULL);
proc_create("status", 0, DAC960_ProcDirectoryEntry,
&dac960_proc_fops);
proc_create_single("status", 0, DAC960_ProcDirectoryEntry,
dac960_proc_show);
}
snprintf(Controller->ControllerName, sizeof(Controller->ControllerName),
"c%d", Controller->ControllerNumber);
ControllerProcEntry = proc_mkdir(Controller->ControllerName,
DAC960_ProcDirectoryEntry);
proc_create_data("initial_status", 0, ControllerProcEntry, &dac960_initial_status_proc_fops, Controller);
proc_create_data("current_status", 0, ControllerProcEntry, &dac960_current_status_proc_fops, Controller);
proc_create_single_data("initial_status", 0, ControllerProcEntry,
dac960_initial_status_proc_show, Controller);
proc_create_single_data("current_status", 0, ControllerProcEntry,
dac960_current_status_proc_show, Controller);
proc_create_data("user_command", S_IWUSR | S_IRUSR, ControllerProcEntry, &dac960_user_command_proc_fops, Controller);
Controller->ControllerProcEntry = ControllerProcEntry;
}

View file

@ -2538,18 +2538,6 @@ static int pkt_seq_show(struct seq_file *m, void *p)
return 0;
}
static int pkt_seq_open(struct inode *inode, struct file *file)
{
return single_open(file, pkt_seq_show, PDE_DATA(inode));
}
static const struct file_operations pkt_proc_fops = {
.open = pkt_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release
};
static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
{
int i;
@ -2604,7 +2592,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
goto out_mem;
}
proc_create_data(pd->name, 0, pkt_proc, &pkt_proc_fops, pd);
proc_create_single_data(pd->name, 0, pkt_proc, pkt_seq_show, pd);
pkt_dbg(1, pd, "writer mapped to %s\n", bdevname(bdev, b));
return 0;

View file

@ -521,26 +521,13 @@ static int ps3vram_proc_show(struct seq_file *m, void *v)
return 0;
}
static int ps3vram_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, ps3vram_proc_show, PDE_DATA(inode));
}
static const struct file_operations ps3vram_proc_fops = {
.owner = THIS_MODULE,
.open = ps3vram_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static void ps3vram_proc_init(struct ps3_system_bus_device *dev)
{
struct ps3vram_priv *priv = ps3_system_bus_get_drvdata(dev);
struct proc_dir_entry *pde;
pde = proc_create_data(DEVICE_NAME, 0444, NULL, &ps3vram_proc_fops,
priv);
pde = proc_create_single_data(DEVICE_NAME, 0444, NULL,
ps3vram_proc_show, priv);
if (!pde)
dev_warn(&dev->core, "failed to create /proc entry\n");
}