aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/stallion.c126
1 files changed, 50 insertions, 76 deletions
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index e1e0dd89ac9a..2ad813a801dc 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -32,6 +32,7 @@
32#include <linux/tty.h> 32#include <linux/tty.h>
33#include <linux/tty_flip.h> 33#include <linux/tty_flip.h>
34#include <linux/serial.h> 34#include <linux/serial.h>
35#include <linux/seq_file.h>
35#include <linux/cd1400.h> 36#include <linux/cd1400.h>
36#include <linux/sc26198.h> 37#include <linux/sc26198.h>
37#include <linux/comstats.h> 38#include <linux/comstats.h>
@@ -1379,52 +1380,47 @@ static void stl_sendxchar(struct tty_struct *tty, char ch)
1379 stl_putchar(tty, ch); 1380 stl_putchar(tty, ch);
1380} 1381}
1381 1382
1382/*****************************************************************************/ 1383static void stl_portinfo(struct seq_file *m, struct stlport *portp, int portnr)
1383
1384#define MAXLINE 80
1385
1386/*
1387 * Format info for a specified port. The line is deliberately limited
1388 * to 80 characters. (If it is too long it will be truncated, if too
1389 * short then padded with spaces).
1390 */
1391
1392static int stl_portinfo(struct stlport *portp, int portnr, char *pos)
1393{ 1384{
1394 char *sp; 1385 int sigs;
1395 int sigs, cnt; 1386 char sep;
1396 1387
1397 sp = pos; 1388 seq_printf(m, "%d: uart:%s tx:%d rx:%d",
1398 sp += sprintf(sp, "%d: uart:%s tx:%d rx:%d",
1399 portnr, (portp->hwid == 1) ? "SC26198" : "CD1400", 1389 portnr, (portp->hwid == 1) ? "SC26198" : "CD1400",
1400 (int) portp->stats.txtotal, (int) portp->stats.rxtotal); 1390 (int) portp->stats.txtotal, (int) portp->stats.rxtotal);
1401 1391
1402 if (portp->stats.rxframing) 1392 if (portp->stats.rxframing)
1403 sp += sprintf(sp, " fe:%d", (int) portp->stats.rxframing); 1393 seq_printf(m, " fe:%d", (int) portp->stats.rxframing);
1404 if (portp->stats.rxparity) 1394 if (portp->stats.rxparity)
1405 sp += sprintf(sp, " pe:%d", (int) portp->stats.rxparity); 1395 seq_printf(m, " pe:%d", (int) portp->stats.rxparity);
1406 if (portp->stats.rxbreaks) 1396 if (portp->stats.rxbreaks)
1407 sp += sprintf(sp, " brk:%d", (int) portp->stats.rxbreaks); 1397 seq_printf(m, " brk:%d", (int) portp->stats.rxbreaks);
1408 if (portp->stats.rxoverrun) 1398 if (portp->stats.rxoverrun)
1409 sp += sprintf(sp, " oe:%d", (int) portp->stats.rxoverrun); 1399 seq_printf(m, " oe:%d", (int) portp->stats.rxoverrun);
1410 1400
1411 sigs = stl_getsignals(portp); 1401 sigs = stl_getsignals(portp);
1412 cnt = sprintf(sp, "%s%s%s%s%s ", 1402 sep = ' ';
1413 (sigs & TIOCM_RTS) ? "|RTS" : "", 1403 if (sigs & TIOCM_RTS) {
1414 (sigs & TIOCM_CTS) ? "|CTS" : "", 1404 seq_printf(m, "%c%s", sep, "RTS");
1415 (sigs & TIOCM_DTR) ? "|DTR" : "", 1405 sep = '|';
1416 (sigs & TIOCM_CD) ? "|DCD" : "", 1406 }
1417 (sigs & TIOCM_DSR) ? "|DSR" : ""); 1407 if (sigs & TIOCM_CTS) {
1418 *sp = ' '; 1408 seq_printf(m, "%c%s", sep, "CTS");
1419 sp += cnt; 1409 sep = '|';
1420 1410 }
1421 for (cnt = sp - pos; cnt < (MAXLINE - 1); cnt++) 1411 if (sigs & TIOCM_DTR) {
1422 *sp++ = ' '; 1412 seq_printf(m, "%c%s", sep, "DTR");
1423 if (cnt >= MAXLINE) 1413 sep = '|';
1424 pos[(MAXLINE - 2)] = '+'; 1414 }
1425 pos[(MAXLINE - 1)] = '\n'; 1415 if (sigs & TIOCM_CD) {
1426 1416 seq_printf(m, "%c%s", sep, "DCD");
1427 return MAXLINE; 1417 sep = '|';
1418 }
1419 if (sigs & TIOCM_DSR) {
1420 seq_printf(m, "%c%s", sep, "DSR");
1421 sep = '|';
1422 }
1423 seq_putc(m, '\n');
1428} 1424}
1429 1425
1430/*****************************************************************************/ 1426/*****************************************************************************/
@@ -1433,30 +1429,17 @@ static int stl_portinfo(struct stlport *portp, int portnr, char *pos)
1433 * Port info, read from the /proc file system. 1429 * Port info, read from the /proc file system.
1434 */ 1430 */
1435 1431
1436static int stl_readproc(char *page, char **start, off_t off, int count, int *eof, void *data) 1432static int stl_proc_show(struct seq_file *m, void *v)
1437{ 1433{
1438 struct stlbrd *brdp; 1434 struct stlbrd *brdp;
1439 struct stlpanel *panelp; 1435 struct stlpanel *panelp;
1440 struct stlport *portp; 1436 struct stlport *portp;
1441 unsigned int brdnr, panelnr, portnr; 1437 unsigned int brdnr, panelnr, portnr;
1442 int totalport, curoff, maxoff; 1438 int totalport;
1443 char *pos;
1444 1439
1445 pr_debug("stl_readproc(page=%p,start=%p,off=%lx,count=%d,eof=%p,"
1446 "data=%p\n", page, start, off, count, eof, data);
1447
1448 pos = page;
1449 totalport = 0; 1440 totalport = 0;
1450 curoff = 0; 1441
1451 1442 seq_printf(m, "%s: version %s\n", stl_drvtitle, stl_drvversion);
1452 if (off == 0) {
1453 pos += sprintf(pos, "%s: version %s", stl_drvtitle,
1454 stl_drvversion);
1455 while (pos < (page + MAXLINE - 1))
1456 *pos++ = ' ';
1457 *pos++ = '\n';
1458 }
1459 curoff = MAXLINE;
1460 1443
1461/* 1444/*
1462 * We scan through for each board, panel and port. The offset is 1445 * 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 if (brdp->state == 0) 1452 if (brdp->state == 0)
1470 continue; 1453 continue;
1471 1454
1472 maxoff = curoff + (brdp->nrports * MAXLINE);
1473 if (off >= maxoff) {
1474 curoff = maxoff;
1475 continue;
1476 }
1477
1478 totalport = brdnr * STL_MAXPORTS; 1455 totalport = brdnr * STL_MAXPORTS;
1479 for (panelnr = 0; panelnr < brdp->nrpanels; panelnr++) { 1456 for (panelnr = 0; panelnr < brdp->nrpanels; panelnr++) {
1480 panelp = brdp->panels[panelnr]; 1457 panelp = brdp->panels[panelnr];
1481 if (panelp == NULL) 1458 if (panelp == NULL)
1482 continue; 1459 continue;
1483 1460
1484 maxoff = curoff + (panelp->nrports * MAXLINE);
1485 if (off >= maxoff) {
1486 curoff = maxoff;
1487 totalport += panelp->nrports;
1488 continue;
1489 }
1490
1491 for (portnr = 0; portnr < panelp->nrports; portnr++, 1461 for (portnr = 0; portnr < panelp->nrports; portnr++,
1492 totalport++) { 1462 totalport++) {
1493 portp = panelp->ports[portnr]; 1463 portp = panelp->ports[portnr];
1494 if (portp == NULL) 1464 if (portp == NULL)
1495 continue; 1465 continue;
1496 if (off >= (curoff += MAXLINE)) 1466 stl_portinfo(m, portp, totalport);
1497 continue;
1498 if ((pos - page + MAXLINE) > count)
1499 goto stl_readdone;
1500 pos += stl_portinfo(portp, totalport, pos);
1501 } 1467 }
1502 } 1468 }
1503 } 1469 }
1470 return 0;
1471}
1504 1472
1505 *eof = 1; 1473static int stl_proc_open(struct inode *inode, struct file *file)
1506 1474{
1507stl_readdone: 1475 return single_open(file, stl_proc_show, NULL);
1508 *start = page;
1509 return pos - page;
1510} 1476}
1511 1477
1478static const struct file_operations stl_proc_fops = {
1479 .owner = THIS_MODULE,
1480 .open = stl_proc_open,
1481 .read = seq_read,
1482 .llseek = seq_lseek,
1483 .release = single_release,
1484};
1485
1512/*****************************************************************************/ 1486/*****************************************************************************/
1513 1487
1514/* 1488/*
@@ -2566,9 +2540,9 @@ static const struct tty_operations stl_ops = {
2566 .break_ctl = stl_breakctl, 2540 .break_ctl = stl_breakctl,
2567 .wait_until_sent = stl_waituntilsent, 2541 .wait_until_sent = stl_waituntilsent,
2568 .send_xchar = stl_sendxchar, 2542 .send_xchar = stl_sendxchar,
2569 .read_proc = stl_readproc,
2570 .tiocmget = stl_tiocmget, 2543 .tiocmget = stl_tiocmget,
2571 .tiocmset = stl_tiocmset, 2544 .tiocmset = stl_tiocmset,
2545 .proc_fops = &stl_proc_fops,
2572}; 2546};
2573 2547
2574static const struct tty_port_operations stl_port_ops = { 2548static const struct tty_port_operations stl_port_ops = {