Commit 8561c44c authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Linus Torvalds

proc tty: switch stallion 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 87687144
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,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/cd1400.h> #include <linux/cd1400.h>
#include <linux/sc26198.h> #include <linux/sc26198.h>
#include <linux/comstats.h> #include <linux/comstats.h>
...@@ -1379,52 +1380,47 @@ static void stl_sendxchar(struct tty_struct *tty, char ch) ...@@ -1379,52 +1380,47 @@ static void stl_sendxchar(struct tty_struct *tty, char ch)
stl_putchar(tty, ch); stl_putchar(tty, ch);
} }
/*****************************************************************************/ static void stl_portinfo(struct seq_file *m, struct stlport *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 stl_portinfo(struct stlport *portp, int portnr, char *pos)
{ {
char *sp; int sigs;
int sigs, cnt; char sep;
sp = pos; seq_printf(m, "%d: uart:%s tx:%d rx:%d",
sp += sprintf(sp, "%d: uart:%s tx:%d rx:%d",
portnr, (portp->hwid == 1) ? "SC26198" : "CD1400", portnr, (portp->hwid == 1) ? "SC26198" : "CD1400",
(int) portp->stats.txtotal, (int) portp->stats.rxtotal); (int) portp->stats.txtotal, (int) portp->stats.rxtotal);
if (portp->stats.rxframing) if (portp->stats.rxframing)
sp += sprintf(sp, " fe:%d", (int) portp->stats.rxframing); seq_printf(m, " fe:%d", (int) portp->stats.rxframing);
if (portp->stats.rxparity) if (portp->stats.rxparity)
sp += sprintf(sp, " pe:%d", (int) portp->stats.rxparity); seq_printf(m, " pe:%d", (int) portp->stats.rxparity);
if (portp->stats.rxbreaks) if (portp->stats.rxbreaks)
sp += sprintf(sp, " brk:%d", (int) portp->stats.rxbreaks); seq_printf(m, " brk:%d", (int) portp->stats.rxbreaks);
if (portp->stats.rxoverrun) if (portp->stats.rxoverrun)
sp += sprintf(sp, " oe:%d", (int) portp->stats.rxoverrun); seq_printf(m, " oe:%d", (int) portp->stats.rxoverrun);
sigs = stl_getsignals(portp); sigs = stl_getsignals(portp);
cnt = sprintf(sp, "%s%s%s%s%s ", sep = ' ';
(sigs & TIOCM_RTS) ? "|RTS" : "", if (sigs & TIOCM_RTS) {
(sigs & TIOCM_CTS) ? "|CTS" : "", seq_printf(m, "%c%s", sep, "RTS");
(sigs & TIOCM_DTR) ? "|DTR" : "", sep = '|';
(sigs & TIOCM_CD) ? "|DCD" : "", }
(sigs & TIOCM_DSR) ? "|DSR" : ""); if (sigs & TIOCM_CTS) {
*sp = ' '; seq_printf(m, "%c%s", sep, "CTS");
sp += cnt; sep = '|';
}
for (cnt = sp - pos; cnt < (MAXLINE - 1); cnt++) if (sigs & TIOCM_DTR) {
*sp++ = ' '; seq_printf(m, "%c%s", sep, "DTR");
if (cnt >= MAXLINE) sep = '|';
pos[(MAXLINE - 2)] = '+'; }
pos[(MAXLINE - 1)] = '\n'; if (sigs & TIOCM_CD) {
seq_printf(m, "%c%s", sep, "DCD");
return MAXLINE; sep = '|';
}
if (sigs & TIOCM_DSR) {
seq_printf(m, "%c%s", sep, "DSR");
sep = '|';
}
seq_putc(m, '\n');
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -1433,30 +1429,17 @@ static int stl_portinfo(struct stlport *portp, int portnr, char *pos) ...@@ -1433,30 +1429,17 @@ static int stl_portinfo(struct stlport *portp, int portnr, char *pos)
* Port info, read from the /proc file system. * Port info, read from the /proc file system.
*/ */
static int stl_readproc(char *page, char **start, off_t off, int count, int *eof, void *data) static int stl_proc_show(struct seq_file *m, void *v)
{ {
struct stlbrd *brdp; struct stlbrd *brdp;
struct stlpanel *panelp; struct stlpanel *panelp;
struct stlport *portp; struct stlport *portp;
unsigned int brdnr, panelnr, portnr; unsigned int brdnr, panelnr, portnr;
int totalport, curoff, maxoff; int totalport;
char *pos;
pr_debug("stl_readproc(page=%p,start=%p,off=%lx,count=%d,eof=%p,"
"data=%p\n", page, start, off, count, eof, data);
pos = page;
totalport = 0; totalport = 0;
curoff = 0;
seq_printf(m, "%s: version %s\n", stl_drvtitle, stl_drvversion);
if (off == 0) {
pos += sprintf(pos, "%s: version %s", stl_drvtitle,
stl_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
...@@ -1469,46 +1452,37 @@ static int stl_readproc(char *page, char **start, off_t off, int count, int *eof ...@@ -1469,46 +1452,37 @@ static int stl_readproc(char *page, char **start, off_t off, int count, int *eof
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 (panelnr = 0; panelnr < brdp->nrpanels; panelnr++) { for (panelnr = 0; panelnr < brdp->nrpanels; panelnr++) {
panelp = brdp->panels[panelnr]; panelp = brdp->panels[panelnr];
if (panelp == NULL) if (panelp == NULL)
continue; continue;
maxoff = curoff + (panelp->nrports * MAXLINE);
if (off >= maxoff) {
curoff = maxoff;
totalport += panelp->nrports;
continue;
}
for (portnr = 0; portnr < panelp->nrports; portnr++, for (portnr = 0; portnr < panelp->nrports; portnr++,
totalport++) { totalport++) {
portp = panelp->ports[portnr]; portp = panelp->ports[portnr];
if (portp == NULL) if (portp == NULL)
continue; continue;
if (off >= (curoff += MAXLINE)) stl_portinfo(m, portp, totalport);
continue;
if ((pos - page + MAXLINE) > count)
goto stl_readdone;
pos += stl_portinfo(portp, totalport, pos);
} }
} }
} }
return 0;
}
*eof = 1; static int stl_proc_open(struct inode *inode, struct file *file)
{
stl_readdone: return single_open(file, stl_proc_show, NULL);
*start = page;
return pos - page;
} }
static const struct file_operations stl_proc_fops = {
.owner = THIS_MODULE,
.open = stl_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/*****************************************************************************/ /*****************************************************************************/
/* /*
...@@ -2566,9 +2540,9 @@ static const struct tty_operations stl_ops = { ...@@ -2566,9 +2540,9 @@ static const struct tty_operations stl_ops = {
.break_ctl = stl_breakctl, .break_ctl = stl_breakctl,
.wait_until_sent = stl_waituntilsent, .wait_until_sent = stl_waituntilsent,
.send_xchar = stl_sendxchar, .send_xchar = stl_sendxchar,
.read_proc = stl_readproc,
.tiocmget = stl_tiocmget, .tiocmget = stl_tiocmget,
.tiocmset = stl_tiocmset, .tiocmset = stl_tiocmset,
.proc_fops = &stl_proc_fops,
}; };
static const struct tty_port_operations stl_port_ops = { static const struct tty_port_operations stl_port_ops = {
......
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