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>
Этот коммит содержится в:
@@ -218,9 +218,9 @@ extern const struct proc_ns_operations cgroupns_operations;
|
||||
* cgroup-v1.c
|
||||
*/
|
||||
extern struct cftype cgroup1_base_files[];
|
||||
extern const struct file_operations proc_cgroupstats_operations;
|
||||
extern struct kernfs_syscall_ops cgroup1_kf_syscall_ops;
|
||||
|
||||
int proc_cgroupstats_show(struct seq_file *m, void *v);
|
||||
bool cgroup1_ssid_disabled(int ssid);
|
||||
void cgroup1_pidlist_destroy_all(struct cgroup *cgrp);
|
||||
void cgroup1_release_agent(struct work_struct *work);
|
||||
|
@@ -682,7 +682,7 @@ struct cftype cgroup1_base_files[] = {
|
||||
};
|
||||
|
||||
/* Display information about each subsystem and each hierarchy */
|
||||
static int proc_cgroupstats_show(struct seq_file *m, void *v)
|
||||
int proc_cgroupstats_show(struct seq_file *m, void *v)
|
||||
{
|
||||
struct cgroup_subsys *ss;
|
||||
int i;
|
||||
@@ -705,18 +705,6 @@ static int proc_cgroupstats_show(struct seq_file *m, void *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cgroupstats_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, proc_cgroupstats_show, NULL);
|
||||
}
|
||||
|
||||
const struct file_operations proc_cgroupstats_operations = {
|
||||
.open = cgroupstats_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
/**
|
||||
* cgroupstats_build - build and fill cgroupstats
|
||||
* @stats: cgroupstats to fill information into
|
||||
|
@@ -5335,7 +5335,7 @@ int __init cgroup_init(void)
|
||||
WARN_ON(sysfs_create_mount_point(fs_kobj, "cgroup"));
|
||||
WARN_ON(register_filesystem(&cgroup_fs_type));
|
||||
WARN_ON(register_filesystem(&cgroup2_fs_type));
|
||||
WARN_ON(!proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations));
|
||||
WARN_ON(!proc_create_single("cgroups", 0, NULL, proc_cgroupstats_show));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
14
kernel/dma.c
14
kernel/dma.c
@@ -135,21 +135,9 @@ static int proc_dma_show(struct seq_file *m, void *v)
|
||||
}
|
||||
#endif /* MAX_DMA_CHANNELS */
|
||||
|
||||
static int proc_dma_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, proc_dma_show, NULL);
|
||||
}
|
||||
|
||||
static const struct file_operations proc_dma_operations = {
|
||||
.open = proc_dma_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
static int __init proc_dma_init(void)
|
||||
{
|
||||
proc_create("dma", 0, NULL, &proc_dma_operations);
|
||||
proc_create_single("dma", 0, NULL, proc_dma_show);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -27,21 +27,9 @@ static int execdomains_proc_show(struct seq_file *m, void *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int execdomains_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, execdomains_proc_show, NULL);
|
||||
}
|
||||
|
||||
static const struct file_operations execdomains_proc_fops = {
|
||||
.open = execdomains_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
static int __init proc_execdomains_init(void)
|
||||
{
|
||||
proc_create("execdomains", 0, NULL, &execdomains_proc_fops);
|
||||
proc_create_single("execdomains", 0, NULL, execdomains_proc_show);
|
||||
return 0;
|
||||
}
|
||||
module_init(proc_execdomains_init);
|
||||
|
@@ -185,11 +185,6 @@ static int irq_affinity_list_proc_open(struct inode *inode, struct file *file)
|
||||
return single_open(file, irq_affinity_list_proc_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static int irq_affinity_hint_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, irq_affinity_hint_proc_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static const struct file_operations irq_affinity_proc_fops = {
|
||||
.open = irq_affinity_proc_open,
|
||||
.read = seq_read,
|
||||
@@ -198,13 +193,6 @@ static const struct file_operations irq_affinity_proc_fops = {
|
||||
.write = irq_affinity_proc_write,
|
||||
};
|
||||
|
||||
static const struct file_operations irq_affinity_hint_proc_fops = {
|
||||
.open = irq_affinity_hint_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
static const struct file_operations irq_affinity_list_proc_fops = {
|
||||
.open = irq_affinity_list_proc_open,
|
||||
.read = seq_read,
|
||||
@@ -223,32 +211,6 @@ static int irq_effective_aff_list_proc_show(struct seq_file *m, void *v)
|
||||
{
|
||||
return show_irq_affinity(EFFECTIVE_LIST, m);
|
||||
}
|
||||
|
||||
static int irq_effective_aff_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, irq_effective_aff_proc_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static int irq_effective_aff_list_proc_open(struct inode *inode,
|
||||
struct file *file)
|
||||
{
|
||||
return single_open(file, irq_effective_aff_list_proc_show,
|
||||
PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static const struct file_operations irq_effective_aff_proc_fops = {
|
||||
.open = irq_effective_aff_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
static const struct file_operations irq_effective_aff_list_proc_fops = {
|
||||
.open = irq_effective_aff_list_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
#endif
|
||||
|
||||
static int default_affinity_show(struct seq_file *m, void *v)
|
||||
@@ -313,18 +275,6 @@ static int irq_node_proc_show(struct seq_file *m, void *v)
|
||||
seq_printf(m, "%d\n", irq_desc_get_node(desc));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int irq_node_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, irq_node_proc_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static const struct file_operations irq_node_proc_fops = {
|
||||
.open = irq_node_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
#endif
|
||||
|
||||
static int irq_spurious_proc_show(struct seq_file *m, void *v)
|
||||
@@ -337,18 +287,6 @@ static int irq_spurious_proc_show(struct seq_file *m, void *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int irq_spurious_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, irq_spurious_proc_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static const struct file_operations irq_spurious_proc_fops = {
|
||||
.open = irq_spurious_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
#define MAX_NAMELEN 128
|
||||
|
||||
static int name_unique(unsigned int irq, struct irqaction *new_action)
|
||||
@@ -421,24 +359,24 @@ void register_irq_proc(unsigned int irq, struct irq_desc *desc)
|
||||
&irq_affinity_proc_fops, irqp);
|
||||
|
||||
/* create /proc/irq/<irq>/affinity_hint */
|
||||
proc_create_data("affinity_hint", 0444, desc->dir,
|
||||
&irq_affinity_hint_proc_fops, irqp);
|
||||
proc_create_single_data("affinity_hint", 0444, desc->dir,
|
||||
irq_affinity_hint_proc_show, irqp);
|
||||
|
||||
/* create /proc/irq/<irq>/smp_affinity_list */
|
||||
proc_create_data("smp_affinity_list", 0644, desc->dir,
|
||||
&irq_affinity_list_proc_fops, irqp);
|
||||
|
||||
proc_create_data("node", 0444, desc->dir,
|
||||
&irq_node_proc_fops, irqp);
|
||||
proc_create_single_data("node", 0444, desc->dir, irq_node_proc_show,
|
||||
irqp);
|
||||
# ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK
|
||||
proc_create_data("effective_affinity", 0444, desc->dir,
|
||||
&irq_effective_aff_proc_fops, irqp);
|
||||
proc_create_data("effective_affinity_list", 0444, desc->dir,
|
||||
&irq_effective_aff_list_proc_fops, irqp);
|
||||
proc_create_single_data("effective_affinity", 0444, desc->dir,
|
||||
irq_effective_aff_proc_show, irqp);
|
||||
proc_create_single_data("effective_affinity_list", 0444, desc->dir,
|
||||
irq_effective_aff_list_proc_show, irqp);
|
||||
# endif
|
||||
#endif
|
||||
proc_create_data("spurious", 0444, desc->dir,
|
||||
&irq_spurious_proc_fops, (void *)(long)irq);
|
||||
proc_create_single_data("spurious", 0444, desc->dir,
|
||||
irq_spurious_proc_show, (void *)(long)irq);
|
||||
|
||||
out_unlock:
|
||||
mutex_unlock(®ister_lock);
|
||||
|
@@ -331,18 +331,6 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lockdep_stats_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, lockdep_stats_show, NULL);
|
||||
}
|
||||
|
||||
static const struct file_operations proc_lockdep_stats_operations = {
|
||||
.open = lockdep_stats_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_LOCK_STAT
|
||||
|
||||
struct lock_stat_data {
|
||||
@@ -662,9 +650,7 @@ static int __init lockdep_proc_init(void)
|
||||
#ifdef CONFIG_PROVE_LOCKING
|
||||
proc_create_seq("lockdep_chains", S_IRUSR, NULL, &lockdep_chains_ops);
|
||||
#endif
|
||||
proc_create("lockdep_stats", S_IRUSR, NULL,
|
||||
&proc_lockdep_stats_operations);
|
||||
|
||||
proc_create_single("lockdep_stats", S_IRUSR, NULL, lockdep_stats_show);
|
||||
#ifdef CONFIG_LOCK_STAT
|
||||
proc_create("lock_stat", S_IRUSR | S_IWUSR, NULL,
|
||||
&proc_lock_stat_operations);
|
||||
|
Ссылка в новой задаче
Block a user