diff options
-rw-r--r-- | drivers/char/synclink.c | 98 |
1 files changed, 39 insertions, 59 deletions
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 0057a8f58cb1..afd0b26ca056 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c | |||
@@ -79,6 +79,7 @@ | |||
79 | #include <linux/ptrace.h> | 79 | #include <linux/ptrace.h> |
80 | #include <linux/ioport.h> | 80 | #include <linux/ioport.h> |
81 | #include <linux/mm.h> | 81 | #include <linux/mm.h> |
82 | #include <linux/seq_file.h> | ||
82 | #include <linux/slab.h> | 83 | #include <linux/slab.h> |
83 | #include <linux/delay.h> | 84 | #include <linux/delay.h> |
84 | #include <linux/netdevice.h> | 85 | #include <linux/netdevice.h> |
@@ -3459,18 +3460,17 @@ cleanup: | |||
3459 | * /proc fs routines.... | 3460 | * /proc fs routines.... |
3460 | */ | 3461 | */ |
3461 | 3462 | ||
3462 | static inline int line_info(char *buf, struct mgsl_struct *info) | 3463 | static inline void line_info(struct seq_file *m, struct mgsl_struct *info) |
3463 | { | 3464 | { |
3464 | char stat_buf[30]; | 3465 | char stat_buf[30]; |
3465 | int ret; | ||
3466 | unsigned long flags; | 3466 | unsigned long flags; |
3467 | 3467 | ||
3468 | if (info->bus_type == MGSL_BUS_TYPE_PCI) { | 3468 | if (info->bus_type == MGSL_BUS_TYPE_PCI) { |
3469 | ret = sprintf(buf, "%s:PCI io:%04X irq:%d mem:%08X lcr:%08X", | 3469 | seq_printf(m, "%s:PCI io:%04X irq:%d mem:%08X lcr:%08X", |
3470 | info->device_name, info->io_base, info->irq_level, | 3470 | info->device_name, info->io_base, info->irq_level, |
3471 | info->phys_memory_base, info->phys_lcr_base); | 3471 | info->phys_memory_base, info->phys_lcr_base); |
3472 | } else { | 3472 | } else { |
3473 | ret = sprintf(buf, "%s:(E)ISA io:%04X irq:%d dma:%d", | 3473 | seq_printf(m, "%s:(E)ISA io:%04X irq:%d dma:%d", |
3474 | info->device_name, info->io_base, | 3474 | info->device_name, info->io_base, |
3475 | info->irq_level, info->dma_level); | 3475 | info->irq_level, info->dma_level); |
3476 | } | 3476 | } |
@@ -3497,37 +3497,37 @@ static inline int line_info(char *buf, struct mgsl_struct *info) | |||
3497 | 3497 | ||
3498 | if (info->params.mode == MGSL_MODE_HDLC || | 3498 | if (info->params.mode == MGSL_MODE_HDLC || |
3499 | info->params.mode == MGSL_MODE_RAW ) { | 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 | info->icount.txok, info->icount.rxok); | 3501 | info->icount.txok, info->icount.rxok); |
3502 | if (info->icount.txunder) | 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 | if (info->icount.txabort) | 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 | if (info->icount.rxshort) | 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 | if (info->icount.rxlong) | 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 | if (info->icount.rxover) | 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 | if (info->icount.rxcrc) | 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 | } else { | 3514 | } else { |
3515 | ret += sprintf(buf+ret, " ASYNC tx:%d rx:%d", | 3515 | seq_printf(m, " ASYNC tx:%d rx:%d", |
3516 | info->icount.tx, info->icount.rx); | 3516 | info->icount.tx, info->icount.rx); |
3517 | if (info->icount.frame) | 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 | if (info->icount.parity) | 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 | if (info->icount.brk) | 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 | if (info->icount.overrun) | 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 | /* Append serial signal status to end */ | 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 | info->tx_active,info->bh_requested,info->bh_running, | 3531 | info->tx_active,info->bh_requested,info->bh_running, |
3532 | info->pending_bh); | 3532 | info->pending_bh); |
3533 | 3533 | ||
@@ -3544,60 +3544,40 @@ static inline int line_info(char *buf, struct mgsl_struct *info) | |||
3544 | u16 Tmr = usc_InReg( info, TMR ); | 3544 | u16 Tmr = usc_InReg( info, TMR ); |
3545 | u16 Tccr = usc_InReg( info, TCCR ); | 3545 | u16 Tccr = usc_InReg( info, TCCR ); |
3546 | u16 Ccar = inw( info->io_base + CCAR ); | 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 | "ricr=%04X icr =%04X dccr=%04X tmr=%04X tccr=%04X ccar=%04X\n", | 3548 | "ricr=%04X icr =%04X dccr=%04X tmr=%04X tccr=%04X ccar=%04X\n", |
3549 | Tcsr,Tdmr,Ticr,Rscr,Rdmr,Ricr,Icr,Dccr,Tmr,Tccr,Ccar ); | 3549 | Tcsr,Tdmr,Ticr,Rscr,Rdmr,Ricr,Icr,Dccr,Tmr,Tccr,Ccar ); |
3550 | } | 3550 | } |
3551 | spin_unlock_irqrestore(&info->irq_spinlock,flags); | 3551 | spin_unlock_irqrestore(&info->irq_spinlock,flags); |
3552 | 3552 | } | |
3553 | return ret; | ||
3554 | |||
3555 | } /* end of line_info() */ | ||
3556 | 3553 | ||
3557 | /* mgsl_read_proc() | 3554 | /* Called to print information about devices */ |
3558 | * | 3555 | static int mgsl_proc_show(struct seq_file *m, void *v) |
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) | ||
3573 | { | 3556 | { |
3574 | int len = 0, l; | ||
3575 | off_t begin = 0; | ||
3576 | struct mgsl_struct *info; | 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 | info = mgsl_device_list; | 3561 | info = mgsl_device_list; |
3581 | while( info ) { | 3562 | while( info ) { |
3582 | l = line_info(page + len, info); | 3563 | line_info(m, 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 | } | ||
3590 | info = info->next_device; | 3564 | info = info->next_device; |
3591 | } | 3565 | } |
3566 | return 0; | ||
3567 | } | ||
3592 | 3568 | ||
3593 | *eof = 1; | 3569 | static int mgsl_proc_open(struct inode *inode, struct file *file) |
3594 | done: | 3570 | { |
3595 | if (off >= len+begin) | 3571 | return single_open(file, mgsl_proc_show, NULL); |
3596 | return 0; | 3572 | } |
3597 | *start = page + (off-begin); | 3573 | |
3598 | return ((count < begin+len-off) ? count : begin+len-off); | 3574 | static const struct file_operations mgsl_proc_fops = { |
3599 | 3575 | .owner = THIS_MODULE, | |
3600 | } /* end of mgsl_read_proc() */ | 3576 | .open = mgsl_proc_open, |
3577 | .read = seq_read, | ||
3578 | .llseek = seq_lseek, | ||
3579 | .release = single_release, | ||
3580 | }; | ||
3601 | 3581 | ||
3602 | /* mgsl_allocate_dma_buffers() | 3582 | /* mgsl_allocate_dma_buffers() |
3603 | * | 3583 | * |
@@ -4335,13 +4315,13 @@ static const struct tty_operations mgsl_ops = { | |||
4335 | .send_xchar = mgsl_send_xchar, | 4315 | .send_xchar = mgsl_send_xchar, |
4336 | .break_ctl = mgsl_break, | 4316 | .break_ctl = mgsl_break, |
4337 | .wait_until_sent = mgsl_wait_until_sent, | 4317 | .wait_until_sent = mgsl_wait_until_sent, |
4338 | .read_proc = mgsl_read_proc, | ||
4339 | .set_termios = mgsl_set_termios, | 4318 | .set_termios = mgsl_set_termios, |
4340 | .stop = mgsl_stop, | 4319 | .stop = mgsl_stop, |
4341 | .start = mgsl_start, | 4320 | .start = mgsl_start, |
4342 | .hangup = mgsl_hangup, | 4321 | .hangup = mgsl_hangup, |
4343 | .tiocmget = tiocmget, | 4322 | .tiocmget = tiocmget, |
4344 | .tiocmset = tiocmset, | 4323 | .tiocmset = tiocmset, |
4324 | .proc_fops = &mgsl_proc_fops, | ||
4345 | }; | 4325 | }; |
4346 | 4326 | ||
4347 | /* | 4327 | /* |