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

tty: 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>

+16 -172
+1 -14
arch/ia64/hp/sim/simserial.c
··· 435 435 return 0; 436 436 } 437 437 438 - static int rs_proc_open(struct inode *inode, struct file *file) 439 - { 440 - return single_open(file, rs_proc_show, NULL); 441 - } 442 - 443 - static const struct file_operations rs_proc_fops = { 444 - .owner = THIS_MODULE, 445 - .open = rs_proc_open, 446 - .read = seq_read, 447 - .llseek = seq_lseek, 448 - .release = single_release, 449 - }; 450 - 451 438 static const struct tty_operations hp_ops = { 452 439 .open = rs_open, 453 440 .close = rs_close, ··· 449 462 .unthrottle = rs_unthrottle, 450 463 .send_xchar = rs_send_xchar, 451 464 .hangup = rs_hangup, 452 - .proc_fops = &rs_proc_fops, 465 + .proc_show = rs_proc_show, 453 466 }; 454 467 455 468 static const struct tty_port_operations hp_port_ops = {
+1 -14
arch/xtensa/platforms/iss/console.c
··· 153 153 return 0; 154 154 } 155 155 156 - static int rs_proc_open(struct inode *inode, struct file *file) 157 - { 158 - return single_open(file, rs_proc_show, NULL); 159 - } 160 - 161 - static const struct file_operations rs_proc_fops = { 162 - .owner = THIS_MODULE, 163 - .open = rs_proc_open, 164 - .read = seq_read, 165 - .llseek = seq_lseek, 166 - .release = single_release, 167 - }; 168 - 169 156 static const struct tty_operations serial_ops = { 170 157 .open = rs_open, 171 158 .close = rs_close, ··· 163 176 .chars_in_buffer = rs_chars_in_buffer, 164 177 .hangup = rs_hangup, 165 178 .wait_until_sent = rs_wait_until_sent, 166 - .proc_fops = &rs_proc_fops, 179 + .proc_show = rs_proc_show, 167 180 }; 168 181 169 182 int __init rs_init(void)
+1 -14
drivers/mmc/core/sdio_uart.c
··· 1008 1008 return 0; 1009 1009 } 1010 1010 1011 - static int sdio_uart_proc_open(struct inode *inode, struct file *file) 1012 - { 1013 - return single_open(file, sdio_uart_proc_show, NULL); 1014 - } 1015 - 1016 - static const struct file_operations sdio_uart_proc_fops = { 1017 - .owner = THIS_MODULE, 1018 - .open = sdio_uart_proc_open, 1019 - .read = seq_read, 1020 - .llseek = seq_lseek, 1021 - .release = single_release, 1022 - }; 1023 - 1024 1011 static const struct tty_port_operations sdio_uart_port_ops = { 1025 1012 .dtr_rts = uart_dtr_rts, 1026 1013 .carrier_raised = uart_carrier_raised, ··· 1032 1045 .tiocmset = sdio_uart_tiocmset, 1033 1046 .install = sdio_uart_install, 1034 1047 .cleanup = sdio_uart_cleanup, 1035 - .proc_fops = &sdio_uart_proc_fops, 1048 + .proc_show = sdio_uart_proc_show, 1036 1049 }; 1037 1050 1038 1051 static struct tty_driver *sdio_uart_tty_driver;
+1 -14
drivers/staging/fwserial/fwserial.c
··· 1506 1506 return 0; 1507 1507 } 1508 1508 1509 - static int fwtty_proc_open(struct inode *inode, struct file *fp) 1510 - { 1511 - return single_open(fp, fwtty_proc_show, NULL); 1512 - } 1513 - 1514 1509 static int fwtty_stats_open(struct inode *inode, struct file *fp) 1515 1510 { 1516 1511 return single_open(fp, fwtty_debugfs_stats_show, inode->i_private); ··· 1530 1535 .read = seq_read, 1531 1536 .llseek = seq_lseek, 1532 1537 .release = single_release, 1533 - }; 1534 - 1535 - static const struct file_operations fwtty_proc_fops = { 1536 - .owner = THIS_MODULE, 1537 - .open = fwtty_proc_open, 1538 - .read = seq_read, 1539 - .llseek = seq_lseek, 1540 - .release = single_release, 1541 1538 }; 1542 1539 1543 1540 static const struct tty_port_operations fwtty_port_ops = { ··· 1557 1570 .tiocmget = fwtty_tiocmget, 1558 1571 .tiocmset = fwtty_tiocmset, 1559 1572 .get_icount = fwtty_get_icount, 1560 - .proc_fops = &fwtty_proc_fops, 1573 + .proc_show = fwtty_proc_show, 1561 1574 }; 1562 1575 1563 1576 static const struct tty_operations fwloop_ops = {
+1 -14
drivers/tty/amiserial.c
··· 1566 1566 return 0; 1567 1567 } 1568 1568 1569 - static int rs_proc_open(struct inode *inode, struct file *file) 1570 - { 1571 - return single_open(file, rs_proc_show, NULL); 1572 - } 1573 - 1574 - static const struct file_operations rs_proc_fops = { 1575 - .owner = THIS_MODULE, 1576 - .open = rs_proc_open, 1577 - .read = seq_read, 1578 - .llseek = seq_lseek, 1579 - .release = single_release, 1580 - }; 1581 - 1582 1569 /* 1583 1570 * --------------------------------------------------------------------- 1584 1571 * rs_init() and friends ··· 1607 1620 .tiocmget = rs_tiocmget, 1608 1621 .tiocmset = rs_tiocmset, 1609 1622 .get_icount = rs_get_icount, 1610 - .proc_fops = &rs_proc_fops, 1623 + .proc_show = rs_proc_show, 1611 1624 }; 1612 1625 1613 1626 static int amiga_carrier_raised(struct tty_port *port)
+1 -14
drivers/tty/cyclades.c
··· 3972 3972 return 0; 3973 3973 } 3974 3974 3975 - static int cyclades_proc_open(struct inode *inode, struct file *file) 3976 - { 3977 - return single_open(file, cyclades_proc_show, NULL); 3978 - } 3979 - 3980 - static const struct file_operations cyclades_proc_fops = { 3981 - .owner = THIS_MODULE, 3982 - .open = cyclades_proc_open, 3983 - .read = seq_read, 3984 - .llseek = seq_lseek, 3985 - .release = single_release, 3986 - }; 3987 - 3988 3975 /* The serial driver boot-time initialization code! 3989 3976 Hardware I/O ports are mapped to character special devices on a 3990 3977 first found, first allocated manner. That is, this code searches ··· 4011 4024 .tiocmget = cy_tiocmget, 4012 4025 .tiocmset = cy_tiocmset, 4013 4026 .get_icount = cy_get_icount, 4014 - .proc_fops = &cyclades_proc_fops, 4027 + .proc_show = cyclades_proc_show, 4015 4028 }; 4016 4029 4017 4030 static int __init cy_init(void)
+1 -14
drivers/tty/serial/serial_core.c
··· 1829 1829 uart_line_info(m, drv, i); 1830 1830 return 0; 1831 1831 } 1832 - 1833 - static int uart_proc_open(struct inode *inode, struct file *file) 1834 - { 1835 - return single_open(file, uart_proc_show, PDE_DATA(inode)); 1836 - } 1837 - 1838 - static const struct file_operations uart_proc_fops = { 1839 - .owner = THIS_MODULE, 1840 - .open = uart_proc_open, 1841 - .read = seq_read, 1842 - .llseek = seq_lseek, 1843 - .release = single_release, 1844 - }; 1845 1832 #endif 1846 1833 1847 1834 #if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(CONFIG_CONSOLE_POLL) ··· 2402 2415 .break_ctl = uart_break_ctl, 2403 2416 .wait_until_sent= uart_wait_until_sent, 2404 2417 #ifdef CONFIG_PROC_FS 2405 - .proc_fops = &uart_proc_fops, 2418 + .proc_show = uart_proc_show, 2406 2419 #endif 2407 2420 .tiocmget = uart_tiocmget, 2408 2421 .tiocmset = uart_tiocmset,
+1 -14
drivers/tty/synclink.c
··· 3534 3534 return 0; 3535 3535 } 3536 3536 3537 - static int mgsl_proc_open(struct inode *inode, struct file *file) 3538 - { 3539 - return single_open(file, mgsl_proc_show, NULL); 3540 - } 3541 - 3542 - static const struct file_operations mgsl_proc_fops = { 3543 - .owner = THIS_MODULE, 3544 - .open = mgsl_proc_open, 3545 - .read = seq_read, 3546 - .llseek = seq_lseek, 3547 - .release = single_release, 3548 - }; 3549 - 3550 3537 /* mgsl_allocate_dma_buffers() 3551 3538 * 3552 3539 * Allocate and format DMA buffers (ISA adapter) ··· 4285 4298 .tiocmget = tiocmget, 4286 4299 .tiocmset = tiocmset, 4287 4300 .get_icount = msgl_get_icount, 4288 - .proc_fops = &mgsl_proc_fops, 4301 + .proc_show = mgsl_proc_show, 4289 4302 }; 4290 4303 4291 4304 /*
+1 -14
drivers/tty/synclinkmp.c
··· 1421 1421 return 0; 1422 1422 } 1423 1423 1424 - static int synclinkmp_proc_open(struct inode *inode, struct file *file) 1425 - { 1426 - return single_open(file, synclinkmp_proc_show, NULL); 1427 - } 1428 - 1429 - static const struct file_operations synclinkmp_proc_fops = { 1430 - .owner = THIS_MODULE, 1431 - .open = synclinkmp_proc_open, 1432 - .read = seq_read, 1433 - .llseek = seq_lseek, 1434 - .release = single_release, 1435 - }; 1436 - 1437 1424 /* Return the count of bytes in transmit buffer 1438 1425 */ 1439 1426 static int chars_in_buffer(struct tty_struct *tty) ··· 3886 3899 .tiocmget = tiocmget, 3887 3900 .tiocmset = tiocmset, 3888 3901 .get_icount = get_icount, 3889 - .proc_fops = &synclinkmp_proc_fops, 3902 + .proc_show = synclinkmp_proc_show, 3890 3903 }; 3891 3904 3892 3905
+1 -14
drivers/usb/serial/usb-serial.c
··· 476 476 return 0; 477 477 } 478 478 479 - static int serial_proc_open(struct inode *inode, struct file *file) 480 - { 481 - return single_open(file, serial_proc_show, NULL); 482 - } 483 - 484 - static const struct file_operations serial_proc_fops = { 485 - .owner = THIS_MODULE, 486 - .open = serial_proc_open, 487 - .read = seq_read, 488 - .llseek = seq_lseek, 489 - .release = single_release, 490 - }; 491 - 492 479 static int serial_tiocmget(struct tty_struct *tty) 493 480 { 494 481 struct usb_serial_port *port = tty->driver_data; ··· 1179 1192 .get_icount = serial_get_icount, 1180 1193 .cleanup = serial_cleanup, 1181 1194 .install = serial_install, 1182 - .proc_fops = &serial_proc_fops, 1195 + .proc_show = serial_proc_show, 1183 1196 }; 1184 1197 1185 1198
+3 -3
fs/proc/proc_tty.c
··· 135 135 struct proc_dir_entry *ent; 136 136 137 137 if (!driver->driver_name || driver->proc_entry || 138 - !driver->ops->proc_fops) 138 + !driver->ops->proc_show) 139 139 return; 140 140 141 - ent = proc_create_data(driver->driver_name, 0, proc_tty_driver, 142 - driver->ops->proc_fops, driver); 141 + ent = proc_create_single_data(driver->driver_name, 0, proc_tty_driver, 142 + driver->ops->proc_show, driver); 143 143 driver->proc_entry = ent; 144 144 } 145 145
+1 -1
include/linux/tty_driver.h
··· 293 293 int (*poll_get_char)(struct tty_driver *driver, int line); 294 294 void (*poll_put_char)(struct tty_driver *driver, int line, char ch); 295 295 #endif 296 - const struct file_operations *proc_fops; 296 + int (*proc_show)(struct seq_file *, void *); 297 297 } __randomize_layout; 298 298 299 299 struct tty_driver {