Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Commit

Permalink
proc: introduce proc_create_seq{,_data}
Browse files Browse the repository at this point in the history
Variants of proc_create{,_data} that directly take a struct seq_operations
argument and drastically reduces the boilerplate code in the callers.

All trivial callers converted over.

Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
Christoph Hellwig committed May 16, 2018
1 parent 7aed53d commit fddda2b
Show file tree
Hide file tree
Showing 53 changed files with 151 additions and 925 deletions.
15 changes: 1 addition & 14 deletions arch/ia64/hp/common/sba_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1942,19 +1942,6 @@ static const struct seq_operations ioc_seq_ops = {
.show = ioc_show
};

static int
ioc_open(struct inode *inode, struct file *file)
{
return seq_open(file, &ioc_seq_ops);
}

static const struct file_operations ioc_fops = {
.open = ioc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release
};

static void __init
ioc_proc_init(void)
{
Expand All @@ -1964,7 +1951,7 @@ ioc_proc_init(void)
if (!dir)
return;

proc_create(ioc_list->name, 0, dir, &ioc_fops);
proc_create_seq(ioc_list->name, 0, dir, &ioc_seq_ops);
}
#endif

Expand Down
16 changes: 1 addition & 15 deletions arch/ia64/kernel/perfmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -5708,13 +5708,6 @@ const struct seq_operations pfm_seq_ops = {
.show = pfm_proc_show
};

static int
pfm_proc_open(struct inode *inode, struct file *file)
{
return seq_open(file, &pfm_seq_ops);
}


/*
* we come here as soon as local_cpu_data->pfm_syst_wide is set. this happens
* during pfm_enable() hence before pfm_start(). We cannot assume monitoring
Expand Down Expand Up @@ -6537,13 +6530,6 @@ pfm_probe_pmu(void)
return 0;
}

static const struct file_operations pfm_proc_fops = {
.open = pfm_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

int __init
pfm_init(void)
{
Expand Down Expand Up @@ -6615,7 +6601,7 @@ pfm_init(void)
/*
* create /proc/perfmon (mostly for debugging purposes)
*/
perfmon_dir = proc_create("perfmon", S_IRUGO, NULL, &pfm_proc_fops);
perfmon_dir = proc_create_seq("perfmon", S_IRUGO, NULL, &pfm_seq_ops);
if (perfmon_dir == NULL) {
printk(KERN_ERR "perfmon: cannot create /proc entry, perfmon disabled\n");
pmu_conf = NULL;
Expand Down
14 changes: 1 addition & 13 deletions arch/s390/kernel/sysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,18 +386,6 @@ static const struct seq_operations service_level_seq_ops = {
.show = service_level_show
};

static int service_level_open(struct inode *inode, struct file *file)
{
return seq_open(file, &service_level_seq_ops);
}

static const struct file_operations service_level_ops = {
.open = service_level_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release
};

static void service_level_vm_print(struct seq_file *m,
struct service_level *slr)
{
Expand All @@ -420,7 +408,7 @@ static struct service_level service_level_vm = {

static __init int create_proc_service_level(void)
{
proc_create("service_levels", 0, NULL, &service_level_ops);
proc_create_seq("service_levels", 0, NULL, &service_level_seq_ops);
if (MACHINE_IS_VM)
register_service_level(&service_level_vm);
return 0;
Expand Down
28 changes: 2 additions & 26 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,18 +1027,6 @@ static const struct seq_operations partitions_op = {
.stop = disk_seqf_stop,
.show = show_partition
};

static int partitions_open(struct inode *inode, struct file *file)
{
return seq_open(file, &partitions_op);
}

static const struct file_operations proc_partitions_operations = {
.open = partitions_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
#endif


Expand Down Expand Up @@ -1377,22 +1365,10 @@ static const struct seq_operations diskstats_op = {
.show = diskstats_show
};

static int diskstats_open(struct inode *inode, struct file *file)
{
return seq_open(file, &diskstats_op);
}

static const struct file_operations proc_diskstats_operations = {
.open = diskstats_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

static int __init proc_genhd_init(void)
{
proc_create("diskstats", 0, NULL, &proc_diskstats_operations);
proc_create("partitions", 0, NULL, &proc_partitions_operations);
proc_create_seq("diskstats", 0, NULL, &diskstats_op);
proc_create_seq("partitions", 0, NULL, &partitions_op);
return 0;
}
module_init(proc_genhd_init);
Expand Down
14 changes: 1 addition & 13 deletions crypto/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,9 @@ static const struct seq_operations crypto_seq_ops = {
.show = c_show
};

static int crypto_info_open(struct inode *inode, struct file *file)
{
return seq_open(file, &crypto_seq_ops);
}

static const struct file_operations proc_crypto_ops = {
.open = crypto_info_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release
};

void __init crypto_init_proc(void)
{
proc_create("crypto", 0, NULL, &proc_crypto_ops);
proc_create_seq("crypto", 0, NULL, &crypto_seq_ops);
}

void __exit crypto_exit_proc(void)
Expand Down
15 changes: 1 addition & 14 deletions drivers/char/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,6 @@ static const struct seq_operations misc_seq_ops = {
.stop = misc_seq_stop,
.show = misc_seq_show,
};

static int misc_seq_open(struct inode *inode, struct file *file)
{
return seq_open(file, &misc_seq_ops);
}

static const struct file_operations misc_proc_fops = {
.owner = THIS_MODULE,
.open = misc_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
#endif

static int misc_open(struct inode *inode, struct file *file)
Expand Down Expand Up @@ -282,7 +269,7 @@ static int __init misc_init(void)
int err;
struct proc_dir_entry *ret;

ret = proc_create("misc", 0, NULL, &misc_proc_fops);
ret = proc_create_seq("misc", 0, NULL, &misc_seq_ops);
misc_class = class_create(THIS_MODULE, "misc");
err = PTR_ERR(misc_class);
if (IS_ERR(misc_class))
Expand Down
80 changes: 5 additions & 75 deletions drivers/isdn/capi/kcapi_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,32 +108,6 @@ static const struct seq_operations seq_contrstats_ops = {
.show = contrstats_show,
};

static int seq_controller_open(struct inode *inode, struct file *file)
{
return seq_open(file, &seq_controller_ops);
}

static int seq_contrstats_open(struct inode *inode, struct file *file)
{
return seq_open(file, &seq_contrstats_ops);
}

static const struct file_operations proc_controller_ops = {
.owner = THIS_MODULE,
.open = seq_controller_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

static const struct file_operations proc_contrstats_ops = {
.owner = THIS_MODULE,
.open = seq_contrstats_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

// /proc/capi/applications:
// applid l3cnt dblkcnt dblklen #ncci recvqueuelen
// /proc/capi/applstats:
Expand Down Expand Up @@ -216,34 +190,6 @@ static const struct seq_operations seq_applstats_ops = {
.show = applstats_show,
};

static int
seq_applications_open(struct inode *inode, struct file *file)
{
return seq_open(file, &seq_applications_ops);
}

static int
seq_applstats_open(struct inode *inode, struct file *file)
{
return seq_open(file, &seq_applstats_ops);
}

static const struct file_operations proc_applications_ops = {
.owner = THIS_MODULE,
.open = seq_applications_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

static const struct file_operations proc_applstats_ops = {
.owner = THIS_MODULE,
.open = seq_applstats_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

// ---------------------------------------------------------------------------

static void *capi_driver_start(struct seq_file *seq, loff_t *pos)
Expand Down Expand Up @@ -279,34 +225,18 @@ static const struct seq_operations seq_capi_driver_ops = {
.show = capi_driver_show,
};

static int
seq_capi_driver_open(struct inode *inode, struct file *file)
{
int err;
err = seq_open(file, &seq_capi_driver_ops);
return err;
}

static const struct file_operations proc_driver_ops = {
.owner = THIS_MODULE,
.open = seq_capi_driver_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

// ---------------------------------------------------------------------------

void __init
kcapi_proc_init(void)
{
proc_mkdir("capi", NULL);
proc_mkdir("capi/controllers", NULL);
proc_create("capi/controller", 0, NULL, &proc_controller_ops);
proc_create("capi/contrstats", 0, NULL, &proc_contrstats_ops);
proc_create("capi/applications", 0, NULL, &proc_applications_ops);
proc_create("capi/applstats", 0, NULL, &proc_applstats_ops);
proc_create("capi/driver", 0, NULL, &proc_driver_ops);
proc_create_seq("capi/controller", 0, NULL, &seq_controller_ops);
proc_create_seq("capi/contrstats", 0, NULL, &seq_contrstats_ops);
proc_create_seq("capi/applications", 0, NULL, &seq_applications_ops);
proc_create_seq("capi/applstats", 0, NULL, &seq_applstats_ops);
proc_create_seq("capi/driver", 0, NULL, &seq_capi_driver_ops);
}

void __exit
Expand Down
16 changes: 1 addition & 15 deletions drivers/net/hamradio/bpqether.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,20 +449,6 @@ static const struct seq_operations bpq_seqops = {
.show = bpq_seq_show,
};

static int bpq_info_open(struct inode *inode, struct file *file)
{
return seq_open(file, &bpq_seqops);
}

static const struct file_operations bpq_info_fops = {
.owner = THIS_MODULE,
.open = bpq_info_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};


/* ------------------------------------------------------------------------ */

static const struct net_device_ops bpq_netdev_ops = {
Expand Down Expand Up @@ -590,7 +576,7 @@ static int bpq_device_event(struct notifier_block *this,
static int __init bpq_init_driver(void)
{
#ifdef CONFIG_PROC_FS
if (!proc_create("bpqether", 0444, init_net.proc_net, &bpq_info_fops)) {
if (!proc_create_seq("bpqether", 0444, init_net.proc_net, &bpq_seqops)) {
printk(KERN_ERR
"bpq: cannot create /proc/net/bpqether entry.\n");
return -ENOENT;
Expand Down
17 changes: 1 addition & 16 deletions drivers/net/hamradio/scc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2084,21 +2084,6 @@ static const struct seq_operations scc_net_seq_ops = {
.stop = scc_net_seq_stop,
.show = scc_net_seq_show,
};


static int scc_net_seq_open(struct inode *inode, struct file *file)
{
return seq_open(file, &scc_net_seq_ops);
}

static const struct file_operations scc_net_seq_fops = {
.owner = THIS_MODULE,
.open = scc_net_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release_private,
};

#endif /* CONFIG_PROC_FS */


Expand All @@ -2122,7 +2107,7 @@ static int __init scc_init_driver (void)
}
rtnl_unlock();

proc_create("z8530drv", 0, init_net.proc_net, &scc_net_seq_fops);
proc_create_seq("z8530drv", 0, init_net.proc_net, &scc_net_seq_ops);

return 0;
}
Expand Down
16 changes: 1 addition & 15 deletions drivers/net/hamradio/yam.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,20 +841,6 @@ static const struct seq_operations yam_seqops = {
.stop = yam_seq_stop,
.show = yam_seq_show,
};

static int yam_info_open(struct inode *inode, struct file *file)
{
return seq_open(file, &yam_seqops);
}

static const struct file_operations yam_info_fops = {
.owner = THIS_MODULE,
.open = yam_info_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

#endif


Expand Down Expand Up @@ -1168,7 +1154,7 @@ static int __init yam_init_driver(void)
yam_timer.expires = jiffies + HZ / 100;
add_timer(&yam_timer);

proc_create("yam", 0444, init_net.proc_net, &yam_info_fops);
proc_create_seq("yam", 0444, init_net.proc_net, &yam_seqops);
return 0;
error:
while (--i >= 0) {
Expand Down
Loading

0 comments on commit fddda2b

Please sign in to comment.