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

proc tty: switch synclinkmp to ->proc_fops

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexey Dobriyan and committed by
Linus Torvalds
e6c8dd8a a18c56e5

+35 -41
+35 -41
drivers/char/synclinkmp.c
··· 50 50 #include <linux/ptrace.h> 51 51 #include <linux/ioport.h> 52 52 #include <linux/mm.h> 53 + #include <linux/seq_file.h> 53 54 #include <linux/slab.h> 54 55 #include <linux/netdevice.h> 55 56 #include <linux/vmalloc.h> ··· 521 520 static void tx_release(struct tty_struct *tty); 522 521 523 522 static int ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); 524 - static int read_proc(char *page, char **start, off_t off, int count,int *eof, void *data); 525 523 static int chars_in_buffer(struct tty_struct *tty); 526 524 static void throttle(struct tty_struct * tty); 527 525 static void unthrottle(struct tty_struct * tty); ··· 1354 1354 * /proc fs routines.... 1355 1355 */ 1356 1356 1357 - static inline int line_info(char *buf, SLMP_INFO *info) 1357 + static inline void line_info(struct seq_file *m, SLMP_INFO *info) 1358 1358 { 1359 1359 char stat_buf[30]; 1360 - int ret; 1361 1360 unsigned long flags; 1362 1361 1363 - ret = sprintf(buf, "%s: SCABase=%08x Mem=%08X StatusControl=%08x LCR=%08X\n" 1362 + seq_printf(m, "%s: SCABase=%08x Mem=%08X StatusControl=%08x LCR=%08X\n" 1364 1363 "\tIRQ=%d MaxFrameSize=%u\n", 1365 1364 info->device_name, 1366 1365 info->phys_sca_base, ··· 1390 1391 strcat(stat_buf, "|RI"); 1391 1392 1392 1393 if (info->params.mode == MGSL_MODE_HDLC) { 1393 - ret += sprintf(buf+ret, "\tHDLC txok:%d rxok:%d", 1394 + seq_printf(m, "\tHDLC txok:%d rxok:%d", 1394 1395 info->icount.txok, info->icount.rxok); 1395 1396 if (info->icount.txunder) 1396 - ret += sprintf(buf+ret, " txunder:%d", info->icount.txunder); 1397 + seq_printf(m, " txunder:%d", info->icount.txunder); 1397 1398 if (info->icount.txabort) 1398 - ret += sprintf(buf+ret, " txabort:%d", info->icount.txabort); 1399 + seq_printf(m, " txabort:%d", info->icount.txabort); 1399 1400 if (info->icount.rxshort) 1400 - ret += sprintf(buf+ret, " rxshort:%d", info->icount.rxshort); 1401 + seq_printf(m, " rxshort:%d", info->icount.rxshort); 1401 1402 if (info->icount.rxlong) 1402 - ret += sprintf(buf+ret, " rxlong:%d", info->icount.rxlong); 1403 + seq_printf(m, " rxlong:%d", info->icount.rxlong); 1403 1404 if (info->icount.rxover) 1404 - ret += sprintf(buf+ret, " rxover:%d", info->icount.rxover); 1405 + seq_printf(m, " rxover:%d", info->icount.rxover); 1405 1406 if (info->icount.rxcrc) 1406 - ret += sprintf(buf+ret, " rxlong:%d", info->icount.rxcrc); 1407 + seq_printf(m, " rxlong:%d", info->icount.rxcrc); 1407 1408 } else { 1408 - ret += sprintf(buf+ret, "\tASYNC tx:%d rx:%d", 1409 + seq_printf(m, "\tASYNC tx:%d rx:%d", 1409 1410 info->icount.tx, info->icount.rx); 1410 1411 if (info->icount.frame) 1411 - ret += sprintf(buf+ret, " fe:%d", info->icount.frame); 1412 + seq_printf(m, " fe:%d", info->icount.frame); 1412 1413 if (info->icount.parity) 1413 - ret += sprintf(buf+ret, " pe:%d", info->icount.parity); 1414 + seq_printf(m, " pe:%d", info->icount.parity); 1414 1415 if (info->icount.brk) 1415 - ret += sprintf(buf+ret, " brk:%d", info->icount.brk); 1416 + seq_printf(m, " brk:%d", info->icount.brk); 1416 1417 if (info->icount.overrun) 1417 - ret += sprintf(buf+ret, " oe:%d", info->icount.overrun); 1418 + seq_printf(m, " oe:%d", info->icount.overrun); 1418 1419 } 1419 1420 1420 1421 /* Append serial signal status to end */ 1421 - ret += sprintf(buf+ret, " %s\n", stat_buf+1); 1422 + seq_printf(m, " %s\n", stat_buf+1); 1422 1423 1423 - ret += sprintf(buf+ret, "\ttxactive=%d bh_req=%d bh_run=%d pending_bh=%x\n", 1424 + seq_printf(m, "\ttxactive=%d bh_req=%d bh_run=%d pending_bh=%x\n", 1424 1425 info->tx_active,info->bh_requested,info->bh_running, 1425 1426 info->pending_bh); 1426 - 1427 - return ret; 1428 1427 } 1429 1428 1430 1429 /* Called to print information about devices 1431 1430 */ 1432 - static int read_proc(char *page, char **start, off_t off, int count, 1433 - int *eof, void *data) 1431 + static int synclinkmp_proc_show(struct seq_file *m, void *v) 1434 1432 { 1435 - int len = 0, l; 1436 - off_t begin = 0; 1437 1433 SLMP_INFO *info; 1438 1434 1439 - len += sprintf(page, "synclinkmp driver:%s\n", driver_version); 1435 + seq_printf(m, "synclinkmp driver:%s\n", driver_version); 1440 1436 1441 1437 info = synclinkmp_device_list; 1442 1438 while( info ) { 1443 - l = line_info(page + len, info); 1444 - len += l; 1445 - if (len+begin > off+count) 1446 - goto done; 1447 - if (len+begin < off) { 1448 - begin += len; 1449 - len = 0; 1450 - } 1439 + line_info(m, info); 1451 1440 info = info->next_device; 1452 1441 } 1453 - 1454 - *eof = 1; 1455 - done: 1456 - if (off >= len+begin) 1457 - return 0; 1458 - *start = page + (off-begin); 1459 - return ((count < begin+len-off) ? count : begin+len-off); 1442 + return 0; 1460 1443 } 1444 + 1445 + static int synclinkmp_proc_open(struct inode *inode, struct file *file) 1446 + { 1447 + return single_open(file, synclinkmp_proc_show, NULL); 1448 + } 1449 + 1450 + static const struct file_operations synclinkmp_proc_fops = { 1451 + .owner = THIS_MODULE, 1452 + .open = synclinkmp_proc_open, 1453 + .read = seq_read, 1454 + .llseek = seq_lseek, 1455 + .release = single_release, 1456 + }; 1461 1457 1462 1458 /* Return the count of bytes in transmit buffer 1463 1459 */ ··· 3899 3905 .send_xchar = send_xchar, 3900 3906 .break_ctl = set_break, 3901 3907 .wait_until_sent = wait_until_sent, 3902 - .read_proc = read_proc, 3903 3908 .set_termios = set_termios, 3904 3909 .stop = tx_hold, 3905 3910 .start = tx_release, 3906 3911 .hangup = hangup, 3907 3912 .tiocmget = tiocmget, 3908 3913 .tiocmset = tiocmset, 3914 + .proc_fops = &synclinkmp_proc_fops, 3909 3915 }; 3910 3916 3911 3917