Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <hch@lst.de>

+31 -222
+1 -14
drivers/ide/ide-cd.c
··· 1426 1426 return 0; 1427 1427 } 1428 1428 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 - 1442 1429 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 }, 1444 1431 {} 1445 1432 }; 1446 1433
+5 -57
drivers/ide/ide-disk_proc.c
··· 52 52 return 0; 53 53 } 54 54 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 - 68 55 static int idedisk_capacity_proc_show(struct seq_file *m, void *v) 69 56 { 70 57 ide_drive_t*drive = (ide_drive_t *)m->private; ··· 59 72 seq_printf(m, "%llu\n", (long long)ide_gd_capacity(drive)); 60 73 return 0; 61 74 } 62 - 63 - static int idedisk_capacity_proc_open(struct inode *inode, struct file *file) 64 - { 65 - return single_open(file, idedisk_capacity_proc_show, PDE_DATA(inode)); 66 - } 67 - 68 - static const struct file_operations idedisk_capacity_proc_fops = { 69 - .owner = THIS_MODULE, 70 - .open = idedisk_capacity_proc_open, 71 - .read = seq_read, 72 - .llseek = seq_lseek, 73 - .release = single_release, 74 - }; 75 75 76 76 static int __idedisk_proc_show(struct seq_file *m, ide_drive_t *drive, u8 sub_cmd) 77 77 { ··· 88 114 return __idedisk_proc_show(m, m->private, ATA_SMART_READ_VALUES); 89 115 } 90 116 91 - static int idedisk_sv_proc_open(struct inode *inode, struct file *file) 92 - { 93 - return single_open(file, idedisk_sv_proc_show, PDE_DATA(inode)); 94 - } 95 - 96 - static const struct file_operations idedisk_sv_proc_fops = { 97 - .owner = THIS_MODULE, 98 - .open = idedisk_sv_proc_open, 99 - .read = seq_read, 100 - .llseek = seq_lseek, 101 - .release = single_release, 102 - }; 103 - 104 117 static int idedisk_st_proc_show(struct seq_file *m, void *v) 105 118 { 106 119 return __idedisk_proc_show(m, m->private, ATA_SMART_READ_THRESHOLDS); 107 120 } 108 121 109 - static int idedisk_st_proc_open(struct inode *inode, struct file *file) 110 - { 111 - return single_open(file, idedisk_st_proc_show, PDE_DATA(inode)); 112 - } 113 - 114 - static const struct file_operations idedisk_st_proc_fops = { 115 - .owner = THIS_MODULE, 116 - .open = idedisk_st_proc_open, 117 - .read = seq_read, 118 - .llseek = seq_lseek, 119 - .release = single_release, 120 - }; 121 - 122 122 ide_proc_entry_t ide_disk_proc[] = { 123 - { "cache", S_IFREG|S_IRUGO, &idedisk_cache_proc_fops }, 124 - { "capacity", S_IFREG|S_IRUGO, &idedisk_capacity_proc_fops }, 125 - { "geometry", S_IFREG|S_IRUGO, &ide_geometry_proc_fops }, 126 - { "smart_values", S_IFREG|S_IRUSR, &idedisk_sv_proc_fops }, 127 - { "smart_thresholds", S_IFREG|S_IRUSR, &idedisk_st_proc_fops }, 123 + { "cache", S_IFREG|S_IRUGO, idedisk_cache_proc_show }, 124 + { "capacity", S_IFREG|S_IRUGO, idedisk_capacity_proc_show }, 125 + { "geometry", S_IFREG|S_IRUGO, ide_geometry_proc_show }, 126 + { "smart_values", S_IFREG|S_IRUSR, idedisk_sv_proc_show }, 127 + { "smart_thresholds", S_IFREG|S_IRUSR, idedisk_st_proc_show }, 128 128 {} 129 129 }; 130 130
+2 -15
drivers/ide/ide-floppy_proc.c
··· 14 14 return 0; 15 15 } 16 16 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 - 30 17 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 }, 33 20 {} 34 21 }; 35 22
+18 -118
drivers/ide/ide-proc.c
··· 56 56 return 0; 57 57 } 58 58 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 - 72 59 static int ide_mate_proc_show(struct seq_file *m, void *v) 73 60 { 74 61 ide_hwif_t *hwif = (ide_hwif_t *) m->private; ··· 67 80 return 0; 68 81 } 69 82 70 - static int ide_mate_proc_open(struct inode *inode, struct file *file) 71 - { 72 - return single_open(file, ide_mate_proc_show, PDE_DATA(inode)); 73 - } 74 - 75 - static const struct file_operations ide_mate_proc_fops = { 76 - .owner = THIS_MODULE, 77 - .open = ide_mate_proc_open, 78 - .read = seq_read, 79 - .llseek = seq_lseek, 80 - .release = single_release, 81 - }; 82 - 83 83 static int ide_channel_proc_show(struct seq_file *m, void *v) 84 84 { 85 85 ide_hwif_t *hwif = (ide_hwif_t *) m->private; ··· 74 100 seq_printf(m, "%c\n", hwif->channel ? '1' : '0'); 75 101 return 0; 76 102 } 77 - 78 - static int ide_channel_proc_open(struct inode *inode, struct file *file) 79 - { 80 - return single_open(file, ide_channel_proc_show, PDE_DATA(inode)); 81 - } 82 - 83 - static const struct file_operations ide_channel_proc_fops = { 84 - .owner = THIS_MODULE, 85 - .open = ide_channel_proc_open, 86 - .read = seq_read, 87 - .llseek = seq_lseek, 88 - .release = single_release, 89 - }; 90 103 91 104 static int ide_identify_proc_show(struct seq_file *m, void *v) 92 105 { ··· 101 140 kfree(buf); 102 141 return 0; 103 142 } 104 - 105 - static int ide_identify_proc_open(struct inode *inode, struct file *file) 106 - { 107 - return single_open(file, ide_identify_proc_show, PDE_DATA(inode)); 108 - } 109 - 110 - static const struct file_operations ide_identify_proc_fops = { 111 - .owner = THIS_MODULE, 112 - .open = ide_identify_proc_open, 113 - .read = seq_read, 114 - .llseek = seq_lseek, 115 - .release = single_release, 116 - }; 117 143 118 144 /** 119 145 * ide_find_setting - find a specific setting ··· 389 441 .write = ide_settings_proc_write, 390 442 }; 391 443 392 - static int ide_capacity_proc_show(struct seq_file *m, void *v) 444 + int ide_capacity_proc_show(struct seq_file *m, void *v) 393 445 { 394 446 seq_printf(m, "%llu\n", (long long)0x7fffffff); 395 447 return 0; 396 448 } 449 + EXPORT_SYMBOL_GPL(ide_capacity_proc_show); 397 450 398 - static int ide_capacity_proc_open(struct inode *inode, struct file *file) 399 - { 400 - return single_open(file, ide_capacity_proc_show, NULL); 401 - } 402 - 403 - const struct file_operations ide_capacity_proc_fops = { 404 - .owner = THIS_MODULE, 405 - .open = ide_capacity_proc_open, 406 - .read = seq_read, 407 - .llseek = seq_lseek, 408 - .release = single_release, 409 - }; 410 - EXPORT_SYMBOL_GPL(ide_capacity_proc_fops); 411 - 412 - static int ide_geometry_proc_show(struct seq_file *m, void *v) 451 + int ide_geometry_proc_show(struct seq_file *m, void *v) 413 452 { 414 453 ide_drive_t *drive = (ide_drive_t *) m->private; 415 454 ··· 406 471 drive->bios_cyl, drive->bios_head, drive->bios_sect); 407 472 return 0; 408 473 } 409 - 410 - static int ide_geometry_proc_open(struct inode *inode, struct file *file) 411 - { 412 - return single_open(file, ide_geometry_proc_show, PDE_DATA(inode)); 413 - } 414 - 415 - const struct file_operations ide_geometry_proc_fops = { 416 - .owner = THIS_MODULE, 417 - .open = ide_geometry_proc_open, 418 - .read = seq_read, 419 - .llseek = seq_lseek, 420 - .release = single_release, 421 - }; 422 - EXPORT_SYMBOL(ide_geometry_proc_fops); 474 + EXPORT_SYMBOL(ide_geometry_proc_show); 423 475 424 476 static int ide_dmodel_proc_show(struct seq_file *seq, void *v) 425 477 { ··· 416 494 seq_printf(seq, "%.40s\n", m[0] ? m : "(none)"); 417 495 return 0; 418 496 } 419 - 420 - static int ide_dmodel_proc_open(struct inode *inode, struct file *file) 421 - { 422 - return single_open(file, ide_dmodel_proc_show, PDE_DATA(inode)); 423 - } 424 - 425 - static const struct file_operations ide_dmodel_proc_fops = { 426 - .owner = THIS_MODULE, 427 - .open = ide_dmodel_proc_open, 428 - .read = seq_read, 429 - .llseek = seq_lseek, 430 - .release = single_release, 431 - }; 432 497 433 498 static int ide_driver_proc_show(struct seq_file *m, void *v) 434 499 { ··· 431 522 seq_printf(m, "ide-default version 0.9.newide\n"); 432 523 return 0; 433 524 } 434 - 435 - static int ide_driver_proc_open(struct inode *inode, struct file *file) 436 - { 437 - return single_open(file, ide_driver_proc_show, PDE_DATA(inode)); 438 - } 439 - 440 - static const struct file_operations ide_driver_proc_fops = { 441 - .owner = THIS_MODULE, 442 - .open = ide_driver_proc_open, 443 - .read = seq_read, 444 - .llseek = seq_lseek, 445 - .release = single_release, 446 - }; 447 525 448 526 static int ide_media_proc_show(struct seq_file *m, void *v) 449 527 { ··· 463 567 }; 464 568 465 569 static ide_proc_entry_t generic_drive_entries[] = { 466 - { "driver", S_IFREG|S_IRUGO, &ide_driver_proc_fops }, 467 - { "identify", S_IFREG|S_IRUSR, &ide_identify_proc_fops}, 468 - { "media", S_IFREG|S_IRUGO, &ide_media_proc_fops }, 469 - { "model", S_IFREG|S_IRUGO, &ide_dmodel_proc_fops }, 470 - { "settings", S_IFREG|S_IRUSR|S_IWUSR, &ide_settings_proc_fops}, 570 + { "driver", S_IFREG|S_IRUGO, ide_driver_proc_show }, 571 + { "identify", S_IFREG|S_IRUSR, ide_identify_proc_show }, 572 + { "media", S_IFREG|S_IRUGO, ide_media_proc_show }, 573 + { "model", S_IFREG|S_IRUGO, ide_dmodel_proc_show }, 471 574 {} 472 575 }; 473 576 ··· 477 582 if (!dir || !p) 478 583 return; 479 584 while (p->name != NULL) { 480 - ent = proc_create_data(p->name, p->mode, dir, p->proc_fops, data); 585 + ent = proc_create_single_data(p->name, p->mode, dir, p->show, data); 481 586 if (!ent) return; 482 587 p++; 483 588 } ··· 542 647 continue; 543 648 544 649 drive->proc = proc_mkdir(drive->name, parent); 545 - if (drive->proc) 650 + if (drive->proc) { 546 651 ide_add_proc_entries(drive->proc, generic_drive_entries, drive); 652 + proc_create_data("setting", S_IFREG|S_IRUSR|S_IWUSR, 653 + drive->proc, &ide_settings_proc_fops, 654 + drive); 655 + } 547 656 sprintf(name, "ide%d/%s", (drive->name[2]-'a')/2, drive->name); 548 657 ent = proc_symlink(drive->name, proc_ide_root, name); 549 658 if (!ent) return; ··· 557 658 void ide_proc_unregister_device(ide_drive_t *drive) 558 659 { 559 660 if (drive->proc) { 661 + remove_proc_entry("settings", drive->proc); 560 662 ide_remove_proc_entries(drive->proc, generic_drive_entries); 561 663 remove_proc_entry(drive->name, proc_ide_root); 562 664 remove_proc_entry(drive->name, drive->hwif->proc); ··· 566 666 } 567 667 568 668 static ide_proc_entry_t hwif_entries[] = { 569 - { "channel", S_IFREG|S_IRUGO, &ide_channel_proc_fops }, 570 - { "mate", S_IFREG|S_IRUGO, &ide_mate_proc_fops }, 571 - { "model", S_IFREG|S_IRUGO, &ide_imodel_proc_fops }, 669 + { "channel", S_IFREG|S_IRUGO, ide_channel_proc_show }, 670 + { "mate", S_IFREG|S_IRUGO, ide_mate_proc_show }, 671 + { "model", S_IFREG|S_IRUGO, ide_imodel_proc_show }, 572 672 {} 573 673 }; 574 674
+2 -15
drivers/ide/ide-tape.c
··· 1847 1847 return 0; 1848 1848 } 1849 1849 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 - 1863 1850 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 }, 1866 1853 {} 1867 1854 }; 1868 1855
+3 -3
include/linux/ide.h
··· 961 961 typedef struct { 962 962 const char *name; 963 963 umode_t mode; 964 - const struct file_operations *proc_fops; 964 + int (*show)(struct seq_file *, void *); 965 965 } ide_proc_entry_t; 966 966 967 967 void proc_ide_create(void); ··· 973 973 void ide_proc_register_driver(ide_drive_t *, struct ide_driver *); 974 974 void ide_proc_unregister_driver(ide_drive_t *, struct ide_driver *); 975 975 976 - extern const struct file_operations ide_capacity_proc_fops; 977 - extern const struct file_operations ide_geometry_proc_fops; 976 + int ide_capacity_proc_show(struct seq_file *m, void *v); 977 + int ide_geometry_proc_show(struct seq_file *m, void *v); 978 978 #else 979 979 static inline void proc_ide_create(void) { ; } 980 980 static inline void proc_ide_destroy(void) { ; }