Skip to content

Commit fddda2b

Browse files
author
Christoph Hellwig
committed
proc: introduce proc_create_seq{,_data}
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]>
1 parent 7aed53d commit fddda2b

File tree

53 files changed

+151
-925
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+151
-925
lines changed

arch/ia64/hp/common/sba_iommu.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,19 +1942,6 @@ static const struct seq_operations ioc_seq_ops = {
19421942
.show = ioc_show
19431943
};
19441944

1945-
static int
1946-
ioc_open(struct inode *inode, struct file *file)
1947-
{
1948-
return seq_open(file, &ioc_seq_ops);
1949-
}
1950-
1951-
static const struct file_operations ioc_fops = {
1952-
.open = ioc_open,
1953-
.read = seq_read,
1954-
.llseek = seq_lseek,
1955-
.release = seq_release
1956-
};
1957-
19581945
static void __init
19591946
ioc_proc_init(void)
19601947
{
@@ -1964,7 +1951,7 @@ ioc_proc_init(void)
19641951
if (!dir)
19651952
return;
19661953

1967-
proc_create(ioc_list->name, 0, dir, &ioc_fops);
1954+
proc_create_seq(ioc_list->name, 0, dir, &ioc_seq_ops);
19681955
}
19691956
#endif
19701957

arch/ia64/kernel/perfmon.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5708,13 +5708,6 @@ const struct seq_operations pfm_seq_ops = {
57085708
.show = pfm_proc_show
57095709
};
57105710

5711-
static int
5712-
pfm_proc_open(struct inode *inode, struct file *file)
5713-
{
5714-
return seq_open(file, &pfm_seq_ops);
5715-
}
5716-
5717-
57185711
/*
57195712
* we come here as soon as local_cpu_data->pfm_syst_wide is set. this happens
57205713
* during pfm_enable() hence before pfm_start(). We cannot assume monitoring
@@ -6537,13 +6530,6 @@ pfm_probe_pmu(void)
65376530
return 0;
65386531
}
65396532

6540-
static const struct file_operations pfm_proc_fops = {
6541-
.open = pfm_proc_open,
6542-
.read = seq_read,
6543-
.llseek = seq_lseek,
6544-
.release = seq_release,
6545-
};
6546-
65476533
int __init
65486534
pfm_init(void)
65496535
{
@@ -6615,7 +6601,7 @@ pfm_init(void)
66156601
/*
66166602
* create /proc/perfmon (mostly for debugging purposes)
66176603
*/
6618-
perfmon_dir = proc_create("perfmon", S_IRUGO, NULL, &pfm_proc_fops);
6604+
perfmon_dir = proc_create_seq("perfmon", S_IRUGO, NULL, &pfm_seq_ops);
66196605
if (perfmon_dir == NULL) {
66206606
printk(KERN_ERR "perfmon: cannot create /proc entry, perfmon disabled\n");
66216607
pmu_conf = NULL;

arch/s390/kernel/sysinfo.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -386,18 +386,6 @@ static const struct seq_operations service_level_seq_ops = {
386386
.show = service_level_show
387387
};
388388

389-
static int service_level_open(struct inode *inode, struct file *file)
390-
{
391-
return seq_open(file, &service_level_seq_ops);
392-
}
393-
394-
static const struct file_operations service_level_ops = {
395-
.open = service_level_open,
396-
.read = seq_read,
397-
.llseek = seq_lseek,
398-
.release = seq_release
399-
};
400-
401389
static void service_level_vm_print(struct seq_file *m,
402390
struct service_level *slr)
403391
{
@@ -420,7 +408,7 @@ static struct service_level service_level_vm = {
420408

421409
static __init int create_proc_service_level(void)
422410
{
423-
proc_create("service_levels", 0, NULL, &service_level_ops);
411+
proc_create_seq("service_levels", 0, NULL, &service_level_seq_ops);
424412
if (MACHINE_IS_VM)
425413
register_service_level(&service_level_vm);
426414
return 0;

block/genhd.c

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,18 +1027,6 @@ static const struct seq_operations partitions_op = {
10271027
.stop = disk_seqf_stop,
10281028
.show = show_partition
10291029
};
1030-
1031-
static int partitions_open(struct inode *inode, struct file *file)
1032-
{
1033-
return seq_open(file, &partitions_op);
1034-
}
1035-
1036-
static const struct file_operations proc_partitions_operations = {
1037-
.open = partitions_open,
1038-
.read = seq_read,
1039-
.llseek = seq_lseek,
1040-
.release = seq_release,
1041-
};
10421030
#endif
10431031

10441032

@@ -1377,22 +1365,10 @@ static const struct seq_operations diskstats_op = {
13771365
.show = diskstats_show
13781366
};
13791367

1380-
static int diskstats_open(struct inode *inode, struct file *file)
1381-
{
1382-
return seq_open(file, &diskstats_op);
1383-
}
1384-
1385-
static const struct file_operations proc_diskstats_operations = {
1386-
.open = diskstats_open,
1387-
.read = seq_read,
1388-
.llseek = seq_lseek,
1389-
.release = seq_release,
1390-
};
1391-
13921368
static int __init proc_genhd_init(void)
13931369
{
1394-
proc_create("diskstats", 0, NULL, &proc_diskstats_operations);
1395-
proc_create("partitions", 0, NULL, &proc_partitions_operations);
1370+
proc_create_seq("diskstats", 0, NULL, &diskstats_op);
1371+
proc_create_seq("partitions", 0, NULL, &partitions_op);
13961372
return 0;
13971373
}
13981374
module_init(proc_genhd_init);

crypto/proc.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,9 @@ static const struct seq_operations crypto_seq_ops = {
9494
.show = c_show
9595
};
9696

97-
static int crypto_info_open(struct inode *inode, struct file *file)
98-
{
99-
return seq_open(file, &crypto_seq_ops);
100-
}
101-
102-
static const struct file_operations proc_crypto_ops = {
103-
.open = crypto_info_open,
104-
.read = seq_read,
105-
.llseek = seq_lseek,
106-
.release = seq_release
107-
};
108-
10997
void __init crypto_init_proc(void)
11098
{
111-
proc_create("crypto", 0, NULL, &proc_crypto_ops);
99+
proc_create_seq("crypto", 0, NULL, &crypto_seq_ops);
112100
}
113101

114102
void __exit crypto_exit_proc(void)

drivers/char/misc.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,6 @@ static const struct seq_operations misc_seq_ops = {
9595
.stop = misc_seq_stop,
9696
.show = misc_seq_show,
9797
};
98-
99-
static int misc_seq_open(struct inode *inode, struct file *file)
100-
{
101-
return seq_open(file, &misc_seq_ops);
102-
}
103-
104-
static const struct file_operations misc_proc_fops = {
105-
.owner = THIS_MODULE,
106-
.open = misc_seq_open,
107-
.read = seq_read,
108-
.llseek = seq_lseek,
109-
.release = seq_release,
110-
};
11198
#endif
11299

113100
static int misc_open(struct inode *inode, struct file *file)
@@ -282,7 +269,7 @@ static int __init misc_init(void)
282269
int err;
283270
struct proc_dir_entry *ret;
284271

285-
ret = proc_create("misc", 0, NULL, &misc_proc_fops);
272+
ret = proc_create_seq("misc", 0, NULL, &misc_seq_ops);
286273
misc_class = class_create(THIS_MODULE, "misc");
287274
err = PTR_ERR(misc_class);
288275
if (IS_ERR(misc_class))

drivers/isdn/capi/kcapi_proc.c

Lines changed: 5 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -108,32 +108,6 @@ static const struct seq_operations seq_contrstats_ops = {
108108
.show = contrstats_show,
109109
};
110110

111-
static int seq_controller_open(struct inode *inode, struct file *file)
112-
{
113-
return seq_open(file, &seq_controller_ops);
114-
}
115-
116-
static int seq_contrstats_open(struct inode *inode, struct file *file)
117-
{
118-
return seq_open(file, &seq_contrstats_ops);
119-
}
120-
121-
static const struct file_operations proc_controller_ops = {
122-
.owner = THIS_MODULE,
123-
.open = seq_controller_open,
124-
.read = seq_read,
125-
.llseek = seq_lseek,
126-
.release = seq_release,
127-
};
128-
129-
static const struct file_operations proc_contrstats_ops = {
130-
.owner = THIS_MODULE,
131-
.open = seq_contrstats_open,
132-
.read = seq_read,
133-
.llseek = seq_lseek,
134-
.release = seq_release,
135-
};
136-
137111
// /proc/capi/applications:
138112
// applid l3cnt dblkcnt dblklen #ncci recvqueuelen
139113
// /proc/capi/applstats:
@@ -216,34 +190,6 @@ static const struct seq_operations seq_applstats_ops = {
216190
.show = applstats_show,
217191
};
218192

219-
static int
220-
seq_applications_open(struct inode *inode, struct file *file)
221-
{
222-
return seq_open(file, &seq_applications_ops);
223-
}
224-
225-
static int
226-
seq_applstats_open(struct inode *inode, struct file *file)
227-
{
228-
return seq_open(file, &seq_applstats_ops);
229-
}
230-
231-
static const struct file_operations proc_applications_ops = {
232-
.owner = THIS_MODULE,
233-
.open = seq_applications_open,
234-
.read = seq_read,
235-
.llseek = seq_lseek,
236-
.release = seq_release,
237-
};
238-
239-
static const struct file_operations proc_applstats_ops = {
240-
.owner = THIS_MODULE,
241-
.open = seq_applstats_open,
242-
.read = seq_read,
243-
.llseek = seq_lseek,
244-
.release = seq_release,
245-
};
246-
247193
// ---------------------------------------------------------------------------
248194

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

282-
static int
283-
seq_capi_driver_open(struct inode *inode, struct file *file)
284-
{
285-
int err;
286-
err = seq_open(file, &seq_capi_driver_ops);
287-
return err;
288-
}
289-
290-
static const struct file_operations proc_driver_ops = {
291-
.owner = THIS_MODULE,
292-
.open = seq_capi_driver_open,
293-
.read = seq_read,
294-
.llseek = seq_lseek,
295-
.release = seq_release,
296-
};
297-
298228
// ---------------------------------------------------------------------------
299229

300230
void __init
301231
kcapi_proc_init(void)
302232
{
303233
proc_mkdir("capi", NULL);
304234
proc_mkdir("capi/controllers", NULL);
305-
proc_create("capi/controller", 0, NULL, &proc_controller_ops);
306-
proc_create("capi/contrstats", 0, NULL, &proc_contrstats_ops);
307-
proc_create("capi/applications", 0, NULL, &proc_applications_ops);
308-
proc_create("capi/applstats", 0, NULL, &proc_applstats_ops);
309-
proc_create("capi/driver", 0, NULL, &proc_driver_ops);
235+
proc_create_seq("capi/controller", 0, NULL, &seq_controller_ops);
236+
proc_create_seq("capi/contrstats", 0, NULL, &seq_contrstats_ops);
237+
proc_create_seq("capi/applications", 0, NULL, &seq_applications_ops);
238+
proc_create_seq("capi/applstats", 0, NULL, &seq_applstats_ops);
239+
proc_create_seq("capi/driver", 0, NULL, &seq_capi_driver_ops);
310240
}
311241

312242
void __exit

drivers/net/hamradio/bpqether.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -449,20 +449,6 @@ static const struct seq_operations bpq_seqops = {
449449
.show = bpq_seq_show,
450450
};
451451

452-
static int bpq_info_open(struct inode *inode, struct file *file)
453-
{
454-
return seq_open(file, &bpq_seqops);
455-
}
456-
457-
static const struct file_operations bpq_info_fops = {
458-
.owner = THIS_MODULE,
459-
.open = bpq_info_open,
460-
.read = seq_read,
461-
.llseek = seq_lseek,
462-
.release = seq_release,
463-
};
464-
465-
466452
/* ------------------------------------------------------------------------ */
467453

468454
static const struct net_device_ops bpq_netdev_ops = {
@@ -590,7 +576,7 @@ static int bpq_device_event(struct notifier_block *this,
590576
static int __init bpq_init_driver(void)
591577
{
592578
#ifdef CONFIG_PROC_FS
593-
if (!proc_create("bpqether", 0444, init_net.proc_net, &bpq_info_fops)) {
579+
if (!proc_create_seq("bpqether", 0444, init_net.proc_net, &bpq_seqops)) {
594580
printk(KERN_ERR
595581
"bpq: cannot create /proc/net/bpqether entry.\n");
596582
return -ENOENT;

drivers/net/hamradio/scc.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,21 +2084,6 @@ static const struct seq_operations scc_net_seq_ops = {
20842084
.stop = scc_net_seq_stop,
20852085
.show = scc_net_seq_show,
20862086
};
2087-
2088-
2089-
static int scc_net_seq_open(struct inode *inode, struct file *file)
2090-
{
2091-
return seq_open(file, &scc_net_seq_ops);
2092-
}
2093-
2094-
static const struct file_operations scc_net_seq_fops = {
2095-
.owner = THIS_MODULE,
2096-
.open = scc_net_seq_open,
2097-
.read = seq_read,
2098-
.llseek = seq_lseek,
2099-
.release = seq_release_private,
2100-
};
2101-
21022087
#endif /* CONFIG_PROC_FS */
21032088

21042089

@@ -2122,7 +2107,7 @@ static int __init scc_init_driver (void)
21222107
}
21232108
rtnl_unlock();
21242109

2125-
proc_create("z8530drv", 0, init_net.proc_net, &scc_net_seq_fops);
2110+
proc_create_seq("z8530drv", 0, init_net.proc_net, &scc_net_seq_ops);
21262111

21272112
return 0;
21282113
}

drivers/net/hamradio/yam.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -841,20 +841,6 @@ static const struct seq_operations yam_seqops = {
841841
.stop = yam_seq_stop,
842842
.show = yam_seq_show,
843843
};
844-
845-
static int yam_info_open(struct inode *inode, struct file *file)
846-
{
847-
return seq_open(file, &yam_seqops);
848-
}
849-
850-
static const struct file_operations yam_info_fops = {
851-
.owner = THIS_MODULE,
852-
.open = yam_info_open,
853-
.read = seq_read,
854-
.llseek = seq_lseek,
855-
.release = seq_release,
856-
};
857-
858844
#endif
859845

860846

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

1171-
proc_create("yam", 0444, init_net.proc_net, &yam_info_fops);
1157+
proc_create_seq("yam", 0444, init_net.proc_net, &yam_seqops);
11721158
return 0;
11731159
error:
11741160
while (--i >= 0) {

0 commit comments

Comments
 (0)