Skip to content

Commit ec7d9c9

Browse files
author
Christoph Hellwig
committed
ide: replace ->proc_fops with ->proc_show
Just set up the show callback in the tty_operations, and use proc_create_single_data to create the file without additional boilerplace code. Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 61fb5c0 commit ec7d9c9

File tree

6 files changed

+31
-222
lines changed

6 files changed

+31
-222
lines changed

drivers/ide/ide-cd.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,21 +1426,8 @@ static int idecd_capacity_proc_show(struct seq_file *m, void *v)
14261426
return 0;
14271427
}
14281428

1429-
static int idecd_capacity_proc_open(struct inode *inode, struct file *file)
1430-
{
1431-
return single_open(file, idecd_capacity_proc_show, PDE_DATA(inode));
1432-
}
1433-
1434-
static const struct file_operations idecd_capacity_proc_fops = {
1435-
.owner = THIS_MODULE,
1436-
.open = idecd_capacity_proc_open,
1437-
.read = seq_read,
1438-
.llseek = seq_lseek,
1439-
.release = single_release,
1440-
};
1441-
14421429
static ide_proc_entry_t idecd_proc[] = {
1443-
{ "capacity", S_IFREG|S_IRUGO, &idecd_capacity_proc_fops },
1430+
{ "capacity", S_IFREG|S_IRUGO, idecd_capacity_proc_show },
14441431
{}
14451432
};
14461433

drivers/ide/ide-disk_proc.c

Lines changed: 5 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,6 @@ static int idedisk_cache_proc_show(struct seq_file *m, void *v)
5252
return 0;
5353
}
5454

55-
static int idedisk_cache_proc_open(struct inode *inode, struct file *file)
56-
{
57-
return single_open(file, idedisk_cache_proc_show, PDE_DATA(inode));
58-
}
59-
60-
static const struct file_operations idedisk_cache_proc_fops = {
61-
.owner = THIS_MODULE,
62-
.open = idedisk_cache_proc_open,
63-
.read = seq_read,
64-
.llseek = seq_lseek,
65-
.release = single_release,
66-
};
67-
6855
static int idedisk_capacity_proc_show(struct seq_file *m, void *v)
6956
{
7057
ide_drive_t*drive = (ide_drive_t *)m->private;
@@ -73,19 +60,6 @@ static int idedisk_capacity_proc_show(struct seq_file *m, void *v)
7360
return 0;
7461
}
7562

76-
static int idedisk_capacity_proc_open(struct inode *inode, struct file *file)
77-
{
78-
return single_open(file, idedisk_capacity_proc_show, PDE_DATA(inode));
79-
}
80-
81-
static const struct file_operations idedisk_capacity_proc_fops = {
82-
.owner = THIS_MODULE,
83-
.open = idedisk_capacity_proc_open,
84-
.read = seq_read,
85-
.llseek = seq_lseek,
86-
.release = single_release,
87-
};
88-
8963
static int __idedisk_proc_show(struct seq_file *m, ide_drive_t *drive, u8 sub_cmd)
9064
{
9165
u8 *buf;
@@ -114,43 +88,17 @@ static int idedisk_sv_proc_show(struct seq_file *m, void *v)
11488
return __idedisk_proc_show(m, m->private, ATA_SMART_READ_VALUES);
11589
}
11690

117-
static int idedisk_sv_proc_open(struct inode *inode, struct file *file)
118-
{
119-
return single_open(file, idedisk_sv_proc_show, PDE_DATA(inode));
120-
}
121-
122-
static const struct file_operations idedisk_sv_proc_fops = {
123-
.owner = THIS_MODULE,
124-
.open = idedisk_sv_proc_open,
125-
.read = seq_read,
126-
.llseek = seq_lseek,
127-
.release = single_release,
128-
};
129-
13091
static int idedisk_st_proc_show(struct seq_file *m, void *v)
13192
{
13293
return __idedisk_proc_show(m, m->private, ATA_SMART_READ_THRESHOLDS);
13394
}
13495

135-
static int idedisk_st_proc_open(struct inode *inode, struct file *file)
136-
{
137-
return single_open(file, idedisk_st_proc_show, PDE_DATA(inode));
138-
}
139-
140-
static const struct file_operations idedisk_st_proc_fops = {
141-
.owner = THIS_MODULE,
142-
.open = idedisk_st_proc_open,
143-
.read = seq_read,
144-
.llseek = seq_lseek,
145-
.release = single_release,
146-
};
147-
14896
ide_proc_entry_t ide_disk_proc[] = {
149-
{ "cache", S_IFREG|S_IRUGO, &idedisk_cache_proc_fops },
150-
{ "capacity", S_IFREG|S_IRUGO, &idedisk_capacity_proc_fops },
151-
{ "geometry", S_IFREG|S_IRUGO, &ide_geometry_proc_fops },
152-
{ "smart_values", S_IFREG|S_IRUSR, &idedisk_sv_proc_fops },
153-
{ "smart_thresholds", S_IFREG|S_IRUSR, &idedisk_st_proc_fops },
97+
{ "cache", S_IFREG|S_IRUGO, idedisk_cache_proc_show },
98+
{ "capacity", S_IFREG|S_IRUGO, idedisk_capacity_proc_show },
99+
{ "geometry", S_IFREG|S_IRUGO, ide_geometry_proc_show },
100+
{ "smart_values", S_IFREG|S_IRUSR, idedisk_sv_proc_show },
101+
{ "smart_thresholds", S_IFREG|S_IRUSR, idedisk_st_proc_show },
154102
{}
155103
};
156104

drivers/ide/ide-floppy_proc.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,9 @@ static int idefloppy_capacity_proc_show(struct seq_file *m, void *v)
1414
return 0;
1515
}
1616

17-
static int idefloppy_capacity_proc_open(struct inode *inode, struct file *file)
18-
{
19-
return single_open(file, idefloppy_capacity_proc_show, PDE_DATA(inode));
20-
}
21-
22-
static const struct file_operations idefloppy_capacity_proc_fops = {
23-
.owner = THIS_MODULE,
24-
.open = idefloppy_capacity_proc_open,
25-
.read = seq_read,
26-
.llseek = seq_lseek,
27-
.release = single_release,
28-
};
29-
3017
ide_proc_entry_t ide_floppy_proc[] = {
31-
{ "capacity", S_IFREG|S_IRUGO, &idefloppy_capacity_proc_fops },
32-
{ "geometry", S_IFREG|S_IRUGO, &ide_geometry_proc_fops },
18+
{ "capacity", S_IFREG|S_IRUGO, idefloppy_capacity_proc_show },
19+
{ "geometry", S_IFREG|S_IRUGO, ide_geometry_proc_show },
3320
{}
3421
};
3522

drivers/ide/ide-proc.c

Lines changed: 18 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,6 @@ static int ide_imodel_proc_show(struct seq_file *m, void *v)
5656
return 0;
5757
}
5858

59-
static int ide_imodel_proc_open(struct inode *inode, struct file *file)
60-
{
61-
return single_open(file, ide_imodel_proc_show, PDE_DATA(inode));
62-
}
63-
64-
static const struct file_operations ide_imodel_proc_fops = {
65-
.owner = THIS_MODULE,
66-
.open = ide_imodel_proc_open,
67-
.read = seq_read,
68-
.llseek = seq_lseek,
69-
.release = single_release,
70-
};
71-
7259
static int ide_mate_proc_show(struct seq_file *m, void *v)
7360
{
7461
ide_hwif_t *hwif = (ide_hwif_t *) m->private;
@@ -80,19 +67,6 @@ static int ide_mate_proc_show(struct seq_file *m, void *v)
8067
return 0;
8168
}
8269

83-
static int ide_mate_proc_open(struct inode *inode, struct file *file)
84-
{
85-
return single_open(file, ide_mate_proc_show, PDE_DATA(inode));
86-
}
87-
88-
static const struct file_operations ide_mate_proc_fops = {
89-
.owner = THIS_MODULE,
90-
.open = ide_mate_proc_open,
91-
.read = seq_read,
92-
.llseek = seq_lseek,
93-
.release = single_release,
94-
};
95-
9670
static int ide_channel_proc_show(struct seq_file *m, void *v)
9771
{
9872
ide_hwif_t *hwif = (ide_hwif_t *) m->private;
@@ -101,19 +75,6 @@ static int ide_channel_proc_show(struct seq_file *m, void *v)
10175
return 0;
10276
}
10377

104-
static int ide_channel_proc_open(struct inode *inode, struct file *file)
105-
{
106-
return single_open(file, ide_channel_proc_show, PDE_DATA(inode));
107-
}
108-
109-
static const struct file_operations ide_channel_proc_fops = {
110-
.owner = THIS_MODULE,
111-
.open = ide_channel_proc_open,
112-
.read = seq_read,
113-
.llseek = seq_lseek,
114-
.release = single_release,
115-
};
116-
11778
static int ide_identify_proc_show(struct seq_file *m, void *v)
11879
{
11980
ide_drive_t *drive = (ide_drive_t *)m->private;
@@ -141,19 +102,6 @@ static int ide_identify_proc_show(struct seq_file *m, void *v)
141102
return 0;
142103
}
143104

144-
static int ide_identify_proc_open(struct inode *inode, struct file *file)
145-
{
146-
return single_open(file, ide_identify_proc_show, PDE_DATA(inode));
147-
}
148-
149-
static const struct file_operations ide_identify_proc_fops = {
150-
.owner = THIS_MODULE,
151-
.open = ide_identify_proc_open,
152-
.read = seq_read,
153-
.llseek = seq_lseek,
154-
.release = single_release,
155-
};
156-
157105
/**
158106
* ide_find_setting - find a specific setting
159107
* @st: setting table pointer
@@ -441,27 +389,14 @@ static const struct file_operations ide_settings_proc_fops = {
441389
.write = ide_settings_proc_write,
442390
};
443391

444-
static int ide_capacity_proc_show(struct seq_file *m, void *v)
392+
int ide_capacity_proc_show(struct seq_file *m, void *v)
445393
{
446394
seq_printf(m, "%llu\n", (long long)0x7fffffff);
447395
return 0;
448396
}
397+
EXPORT_SYMBOL_GPL(ide_capacity_proc_show);
449398

450-
static int ide_capacity_proc_open(struct inode *inode, struct file *file)
451-
{
452-
return single_open(file, ide_capacity_proc_show, NULL);
453-
}
454-
455-
const struct file_operations ide_capacity_proc_fops = {
456-
.owner = THIS_MODULE,
457-
.open = ide_capacity_proc_open,
458-
.read = seq_read,
459-
.llseek = seq_lseek,
460-
.release = single_release,
461-
};
462-
EXPORT_SYMBOL_GPL(ide_capacity_proc_fops);
463-
464-
static int ide_geometry_proc_show(struct seq_file *m, void *v)
399+
int ide_geometry_proc_show(struct seq_file *m, void *v)
465400
{
466401
ide_drive_t *drive = (ide_drive_t *) m->private;
467402

@@ -471,20 +406,7 @@ static int ide_geometry_proc_show(struct seq_file *m, void *v)
471406
drive->bios_cyl, drive->bios_head, drive->bios_sect);
472407
return 0;
473408
}
474-
475-
static int ide_geometry_proc_open(struct inode *inode, struct file *file)
476-
{
477-
return single_open(file, ide_geometry_proc_show, PDE_DATA(inode));
478-
}
479-
480-
const struct file_operations ide_geometry_proc_fops = {
481-
.owner = THIS_MODULE,
482-
.open = ide_geometry_proc_open,
483-
.read = seq_read,
484-
.llseek = seq_lseek,
485-
.release = single_release,
486-
};
487-
EXPORT_SYMBOL(ide_geometry_proc_fops);
409+
EXPORT_SYMBOL(ide_geometry_proc_show);
488410

489411
static int ide_dmodel_proc_show(struct seq_file *seq, void *v)
490412
{
@@ -495,19 +417,6 @@ static int ide_dmodel_proc_show(struct seq_file *seq, void *v)
495417
return 0;
496418
}
497419

498-
static int ide_dmodel_proc_open(struct inode *inode, struct file *file)
499-
{
500-
return single_open(file, ide_dmodel_proc_show, PDE_DATA(inode));
501-
}
502-
503-
static const struct file_operations ide_dmodel_proc_fops = {
504-
.owner = THIS_MODULE,
505-
.open = ide_dmodel_proc_open,
506-
.read = seq_read,
507-
.llseek = seq_lseek,
508-
.release = single_release,
509-
};
510-
511420
static int ide_driver_proc_show(struct seq_file *m, void *v)
512421
{
513422
ide_drive_t *drive = (ide_drive_t *)m->private;
@@ -523,19 +432,6 @@ static int ide_driver_proc_show(struct seq_file *m, void *v)
523432
return 0;
524433
}
525434

526-
static int ide_driver_proc_open(struct inode *inode, struct file *file)
527-
{
528-
return single_open(file, ide_driver_proc_show, PDE_DATA(inode));
529-
}
530-
531-
static const struct file_operations ide_driver_proc_fops = {
532-
.owner = THIS_MODULE,
533-
.open = ide_driver_proc_open,
534-
.read = seq_read,
535-
.llseek = seq_lseek,
536-
.release = single_release,
537-
};
538-
539435
static int ide_media_proc_show(struct seq_file *m, void *v)
540436
{
541437
ide_drive_t *drive = (ide_drive_t *) m->private;
@@ -567,11 +463,10 @@ static const struct file_operations ide_media_proc_fops = {
567463
};
568464

569465
static ide_proc_entry_t generic_drive_entries[] = {
570-
{ "driver", S_IFREG|S_IRUGO, &ide_driver_proc_fops },
571-
{ "identify", S_IFREG|S_IRUSR, &ide_identify_proc_fops},
572-
{ "media", S_IFREG|S_IRUGO, &ide_media_proc_fops },
573-
{ "model", S_IFREG|S_IRUGO, &ide_dmodel_proc_fops },
574-
{ "settings", S_IFREG|S_IRUSR|S_IWUSR, &ide_settings_proc_fops},
466+
{ "driver", S_IFREG|S_IRUGO, ide_driver_proc_show },
467+
{ "identify", S_IFREG|S_IRUSR, ide_identify_proc_show },
468+
{ "media", S_IFREG|S_IRUGO, ide_media_proc_show },
469+
{ "model", S_IFREG|S_IRUGO, ide_dmodel_proc_show },
575470
{}
576471
};
577472

@@ -582,7 +477,7 @@ static void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p
582477
if (!dir || !p)
583478
return;
584479
while (p->name != NULL) {
585-
ent = proc_create_data(p->name, p->mode, dir, p->proc_fops, data);
480+
ent = proc_create_single_data(p->name, p->mode, dir, p->show, data);
586481
if (!ent) return;
587482
p++;
588483
}
@@ -647,8 +542,12 @@ void ide_proc_port_register_devices(ide_hwif_t *hwif)
647542
continue;
648543

649544
drive->proc = proc_mkdir(drive->name, parent);
650-
if (drive->proc)
545+
if (drive->proc) {
651546
ide_add_proc_entries(drive->proc, generic_drive_entries, drive);
547+
proc_create_data("setting", S_IFREG|S_IRUSR|S_IWUSR,
548+
drive->proc, &ide_settings_proc_fops,
549+
drive);
550+
}
652551
sprintf(name, "ide%d/%s", (drive->name[2]-'a')/2, drive->name);
653552
ent = proc_symlink(drive->name, proc_ide_root, name);
654553
if (!ent) return;
@@ -658,6 +557,7 @@ void ide_proc_port_register_devices(ide_hwif_t *hwif)
658557
void ide_proc_unregister_device(ide_drive_t *drive)
659558
{
660559
if (drive->proc) {
560+
remove_proc_entry("settings", drive->proc);
661561
ide_remove_proc_entries(drive->proc, generic_drive_entries);
662562
remove_proc_entry(drive->name, proc_ide_root);
663563
remove_proc_entry(drive->name, drive->hwif->proc);
@@ -666,9 +566,9 @@ void ide_proc_unregister_device(ide_drive_t *drive)
666566
}
667567

668568
static ide_proc_entry_t hwif_entries[] = {
669-
{ "channel", S_IFREG|S_IRUGO, &ide_channel_proc_fops },
670-
{ "mate", S_IFREG|S_IRUGO, &ide_mate_proc_fops },
671-
{ "model", S_IFREG|S_IRUGO, &ide_imodel_proc_fops },
569+
{ "channel", S_IFREG|S_IRUGO, ide_channel_proc_show },
570+
{ "mate", S_IFREG|S_IRUGO, ide_mate_proc_show },
571+
{ "model", S_IFREG|S_IRUGO, ide_imodel_proc_show },
672572
{}
673573
};
674574

drivers/ide/ide-tape.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,22 +1847,9 @@ static int idetape_name_proc_show(struct seq_file *m, void *v)
18471847
return 0;
18481848
}
18491849

1850-
static int idetape_name_proc_open(struct inode *inode, struct file *file)
1851-
{
1852-
return single_open(file, idetape_name_proc_show, PDE_DATA(inode));
1853-
}
1854-
1855-
static const struct file_operations idetape_name_proc_fops = {
1856-
.owner = THIS_MODULE,
1857-
.open = idetape_name_proc_open,
1858-
.read = seq_read,
1859-
.llseek = seq_lseek,
1860-
.release = single_release,
1861-
};
1862-
18631850
static ide_proc_entry_t idetape_proc[] = {
1864-
{ "capacity", S_IFREG|S_IRUGO, &ide_capacity_proc_fops },
1865-
{ "name", S_IFREG|S_IRUGO, &idetape_name_proc_fops },
1851+
{ "capacity", S_IFREG|S_IRUGO, ide_capacity_proc_show },
1852+
{ "name", S_IFREG|S_IRUGO, idetape_name_proc_show },
18661853
{}
18671854
};
18681855

0 commit comments

Comments
 (0)