proc tty: switch istallion 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>
This commit is contained in:
Alexey Dobriyan 2009-03-31 15:19:16 -07:00 committed by Linus Torvalds
parent cdda7cd92b
commit 5bd6de7dad

View File

@ -24,6 +24,7 @@
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/tty_flip.h> #include <linux/tty_flip.h>
#include <linux/serial.h> #include <linux/serial.h>
#include <linux/seq_file.h>
#include <linux/cdk.h> #include <linux/cdk.h>
#include <linux/comstats.h> #include <linux/comstats.h>
#include <linux/istallion.h> #include <linux/istallion.h>
@ -613,7 +614,6 @@ static int stli_breakctl(struct tty_struct *tty, int state);
static void stli_waituntilsent(struct tty_struct *tty, int timeout); static void stli_waituntilsent(struct tty_struct *tty, int timeout);
static void stli_sendxchar(struct tty_struct *tty, char ch); static void stli_sendxchar(struct tty_struct *tty, char ch);
static void stli_hangup(struct tty_struct *tty); static void stli_hangup(struct tty_struct *tty);
static int stli_portinfo(struct stlibrd *brdp, struct stliport *portp, int portnr, char *pos);
static int stli_brdinit(struct stlibrd *brdp); static int stli_brdinit(struct stlibrd *brdp);
static int stli_startbrd(struct stlibrd *brdp); static int stli_startbrd(struct stlibrd *brdp);
@ -1893,20 +1893,10 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0); stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
} }
/*****************************************************************************/ static void stli_portinfo(struct seq_file *m, struct stlibrd *brdp, struct stliport *portp, int portnr)
#define MAXLINE 80
/*
* Format info for a specified port. The line is deliberately limited
* to 80 characters. (If it is too long it will be truncated, if too
* short then padded with spaces).
*/
static int stli_portinfo(struct stlibrd *brdp, struct stliport *portp, int portnr, char *pos)
{ {
char *sp, *uart; char *uart;
int rc, cnt; int rc;
rc = stli_portcmdstats(NULL, portp); rc = stli_portcmdstats(NULL, portp);
@ -1918,44 +1908,50 @@ static int stli_portinfo(struct stlibrd *brdp, struct stliport *portp, int portn
default:uart = "CD1400"; break; default:uart = "CD1400"; break;
} }
} }
seq_printf(m, "%d: uart:%s ", portnr, uart);
sp = pos;
sp += sprintf(sp, "%d: uart:%s ", portnr, uart);
if ((brdp->state & BST_STARTED) && (rc >= 0)) { if ((brdp->state & BST_STARTED) && (rc >= 0)) {
sp += sprintf(sp, "tx:%d rx:%d", (int) stli_comstats.txtotal, char sep;
seq_printf(m, "tx:%d rx:%d", (int) stli_comstats.txtotal,
(int) stli_comstats.rxtotal); (int) stli_comstats.rxtotal);
if (stli_comstats.rxframing) if (stli_comstats.rxframing)
sp += sprintf(sp, " fe:%d", seq_printf(m, " fe:%d",
(int) stli_comstats.rxframing); (int) stli_comstats.rxframing);
if (stli_comstats.rxparity) if (stli_comstats.rxparity)
sp += sprintf(sp, " pe:%d", seq_printf(m, " pe:%d",
(int) stli_comstats.rxparity); (int) stli_comstats.rxparity);
if (stli_comstats.rxbreaks) if (stli_comstats.rxbreaks)
sp += sprintf(sp, " brk:%d", seq_printf(m, " brk:%d",
(int) stli_comstats.rxbreaks); (int) stli_comstats.rxbreaks);
if (stli_comstats.rxoverrun) if (stli_comstats.rxoverrun)
sp += sprintf(sp, " oe:%d", seq_printf(m, " oe:%d",
(int) stli_comstats.rxoverrun); (int) stli_comstats.rxoverrun);
cnt = sprintf(sp, "%s%s%s%s%s ", sep = ' ';
(stli_comstats.signals & TIOCM_RTS) ? "|RTS" : "", if (stli_comstats.signals & TIOCM_RTS) {
(stli_comstats.signals & TIOCM_CTS) ? "|CTS" : "", seq_printf(m, "%c%s", sep, "RTS");
(stli_comstats.signals & TIOCM_DTR) ? "|DTR" : "", sep = '|';
(stli_comstats.signals & TIOCM_CD) ? "|DCD" : "", }
(stli_comstats.signals & TIOCM_DSR) ? "|DSR" : ""); if (stli_comstats.signals & TIOCM_CTS) {
*sp = ' '; seq_printf(m, "%c%s", sep, "CTS");
sp += cnt; sep = '|';
}
if (stli_comstats.signals & TIOCM_DTR) {
seq_printf(m, "%c%s", sep, "DTR");
sep = '|';
}
if (stli_comstats.signals & TIOCM_CD) {
seq_printf(m, "%c%s", sep, "DCD");
sep = '|';
}
if (stli_comstats.signals & TIOCM_DSR) {
seq_printf(m, "%c%s", sep, "DSR");
sep = '|';
}
} }
seq_putc(m, '\n');
for (cnt = (sp - pos); (cnt < (MAXLINE - 1)); cnt++)
*sp++ = ' ';
if (cnt >= MAXLINE)
pos[(MAXLINE - 2)] = '+';
pos[(MAXLINE - 1)] = '\n';
return(MAXLINE);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1964,26 +1960,15 @@ static int stli_portinfo(struct stlibrd *brdp, struct stliport *portp, int portn
* Port info, read from the /proc file system. * Port info, read from the /proc file system.
*/ */
static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data) static int stli_proc_show(struct seq_file *m, void *v)
{ {
struct stlibrd *brdp; struct stlibrd *brdp;
struct stliport *portp; struct stliport *portp;
unsigned int brdnr, portnr, totalport; unsigned int brdnr, portnr, totalport;
int curoff, maxoff;
char *pos;
pos = page;
totalport = 0; totalport = 0;
curoff = 0;
if (off == 0) { seq_printf(m, "%s: version %s\n", stli_drvtitle, stli_drvversion);
pos += sprintf(pos, "%s: version %s", stli_drvtitle,
stli_drvversion);
while (pos < (page + MAXLINE - 1))
*pos++ = ' ';
*pos++ = '\n';
}
curoff = MAXLINE;
/* /*
* We scan through for each board, panel and port. The offset is * We scan through for each board, panel and port. The offset is
@ -1996,33 +1981,31 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo
if (brdp->state == 0) if (brdp->state == 0)
continue; continue;
maxoff = curoff + (brdp->nrports * MAXLINE);
if (off >= maxoff) {
curoff = maxoff;
continue;
}
totalport = brdnr * STL_MAXPORTS; totalport = brdnr * STL_MAXPORTS;
for (portnr = 0; (portnr < brdp->nrports); portnr++, for (portnr = 0; (portnr < brdp->nrports); portnr++,
totalport++) { totalport++) {
portp = brdp->ports[portnr]; portp = brdp->ports[portnr];
if (portp == NULL) if (portp == NULL)
continue; continue;
if (off >= (curoff += MAXLINE)) stli_portinfo(m, brdp, portp, totalport);
continue;
if ((pos - page + MAXLINE) > count)
goto stli_readdone;
pos += stli_portinfo(brdp, portp, totalport, pos);
} }
} }
return 0;
*eof = 1;
stli_readdone:
*start = page;
return(pos - page);
} }
static int stli_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, stli_proc_show, NULL);
}
static const struct file_operations stli_proc_fops = {
.owner = THIS_MODULE,
.open = stli_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/*****************************************************************************/ /*****************************************************************************/
/* /*
@ -4427,9 +4410,9 @@ static const struct tty_operations stli_ops = {
.break_ctl = stli_breakctl, .break_ctl = stli_breakctl,
.wait_until_sent = stli_waituntilsent, .wait_until_sent = stli_waituntilsent,
.send_xchar = stli_sendxchar, .send_xchar = stli_sendxchar,
.read_proc = stli_readproc,
.tiocmget = stli_tiocmget, .tiocmget = stli_tiocmget,
.tiocmset = stli_tiocmset, .tiocmset = stli_tiocmset,
.proc_fops = &stli_proc_fops,
}; };
static const struct tty_port_operations stli_port_ops = { static const struct tty_port_operations stli_port_ops = {