Skip to content

Commit 3f3942a

Browse files
author
Christoph Hellwig
committed
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>
1 parent 44414d8 commit 3f3942a

File tree

85 files changed

+235
-1509
lines changed

Some content is hidden

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

85 files changed

+235
-1509
lines changed

arch/arm/kernel/dma.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -276,21 +276,9 @@ static int proc_dma_show(struct seq_file *m, void *v)
276276
return 0;
277277
}
278278

279-
static int proc_dma_open(struct inode *inode, struct file *file)
280-
{
281-
return single_open(file, proc_dma_show, NULL);
282-
}
283-
284-
static const struct file_operations proc_dma_operations = {
285-
.open = proc_dma_open,
286-
.read = seq_read,
287-
.llseek = seq_lseek,
288-
.release = single_release,
289-
};
290-
291279
static int __init proc_dma_init(void)
292280
{
293-
proc_create("dma", 0, NULL, &proc_dma_operations);
281+
proc_create_single("dma", 0, NULL, proc_dma_show);
294282
return 0;
295283
}
296284

arch/arm/kernel/swp_emulate.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,6 @@ static int proc_status_show(struct seq_file *m, void *v)
9191
seq_printf(m, "Last process:\t\t%d\n", previous_pid);
9292
return 0;
9393
}
94-
95-
static int proc_status_open(struct inode *inode, struct file *file)
96-
{
97-
return single_open(file, proc_status_show, PDE_DATA(inode));
98-
}
99-
100-
static const struct file_operations proc_status_fops = {
101-
.open = proc_status_open,
102-
.read = seq_read,
103-
.llseek = seq_lseek,
104-
.release = single_release,
105-
};
10694
#endif
10795

10896
/*
@@ -260,7 +248,8 @@ static int __init swp_emulation_init(void)
260248
return 0;
261249

262250
#ifdef CONFIG_PROC_FS
263-
if (!proc_create("cpu/swp_emulation", S_IRUGO, NULL, &proc_status_fops))
251+
if (!proc_create_single("cpu/swp_emulation", S_IRUGO, NULL,
252+
proc_status_show))
264253
return -ENOMEM;
265254
#endif /* CONFIG_PROC_FS */
266255

arch/arm/mach-rpc/ecard.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -657,25 +657,13 @@ static int ecard_devices_proc_show(struct seq_file *m, void *v)
657657
return 0;
658658
}
659659

660-
static int ecard_devices_proc_open(struct inode *inode, struct file *file)
661-
{
662-
return single_open(file, ecard_devices_proc_show, NULL);
663-
}
664-
665-
static const struct file_operations bus_ecard_proc_fops = {
666-
.owner = THIS_MODULE,
667-
.open = ecard_devices_proc_open,
668-
.read = seq_read,
669-
.llseek = seq_lseek,
670-
.release = single_release,
671-
};
672-
673660
static struct proc_dir_entry *proc_bus_ecard_dir = NULL;
674661

675662
static void ecard_proc_init(void)
676663
{
677664
proc_bus_ecard_dir = proc_mkdir("bus/ecard", NULL);
678-
proc_create("devices", 0, proc_bus_ecard_dir, &bus_ecard_proc_fops);
665+
proc_create_single("devices", 0, proc_bus_ecard_dir,
666+
ecard_devices_proc_show);
679667
}
680668

681669
#define ec_set_resource(ec,nr,st,sz) \

arch/ia64/kernel/palinfo.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -920,18 +920,6 @@ static int proc_palinfo_show(struct seq_file *m, void *v)
920920
return 0;
921921
}
922922

923-
static int proc_palinfo_open(struct inode *inode, struct file *file)
924-
{
925-
return single_open(file, proc_palinfo_show, PDE_DATA(inode));
926-
}
927-
928-
static const struct file_operations proc_palinfo_fops = {
929-
.open = proc_palinfo_open,
930-
.read = seq_read,
931-
.llseek = seq_lseek,
932-
.release = single_release,
933-
};
934-
935923
static int palinfo_add_proc(unsigned int cpu)
936924
{
937925
pal_func_cpu_u_t f;
@@ -948,8 +936,8 @@ static int palinfo_add_proc(unsigned int cpu)
948936

949937
for (j=0; j < NR_PALINFO_ENTRIES; j++) {
950938
f.func_id = j;
951-
proc_create_data(palinfo_entries[j].name, 0, cpu_dir,
952-
&proc_palinfo_fops, (void *)f.value);
939+
proc_create_single_data(palinfo_entries[j].name, 0, cpu_dir,
940+
proc_palinfo_show, (void *)f.value);
953941
}
954942
return 0;
955943
}

arch/ia64/kernel/salinfo.c

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ MODULE_AUTHOR("Jesse Barnes <jbarnes@sgi.com>");
5454
MODULE_DESCRIPTION("/proc interface to IA-64 SAL features");
5555
MODULE_LICENSE("GPL");
5656

57-
static const struct file_operations proc_salinfo_fops;
58-
5957
typedef struct {
6058
const char *name; /* name of the proc entry */
6159
unsigned long feature; /* feature bit */
@@ -578,6 +576,17 @@ static int salinfo_cpu_pre_down(unsigned int cpu)
578576
return 0;
579577
}
580578

579+
/*
580+
* 'data' contains an integer that corresponds to the feature we're
581+
* testing
582+
*/
583+
static int proc_salinfo_show(struct seq_file *m, void *v)
584+
{
585+
unsigned long data = (unsigned long)v;
586+
seq_puts(m, (sal_platform_features & data) ? "1\n" : "0\n");
587+
return 0;
588+
}
589+
581590
static int __init
582591
salinfo_init(void)
583592
{
@@ -593,9 +602,9 @@ salinfo_init(void)
593602

594603
for (i=0; i < NR_SALINFO_ENTRIES; i++) {
595604
/* pass the feature bit in question as misc data */
596-
*sdir++ = proc_create_data(salinfo_entries[i].name, 0, salinfo_dir,
597-
&proc_salinfo_fops,
598-
(void *)salinfo_entries[i].feature);
605+
*sdir++ = proc_create_single_data(salinfo_entries[i].name, 0,
606+
salinfo_dir, proc_salinfo_show,
607+
(void *)salinfo_entries[i].feature);
599608
}
600609

601610
for (i = 0; i < ARRAY_SIZE(salinfo_log_name); i++) {
@@ -633,27 +642,4 @@ salinfo_init(void)
633642
return 0;
634643
}
635644

636-
/*
637-
* 'data' contains an integer that corresponds to the feature we're
638-
* testing
639-
*/
640-
static int proc_salinfo_show(struct seq_file *m, void *v)
641-
{
642-
unsigned long data = (unsigned long)v;
643-
seq_puts(m, (sal_platform_features & data) ? "1\n" : "0\n");
644-
return 0;
645-
}
646-
647-
static int proc_salinfo_open(struct inode *inode, struct file *file)
648-
{
649-
return single_open(file, proc_salinfo_show, PDE_DATA(inode));
650-
}
651-
652-
static const struct file_operations proc_salinfo_fops = {
653-
.open = proc_salinfo_open,
654-
.read = seq_read,
655-
.llseek = seq_lseek,
656-
.release = single_release,
657-
};
658-
659645
module_init(salinfo_init);

arch/ia64/sn/kernel/sn2/prominfo_proc.c

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,6 @@ static int proc_fit_show(struct seq_file *m, void *v)
140140
return 0;
141141
}
142142

143-
static int proc_fit_open(struct inode *inode, struct file *file)
144-
{
145-
return single_open(file, proc_fit_show, PDE_DATA(inode));
146-
}
147-
148-
static const struct file_operations proc_fit_fops = {
149-
.open = proc_fit_open,
150-
.read = seq_read,
151-
.llseek = seq_lseek,
152-
.release = single_release,
153-
};
154-
155143
static int proc_version_show(struct seq_file *m, void *v)
156144
{
157145
unsigned long nasid = (unsigned long)m->private;
@@ -174,18 +162,6 @@ static int proc_version_show(struct seq_file *m, void *v)
174162
return 0;
175163
}
176164

177-
static int proc_version_open(struct inode *inode, struct file *file)
178-
{
179-
return single_open(file, proc_version_show, PDE_DATA(inode));
180-
}
181-
182-
static const struct file_operations proc_version_fops = {
183-
.open = proc_version_open,
184-
.read = seq_read,
185-
.llseek = seq_lseek,
186-
.release = single_release,
187-
};
188-
189165
/* module entry points */
190166
int __init prominfo_init(void);
191167
void __exit prominfo_exit(void);
@@ -217,10 +193,10 @@ int __init prominfo_init(void)
217193
if (!dir)
218194
continue;
219195
nasid = cnodeid_to_nasid(cnodeid);
220-
proc_create_data("fit", 0, dir,
221-
&proc_fit_fops, (void *)nasid);
222-
proc_create_data("version", 0, dir,
223-
&proc_version_fops, (void *)nasid);
196+
proc_create_single_data("fit", 0, dir, proc_fit_show,
197+
(void *)nasid);
198+
proc_create_single_data("version", 0, dir, proc_version_show,
199+
(void *)nasid);
224200
}
225201
return 0;
226202
}

arch/ia64/sn/kernel/sn2/sn_proc_fs.c

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -18,77 +18,29 @@ static int partition_id_show(struct seq_file *s, void *p)
1818
return 0;
1919
}
2020

21-
static int partition_id_open(struct inode *inode, struct file *file)
22-
{
23-
return single_open(file, partition_id_show, NULL);
24-
}
25-
2621
static int system_serial_number_show(struct seq_file *s, void *p)
2722
{
2823
seq_printf(s, "%s\n", sn_system_serial_number());
2924
return 0;
3025
}
3126

32-
static int system_serial_number_open(struct inode *inode, struct file *file)
33-
{
34-
return single_open(file, system_serial_number_show, NULL);
35-
}
36-
3727
static int licenseID_show(struct seq_file *s, void *p)
3828
{
3929
seq_printf(s, "0x%llx\n", sn_partition_serial_number_val());
4030
return 0;
4131
}
4232

43-
static int licenseID_open(struct inode *inode, struct file *file)
44-
{
45-
return single_open(file, licenseID_show, NULL);
46-
}
47-
4833
static int coherence_id_show(struct seq_file *s, void *p)
4934
{
5035
seq_printf(s, "%d\n", partition_coherence_id());
5136

5237
return 0;
5338
}
5439

55-
static int coherence_id_open(struct inode *inode, struct file *file)
56-
{
57-
return single_open(file, coherence_id_show, NULL);
58-
}
59-
6040
/* /proc/sgi_sn/sn_topology uses seq_file, see sn_hwperf.c */
6141
extern int sn_topology_open(struct inode *, struct file *);
6242
extern int sn_topology_release(struct inode *, struct file *);
6343

64-
static const struct file_operations proc_partition_id_fops = {
65-
.open = partition_id_open,
66-
.read = seq_read,
67-
.llseek = seq_lseek,
68-
.release = single_release,
69-
};
70-
71-
static const struct file_operations proc_system_sn_fops = {
72-
.open = system_serial_number_open,
73-
.read = seq_read,
74-
.llseek = seq_lseek,
75-
.release = single_release,
76-
};
77-
78-
static const struct file_operations proc_license_id_fops = {
79-
.open = licenseID_open,
80-
.read = seq_read,
81-
.llseek = seq_lseek,
82-
.release = single_release,
83-
};
84-
85-
static const struct file_operations proc_coherence_id_fops = {
86-
.open = coherence_id_open,
87-
.read = seq_read,
88-
.llseek = seq_lseek,
89-
.release = single_release,
90-
};
91-
9244
static const struct file_operations proc_sn_topo_fops = {
9345
.open = sn_topology_open,
9446
.read = seq_read,
@@ -104,13 +56,13 @@ void register_sn_procfs(void)
10456
if (!(sgi_proc_dir = proc_mkdir("sgi_sn", NULL)))
10557
return;
10658

107-
proc_create("partition_id", 0444, sgi_proc_dir,
108-
&proc_partition_id_fops);
109-
proc_create("system_serial_number", 0444, sgi_proc_dir,
110-
&proc_system_sn_fops);
111-
proc_create("licenseID", 0444, sgi_proc_dir, &proc_license_id_fops);
112-
proc_create("coherence_id", 0444, sgi_proc_dir,
113-
&proc_coherence_id_fops);
59+
proc_create_single("partition_id", 0444, sgi_proc_dir,
60+
partition_id_show);
61+
proc_create_single("system_serial_number", 0444, sgi_proc_dir,
62+
system_serial_number_show);
63+
proc_create_single("licenseID", 0444, sgi_proc_dir, licenseID_show);
64+
proc_create_single("coherence_id", 0444, sgi_proc_dir,
65+
coherence_id_show);
11466
proc_create("sn_topology", 0444, sgi_proc_dir, &proc_sn_topo_fops);
11567
}
11668

arch/m68k/kernel/setup_mm.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -527,21 +527,9 @@ static int hardware_proc_show(struct seq_file *m, void *v)
527527
return 0;
528528
}
529529

530-
static int hardware_proc_open(struct inode *inode, struct file *file)
531-
{
532-
return single_open(file, hardware_proc_show, NULL);
533-
}
534-
535-
static const struct file_operations hardware_proc_fops = {
536-
.open = hardware_proc_open,
537-
.read = seq_read,
538-
.llseek = seq_lseek,
539-
.release = single_release,
540-
};
541-
542530
static int __init proc_hardware_init(void)
543531
{
544-
proc_create("hardware", 0, NULL, &hardware_proc_fops);
532+
proc_create_single("hardware", 0, NULL, hardware_proc_show);
545533
return 0;
546534
}
547535
module_init(proc_hardware_init);

0 commit comments

Comments
 (0)