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

proc tty: switch synclink 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
d337829b 8561c44c

+39 -59
+39 -59
drivers/char/synclink.c
··· 79 79 #include <linux/ptrace.h> 80 80 #include <linux/ioport.h> 81 81 #include <linux/mm.h> 82 + #include <linux/seq_file.h> 82 83 #include <linux/slab.h> 83 84 #include <linux/delay.h> 84 85 #include <linux/netdevice.h> ··· 3460 3459 * /proc fs routines.... 3461 3460 */ 3462 3461 3463 - static inline int line_info(char *buf, struct mgsl_struct *info) 3462 + static inline void line_info(struct seq_file *m, struct mgsl_struct *info) 3464 3463 { 3465 3464 char stat_buf[30]; 3466 - int ret; 3467 3465 unsigned long flags; 3468 3466 3469 3467 if (info->bus_type == MGSL_BUS_TYPE_PCI) { 3470 - ret = sprintf(buf, "%s:PCI io:%04X irq:%d mem:%08X lcr:%08X", 3468 + seq_printf(m, "%s:PCI io:%04X irq:%d mem:%08X lcr:%08X", 3471 3469 info->device_name, info->io_base, info->irq_level, 3472 3470 info->phys_memory_base, info->phys_lcr_base); 3473 3471 } else { 3474 - ret = sprintf(buf, "%s:(E)ISA io:%04X irq:%d dma:%d", 3472 + seq_printf(m, "%s:(E)ISA io:%04X irq:%d dma:%d", 3475 3473 info->device_name, info->io_base, 3476 3474 info->irq_level, info->dma_level); 3477 3475 } ··· 3497 3497 3498 3498 if (info->params.mode == MGSL_MODE_HDLC || 3499 3499 info->params.mode == MGSL_MODE_RAW ) { 3500 - ret += sprintf(buf+ret, " HDLC txok:%d rxok:%d", 3500 + seq_printf(m, " HDLC txok:%d rxok:%d", 3501 3501 info->icount.txok, info->icount.rxok); 3502 3502 if (info->icount.txunder) 3503 - ret += sprintf(buf+ret, " txunder:%d", info->icount.txunder); 3503 + seq_printf(m, " txunder:%d", info->icount.txunder); 3504 3504 if (info->icount.txabort) 3505 - ret += sprintf(buf+ret, " txabort:%d", info->icount.txabort); 3505 + seq_printf(m, " txabort:%d", info->icount.txabort); 3506 3506 if (info->icount.rxshort) 3507 - ret += sprintf(buf+ret, " rxshort:%d", info->icount.rxshort); 3507 + seq_printf(m, " rxshort:%d", info->icount.rxshort); 3508 3508 if (info->icount.rxlong) 3509 - ret += sprintf(buf+ret, " rxlong:%d", info->icount.rxlong); 3509 + seq_printf(m, " rxlong:%d", info->icount.rxlong); 3510 3510 if (info->icount.rxover) 3511 - ret += sprintf(buf+ret, " rxover:%d", info->icount.rxover); 3511 + seq_printf(m, " rxover:%d", info->icount.rxover); 3512 3512 if (info->icount.rxcrc) 3513 - ret += sprintf(buf+ret, " rxcrc:%d", info->icount.rxcrc); 3513 + seq_printf(m, " rxcrc:%d", info->icount.rxcrc); 3514 3514 } else { 3515 - ret += sprintf(buf+ret, " ASYNC tx:%d rx:%d", 3515 + seq_printf(m, " ASYNC tx:%d rx:%d", 3516 3516 info->icount.tx, info->icount.rx); 3517 3517 if (info->icount.frame) 3518 - ret += sprintf(buf+ret, " fe:%d", info->icount.frame); 3518 + seq_printf(m, " fe:%d", info->icount.frame); 3519 3519 if (info->icount.parity) 3520 - ret += sprintf(buf+ret, " pe:%d", info->icount.parity); 3520 + seq_printf(m, " pe:%d", info->icount.parity); 3521 3521 if (info->icount.brk) 3522 - ret += sprintf(buf+ret, " brk:%d", info->icount.brk); 3522 + seq_printf(m, " brk:%d", info->icount.brk); 3523 3523 if (info->icount.overrun) 3524 - ret += sprintf(buf+ret, " oe:%d", info->icount.overrun); 3524 + seq_printf(m, " oe:%d", info->icount.overrun); 3525 3525 } 3526 3526 3527 3527 /* Append serial signal status to end */ 3528 - ret += sprintf(buf+ret, " %s\n", stat_buf+1); 3528 + seq_printf(m, " %s\n", stat_buf+1); 3529 3529 3530 - ret += sprintf(buf+ret, "txactive=%d bh_req=%d bh_run=%d pending_bh=%x\n", 3530 + seq_printf(m, "txactive=%d bh_req=%d bh_run=%d pending_bh=%x\n", 3531 3531 info->tx_active,info->bh_requested,info->bh_running, 3532 3532 info->pending_bh); 3533 3533 ··· 3544 3544 u16 Tmr = usc_InReg( info, TMR ); 3545 3545 u16 Tccr = usc_InReg( info, TCCR ); 3546 3546 u16 Ccar = inw( info->io_base + CCAR ); 3547 - ret += sprintf(buf+ret, "tcsr=%04X tdmr=%04X ticr=%04X rcsr=%04X rdmr=%04X\n" 3547 + seq_printf(m, "tcsr=%04X tdmr=%04X ticr=%04X rcsr=%04X rdmr=%04X\n" 3548 3548 "ricr=%04X icr =%04X dccr=%04X tmr=%04X tccr=%04X ccar=%04X\n", 3549 3549 Tcsr,Tdmr,Ticr,Rscr,Rdmr,Ricr,Icr,Dccr,Tmr,Tccr,Ccar ); 3550 3550 } 3551 3551 spin_unlock_irqrestore(&info->irq_spinlock,flags); 3552 - 3553 - return ret; 3554 - 3555 - } /* end of line_info() */ 3552 + } 3556 3553 3557 - /* mgsl_read_proc() 3558 - * 3559 - * Called to print information about devices 3560 - * 3561 - * Arguments: 3562 - * page page of memory to hold returned info 3563 - * start 3564 - * off 3565 - * count 3566 - * eof 3567 - * data 3568 - * 3569 - * Return Value: 3570 - */ 3571 - static int mgsl_read_proc(char *page, char **start, off_t off, int count, 3572 - int *eof, void *data) 3554 + /* Called to print information about devices */ 3555 + static int mgsl_proc_show(struct seq_file *m, void *v) 3573 3556 { 3574 - int len = 0, l; 3575 - off_t begin = 0; 3576 3557 struct mgsl_struct *info; 3577 3558 3578 - len += sprintf(page, "synclink driver:%s\n", driver_version); 3559 + seq_printf(m, "synclink driver:%s\n", driver_version); 3579 3560 3580 3561 info = mgsl_device_list; 3581 3562 while( info ) { 3582 - l = line_info(page + len, info); 3583 - len += l; 3584 - if (len+begin > off+count) 3585 - goto done; 3586 - if (len+begin < off) { 3587 - begin += len; 3588 - len = 0; 3589 - } 3563 + line_info(m, info); 3590 3564 info = info->next_device; 3591 3565 } 3566 + return 0; 3567 + } 3592 3568 3593 - *eof = 1; 3594 - done: 3595 - if (off >= len+begin) 3596 - return 0; 3597 - *start = page + (off-begin); 3598 - return ((count < begin+len-off) ? count : begin+len-off); 3599 - 3600 - } /* end of mgsl_read_proc() */ 3569 + static int mgsl_proc_open(struct inode *inode, struct file *file) 3570 + { 3571 + return single_open(file, mgsl_proc_show, NULL); 3572 + } 3573 + 3574 + static const struct file_operations mgsl_proc_fops = { 3575 + .owner = THIS_MODULE, 3576 + .open = mgsl_proc_open, 3577 + .read = seq_read, 3578 + .llseek = seq_lseek, 3579 + .release = single_release, 3580 + }; 3601 3581 3602 3582 /* mgsl_allocate_dma_buffers() 3603 3583 * ··· 4315 4335 .send_xchar = mgsl_send_xchar, 4316 4336 .break_ctl = mgsl_break, 4317 4337 .wait_until_sent = mgsl_wait_until_sent, 4318 - .read_proc = mgsl_read_proc, 4319 4338 .set_termios = mgsl_set_termios, 4320 4339 .stop = mgsl_stop, 4321 4340 .start = mgsl_start, 4322 4341 .hangup = mgsl_hangup, 4323 4342 .tiocmget = tiocmget, 4324 4343 .tiocmset = tiocmset, 4344 + .proc_fops = &mgsl_proc_fops, 4325 4345 }; 4326 4346 4327 4347 /*