Commit d337829b authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Linus Torvalds

proc tty: switch synclink to ->proc_fops

Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8561c44c
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/seq_file.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
...@@ -3459,18 +3460,17 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp) ...@@ -3459,18 +3460,17 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
* /proc fs routines.... * /proc fs routines....
*/ */
static inline int line_info(char *buf, struct mgsl_struct *info) static inline void line_info(struct seq_file *m, struct mgsl_struct *info)
{ {
char stat_buf[30]; char stat_buf[30];
int ret;
unsigned long flags; unsigned long flags;
if (info->bus_type == MGSL_BUS_TYPE_PCI) { if (info->bus_type == MGSL_BUS_TYPE_PCI) {
ret = sprintf(buf, "%s:PCI io:%04X irq:%d mem:%08X lcr:%08X", seq_printf(m, "%s:PCI io:%04X irq:%d mem:%08X lcr:%08X",
info->device_name, info->io_base, info->irq_level, info->device_name, info->io_base, info->irq_level,
info->phys_memory_base, info->phys_lcr_base); info->phys_memory_base, info->phys_lcr_base);
} else { } else {
ret = sprintf(buf, "%s:(E)ISA io:%04X irq:%d dma:%d", seq_printf(m, "%s:(E)ISA io:%04X irq:%d dma:%d",
info->device_name, info->io_base, info->device_name, info->io_base,
info->irq_level, info->dma_level); info->irq_level, info->dma_level);
} }
...@@ -3497,37 +3497,37 @@ static inline int line_info(char *buf, struct mgsl_struct *info) ...@@ -3497,37 +3497,37 @@ static inline int line_info(char *buf, struct mgsl_struct *info)
if (info->params.mode == MGSL_MODE_HDLC || if (info->params.mode == MGSL_MODE_HDLC ||
info->params.mode == MGSL_MODE_RAW ) { info->params.mode == MGSL_MODE_RAW ) {
ret += sprintf(buf+ret, " HDLC txok:%d rxok:%d", seq_printf(m, " HDLC txok:%d rxok:%d",
info->icount.txok, info->icount.rxok); info->icount.txok, info->icount.rxok);
if (info->icount.txunder) if (info->icount.txunder)
ret += sprintf(buf+ret, " txunder:%d", info->icount.txunder); seq_printf(m, " txunder:%d", info->icount.txunder);
if (info->icount.txabort) if (info->icount.txabort)
ret += sprintf(buf+ret, " txabort:%d", info->icount.txabort); seq_printf(m, " txabort:%d", info->icount.txabort);
if (info->icount.rxshort) if (info->icount.rxshort)
ret += sprintf(buf+ret, " rxshort:%d", info->icount.rxshort); seq_printf(m, " rxshort:%d", info->icount.rxshort);
if (info->icount.rxlong) if (info->icount.rxlong)
ret += sprintf(buf+ret, " rxlong:%d", info->icount.rxlong); seq_printf(m, " rxlong:%d", info->icount.rxlong);
if (info->icount.rxover) if (info->icount.rxover)
ret += sprintf(buf+ret, " rxover:%d", info->icount.rxover); seq_printf(m, " rxover:%d", info->icount.rxover);
if (info->icount.rxcrc) if (info->icount.rxcrc)
ret += sprintf(buf+ret, " rxcrc:%d", info->icount.rxcrc); seq_printf(m, " rxcrc:%d", info->icount.rxcrc);
} else { } else {
ret += sprintf(buf+ret, " ASYNC tx:%d rx:%d", seq_printf(m, " ASYNC tx:%d rx:%d",
info->icount.tx, info->icount.rx); info->icount.tx, info->icount.rx);
if (info->icount.frame) if (info->icount.frame)
ret += sprintf(buf+ret, " fe:%d", info->icount.frame); seq_printf(m, " fe:%d", info->icount.frame);
if (info->icount.parity) if (info->icount.parity)
ret += sprintf(buf+ret, " pe:%d", info->icount.parity); seq_printf(m, " pe:%d", info->icount.parity);
if (info->icount.brk) if (info->icount.brk)
ret += sprintf(buf+ret, " brk:%d", info->icount.brk); seq_printf(m, " brk:%d", info->icount.brk);
if (info->icount.overrun) if (info->icount.overrun)
ret += sprintf(buf+ret, " oe:%d", info->icount.overrun); seq_printf(m, " oe:%d", info->icount.overrun);
} }
/* Append serial signal status to end */ /* Append serial signal status to end */
ret += sprintf(buf+ret, " %s\n", stat_buf+1); seq_printf(m, " %s\n", stat_buf+1);
ret += sprintf(buf+ret, "txactive=%d bh_req=%d bh_run=%d pending_bh=%x\n", seq_printf(m, "txactive=%d bh_req=%d bh_run=%d pending_bh=%x\n",
info->tx_active,info->bh_requested,info->bh_running, info->tx_active,info->bh_requested,info->bh_running,
info->pending_bh); info->pending_bh);
...@@ -3544,60 +3544,40 @@ static inline int line_info(char *buf, struct mgsl_struct *info) ...@@ -3544,60 +3544,40 @@ static inline int line_info(char *buf, struct mgsl_struct *info)
u16 Tmr = usc_InReg( info, TMR ); u16 Tmr = usc_InReg( info, TMR );
u16 Tccr = usc_InReg( info, TCCR ); u16 Tccr = usc_InReg( info, TCCR );
u16 Ccar = inw( info->io_base + CCAR ); u16 Ccar = inw( info->io_base + CCAR );
ret += sprintf(buf+ret, "tcsr=%04X tdmr=%04X ticr=%04X rcsr=%04X rdmr=%04X\n" seq_printf(m, "tcsr=%04X tdmr=%04X ticr=%04X rcsr=%04X rdmr=%04X\n"
"ricr=%04X icr =%04X dccr=%04X tmr=%04X tccr=%04X ccar=%04X\n", "ricr=%04X icr =%04X dccr=%04X tmr=%04X tccr=%04X ccar=%04X\n",
Tcsr,Tdmr,Ticr,Rscr,Rdmr,Ricr,Icr,Dccr,Tmr,Tccr,Ccar ); Tcsr,Tdmr,Ticr,Rscr,Rdmr,Ricr,Icr,Dccr,Tmr,Tccr,Ccar );
} }
spin_unlock_irqrestore(&info->irq_spinlock,flags); spin_unlock_irqrestore(&info->irq_spinlock,flags);
}
return ret;
} /* end of line_info() */
/* mgsl_read_proc() /* Called to print information about devices */
* static int mgsl_proc_show(struct seq_file *m, void *v)
* Called to print information about devices
*
* Arguments:
* page page of memory to hold returned info
* start
* off
* count
* eof
* data
*
* Return Value:
*/
static int mgsl_read_proc(char *page, char **start, off_t off, int count,
int *eof, void *data)
{ {
int len = 0, l;
off_t begin = 0;
struct mgsl_struct *info; struct mgsl_struct *info;
len += sprintf(page, "synclink driver:%s\n", driver_version); seq_printf(m, "synclink driver:%s\n", driver_version);
info = mgsl_device_list; info = mgsl_device_list;
while( info ) { while( info ) {
l = line_info(page + len, info); line_info(m, info);
len += l;
if (len+begin > off+count)
goto done;
if (len+begin < off) {
begin += len;
len = 0;
}
info = info->next_device; info = info->next_device;
} }
return 0;
}
*eof = 1; static int mgsl_proc_open(struct inode *inode, struct file *file)
done: {
if (off >= len+begin) return single_open(file, mgsl_proc_show, NULL);
return 0; }
*start = page + (off-begin);
return ((count < begin+len-off) ? count : begin+len-off); static const struct file_operations mgsl_proc_fops = {
.owner = THIS_MODULE,
} /* end of mgsl_read_proc() */ .open = mgsl_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/* mgsl_allocate_dma_buffers() /* mgsl_allocate_dma_buffers()
* *
...@@ -4335,13 +4315,13 @@ static const struct tty_operations mgsl_ops = { ...@@ -4335,13 +4315,13 @@ static const struct tty_operations mgsl_ops = {
.send_xchar = mgsl_send_xchar, .send_xchar = mgsl_send_xchar,
.break_ctl = mgsl_break, .break_ctl = mgsl_break,
.wait_until_sent = mgsl_wait_until_sent, .wait_until_sent = mgsl_wait_until_sent,
.read_proc = mgsl_read_proc,
.set_termios = mgsl_set_termios, .set_termios = mgsl_set_termios,
.stop = mgsl_stop, .stop = mgsl_stop,
.start = mgsl_start, .start = mgsl_start,
.hangup = mgsl_hangup, .hangup = mgsl_hangup,
.tiocmget = tiocmget, .tiocmget = tiocmget,
.tiocmset = tiocmset, .tiocmset = tiocmset,
.proc_fops = &mgsl_proc_fops,
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment