aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/istallion.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2009-03-31 18:19:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-01 11:59:08 -0400
commit5bd6de7dadb8054a558ae4ac29121d8e93493065 (patch)
tree55a900eb507807fa85de4292d2628cdae8bd94f7 /drivers/char/istallion.c
parentcdda7cd92b9c0b8b25c906a1f39c61954432357a (diff)
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>
Diffstat (limited to 'drivers/char/istallion.c')
-rw-r--r--drivers/char/istallion.c121
1 files changed, 52 insertions, 69 deletions
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 5c3dc6b8411c..fff19f7e29d2 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -24,6 +24,7 @@
24#include <linux/tty.h> 24#include <linux/tty.h>
25#include <linux/tty_flip.h> 25#include <linux/tty_flip.h>
26#include <linux/serial.h> 26#include <linux/serial.h>
27#include <linux/seq_file.h>
27#include <linux/cdk.h> 28#include <linux/cdk.h>
28#include <linux/comstats.h> 29#include <linux/comstats.h>
29#include <linux/istallion.h> 30#include <linux/istallion.h>
@@ -613,7 +614,6 @@ static int stli_breakctl(struct tty_struct *tty, int state);
613static void stli_waituntilsent(struct tty_struct *tty, int timeout); 614static void stli_waituntilsent(struct tty_struct *tty, int timeout);
614static void stli_sendxchar(struct tty_struct *tty, char ch); 615static void stli_sendxchar(struct tty_struct *tty, char ch);
615static void stli_hangup(struct tty_struct *tty); 616static void stli_hangup(struct tty_struct *tty);
616static int stli_portinfo(struct stlibrd *brdp, struct stliport *portp, int portnr, char *pos);
617 617
618static int stli_brdinit(struct stlibrd *brdp); 618static int stli_brdinit(struct stlibrd *brdp);
619static int stli_startbrd(struct stlibrd *brdp); 619static int stli_startbrd(struct stlibrd *brdp);
@@ -1893,20 +1893,10 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
1893 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0); 1893 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
1894} 1894}
1895 1895
1896/*****************************************************************************/ 1896static void stli_portinfo(struct seq_file *m, struct stlibrd *brdp, struct stliport *portp, int portnr)
1897
1898#define MAXLINE 80
1899
1900/*
1901 * Format info for a specified port. The line is deliberately limited
1902 * to 80 characters. (If it is too long it will be truncated, if too
1903 * short then padded with spaces).
1904 */
1905
1906static int stli_portinfo(struct stlibrd *brdp, struct stliport *portp, int portnr, char *pos)
1907{ 1897{
1908 char *sp, *uart; 1898 char *uart;
1909 int rc, cnt; 1899 int rc;
1910 1900
1911 rc = stli_portcmdstats(NULL, portp); 1901 rc = stli_portcmdstats(NULL, portp);
1912 1902
@@ -1918,44 +1908,50 @@ static int stli_portinfo(struct stlibrd *brdp, struct stliport *portp, int portn
1918 default:uart = "CD1400"; break; 1908 default:uart = "CD1400"; break;
1919 } 1909 }
1920 } 1910 }
1921 1911 seq_printf(m, "%d: uart:%s ", portnr, uart);
1922 sp = pos;
1923 sp += sprintf(sp, "%d: uart:%s ", portnr, uart);
1924 1912
1925 if ((brdp->state & BST_STARTED) && (rc >= 0)) { 1913 if ((brdp->state & BST_STARTED) && (rc >= 0)) {
1926 sp += sprintf(sp, "tx:%d rx:%d", (int) stli_comstats.txtotal, 1914 char sep;
1915
1916 seq_printf(m, "tx:%d rx:%d", (int) stli_comstats.txtotal,
1927 (int) stli_comstats.rxtotal); 1917 (int) stli_comstats.rxtotal);
1928 1918
1929 if (stli_comstats.rxframing) 1919 if (stli_comstats.rxframing)
1930 sp += sprintf(sp, " fe:%d", 1920 seq_printf(m, " fe:%d",
1931 (int) stli_comstats.rxframing); 1921 (int) stli_comstats.rxframing);
1932 if (stli_comstats.rxparity) 1922 if (stli_comstats.rxparity)
1933 sp += sprintf(sp, " pe:%d", 1923 seq_printf(m, " pe:%d",
1934 (int) stli_comstats.rxparity); 1924 (int) stli_comstats.rxparity);
1935 if (stli_comstats.rxbreaks) 1925 if (stli_comstats.rxbreaks)
1936 sp += sprintf(sp, " brk:%d", 1926 seq_printf(m, " brk:%d",
1937 (int) stli_comstats.rxbreaks); 1927 (int) stli_comstats.rxbreaks);
1938 if (stli_comstats.rxoverrun) 1928 if (stli_comstats.rxoverrun)
1939 sp += sprintf(sp, " oe:%d", 1929 seq_printf(m, " oe:%d",
1940 (int) stli_comstats.rxoverrun); 1930 (int) stli_comstats.rxoverrun);
1941 1931
1942 cnt = sprintf(sp, "%s%s%s%s%s ", 1932 sep = ' ';
1943 (stli_comstats.signals & TIOCM_RTS) ? "|RTS" : "", 1933 if (stli_comstats.signals & TIOCM_RTS) {
1944 (stli_comstats.signals & TIOCM_CTS) ? "|CTS" : "", 1934 seq_printf(m, "%c%s", sep, "RTS");
1945 (stli_comstats.signals & TIOCM_DTR) ? "|DTR" : "", 1935 sep = '|';
1946 (stli_comstats.signals & TIOCM_CD) ? "|DCD" : "", 1936 }
1947 (stli_comstats.signals & TIOCM_DSR) ? "|DSR" : ""); 1937 if (stli_comstats.signals & TIOCM_CTS) {
1948 *sp = ' '; 1938 seq_printf(m, "%c%s", sep, "CTS");
1949 sp += cnt; 1939 sep = '|';
1940 }
1941 if (stli_comstats.signals & TIOCM_DTR) {
1942 seq_printf(m, "%c%s", sep, "DTR");
1943 sep = '|';
1944 }
1945 if (stli_comstats.signals & TIOCM_CD) {
1946 seq_printf(m, "%c%s", sep, "DCD");
1947 sep = '|';
1948 }
1949 if (stli_comstats.signals & TIOCM_DSR) {
1950 seq_printf(m, "%c%s", sep, "DSR");
1951 sep = '|';
1952 }
1950 } 1953 }
1951 1954 seq_putc(m, '\n');
1952 for (cnt = (sp - pos); (cnt < (MAXLINE - 1)); cnt++)
1953 *sp++ = ' ';
1954 if (cnt >= MAXLINE)
1955 pos[(MAXLINE - 2)] = '+';
1956 pos[(MAXLINE - 1)] = '\n';
1957
1958 return(MAXLINE);
1959} 1955}
1960 1956
1961/*****************************************************************************/ 1957/*****************************************************************************/
@@ -1964,26 +1960,15 @@ static int stli_portinfo(struct stlibrd *brdp, struct stliport *portp, int portn
1964 * Port info, read from the /proc file system. 1960 * Port info, read from the /proc file system.
1965 */ 1961 */
1966 1962
1967static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data) 1963static int stli_proc_show(struct seq_file *m, void *v)
1968{ 1964{
1969 struct stlibrd *brdp; 1965 struct stlibrd *brdp;
1970 struct stliport *portp; 1966 struct stliport *portp;
1971 unsigned int brdnr, portnr, totalport; 1967 unsigned int brdnr, portnr, totalport;
1972 int curoff, maxoff;
1973 char *pos;
1974 1968
1975 pos = page;
1976 totalport = 0; 1969 totalport = 0;
1977 curoff = 0; 1970
1978 1971 seq_printf(m, "%s: version %s\n", stli_drvtitle, stli_drvversion);
1979 if (off == 0) {
1980 pos += sprintf(pos, "%s: version %s", stli_drvtitle,
1981 stli_drvversion);
1982 while (pos < (page + MAXLINE - 1))
1983 *pos++ = ' ';
1984 *pos++ = '\n';
1985 }
1986 curoff = MAXLINE;
1987 1972
1988/* 1973/*
1989 * We scan through for each board, panel and port. The offset is 1974 * 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
1996 if (brdp->state == 0) 1981 if (brdp->state == 0)
1997 continue; 1982 continue;
1998 1983
1999 maxoff = curoff + (brdp->nrports * MAXLINE);
2000 if (off >= maxoff) {
2001 curoff = maxoff;
2002 continue;
2003 }
2004
2005 totalport = brdnr * STL_MAXPORTS; 1984 totalport = brdnr * STL_MAXPORTS;
2006 for (portnr = 0; (portnr < brdp->nrports); portnr++, 1985 for (portnr = 0; (portnr < brdp->nrports); portnr++,
2007 totalport++) { 1986 totalport++) {
2008 portp = brdp->ports[portnr]; 1987 portp = brdp->ports[portnr];
2009 if (portp == NULL) 1988 if (portp == NULL)
2010 continue; 1989 continue;
2011 if (off >= (curoff += MAXLINE)) 1990 stli_portinfo(m, brdp, portp, totalport);
2012 continue;
2013 if ((pos - page + MAXLINE) > count)
2014 goto stli_readdone;
2015 pos += stli_portinfo(brdp, portp, totalport, pos);
2016 } 1991 }
2017 } 1992 }
1993 return 0;
1994}
2018 1995
2019 *eof = 1; 1996static int stli_proc_open(struct inode *inode, struct file *file)
2020 1997{
2021stli_readdone: 1998 return single_open(file, stli_proc_show, NULL);
2022 *start = page;
2023 return(pos - page);
2024} 1999}
2025 2000
2001static const struct file_operations stli_proc_fops = {
2002 .owner = THIS_MODULE,
2003 .open = stli_proc_open,
2004 .read = seq_read,
2005 .llseek = seq_lseek,
2006 .release = single_release,
2007};
2008
2026/*****************************************************************************/ 2009/*****************************************************************************/
2027 2010
2028/* 2011/*
@@ -4427,9 +4410,9 @@ static const struct tty_operations stli_ops = {
4427 .break_ctl = stli_breakctl, 4410 .break_ctl = stli_breakctl,
4428 .wait_until_sent = stli_waituntilsent, 4411 .wait_until_sent = stli_waituntilsent,
4429 .send_xchar = stli_sendxchar, 4412 .send_xchar = stli_sendxchar,
4430 .read_proc = stli_readproc,
4431 .tiocmget = stli_tiocmget, 4413 .tiocmget = stli_tiocmget,
4432 .tiocmset = stli_tiocmset, 4414 .tiocmset = stli_tiocmset,
4415 .proc_fops = &stli_proc_fops,
4433}; 4416};
4434 4417
4435static const struct tty_port_operations stli_port_ops = { 4418static const struct tty_port_operations stli_port_ops = {