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>
This commit is contained in:
@@ -191,10 +191,10 @@ static int init_pmu(void);
|
||||
static void pmu_start(void);
|
||||
static irqreturn_t via_pmu_interrupt(int irq, void *arg);
|
||||
static irqreturn_t gpio1_interrupt(int irq, void *arg);
|
||||
static const struct file_operations pmu_info_proc_fops;
|
||||
static const struct file_operations pmu_irqstats_proc_fops;
|
||||
static int pmu_info_proc_show(struct seq_file *m, void *v);
|
||||
static int pmu_irqstats_proc_show(struct seq_file *m, void *v);
|
||||
static int pmu_battery_proc_show(struct seq_file *m, void *v);
|
||||
static void pmu_pass_intr(unsigned char *data, int len);
|
||||
static const struct file_operations pmu_battery_proc_fops;
|
||||
static const struct file_operations pmu_options_proc_fops;
|
||||
|
||||
#ifdef CONFIG_ADB
|
||||
@@ -511,13 +511,15 @@ static int __init via_pmu_dev_init(void)
|
||||
for (i=0; i<pmu_battery_count; i++) {
|
||||
char title[16];
|
||||
sprintf(title, "battery_%ld", i);
|
||||
proc_pmu_batt[i] = proc_create_data(title, 0, proc_pmu_root,
|
||||
&pmu_battery_proc_fops, (void *)i);
|
||||
proc_pmu_batt[i] = proc_create_single_data(title, 0,
|
||||
proc_pmu_root, pmu_battery_proc_show,
|
||||
(void *)i);
|
||||
}
|
||||
|
||||
proc_pmu_info = proc_create("info", 0, proc_pmu_root, &pmu_info_proc_fops);
|
||||
proc_pmu_irqstats = proc_create("interrupts", 0, proc_pmu_root,
|
||||
&pmu_irqstats_proc_fops);
|
||||
proc_pmu_info = proc_create_single("info", 0, proc_pmu_root,
|
||||
pmu_info_proc_show);
|
||||
proc_pmu_irqstats = proc_create_single("interrupts", 0,
|
||||
proc_pmu_root, pmu_irqstats_proc_show);
|
||||
proc_pmu_options = proc_create("options", 0600, proc_pmu_root,
|
||||
&pmu_options_proc_fops);
|
||||
}
|
||||
@@ -811,19 +813,6 @@ static int pmu_info_proc_show(struct seq_file *m, void *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pmu_info_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, pmu_info_proc_show, NULL);
|
||||
}
|
||||
|
||||
static const struct file_operations pmu_info_proc_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = pmu_info_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
static int pmu_irqstats_proc_show(struct seq_file *m, void *v)
|
||||
{
|
||||
int i;
|
||||
@@ -848,19 +837,6 @@ static int pmu_irqstats_proc_show(struct seq_file *m, void *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pmu_irqstats_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, pmu_irqstats_proc_show, NULL);
|
||||
}
|
||||
|
||||
static const struct file_operations pmu_irqstats_proc_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = pmu_irqstats_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
static int pmu_battery_proc_show(struct seq_file *m, void *v)
|
||||
{
|
||||
long batnum = (long)m->private;
|
||||
@@ -875,19 +851,6 @@ static int pmu_battery_proc_show(struct seq_file *m, void *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pmu_battery_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, pmu_battery_proc_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static const struct file_operations pmu_battery_proc_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = pmu_battery_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
static int pmu_options_proc_show(struct seq_file *m, void *v)
|
||||
{
|
||||
#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32)
|
||||
|
Viittaa uudesa ongelmassa
Block a user