Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alexey Dobriyan and committed by
Linus Torvalds
5bd6de7d cdda7cd9

+52 -69
+52 -69
drivers/char/istallion.c
··· 24 24 #include <linux/tty.h> 25 25 #include <linux/tty_flip.h> 26 26 #include <linux/serial.h> 27 + #include <linux/seq_file.h> 27 28 #include <linux/cdk.h> 28 29 #include <linux/comstats.h> 29 30 #include <linux/istallion.h> ··· 614 613 static void stli_waituntilsent(struct tty_struct *tty, int timeout); 615 614 static void stli_sendxchar(struct tty_struct *tty, char ch); 616 615 static void stli_hangup(struct tty_struct *tty); 617 - static int stli_portinfo(struct stlibrd *brdp, struct stliport *portp, int portnr, char *pos); 618 616 619 617 static int stli_brdinit(struct stlibrd *brdp); 620 618 static int stli_startbrd(struct stlibrd *brdp); ··· 1893 1893 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0); 1894 1894 } 1895 1895 1896 - /*****************************************************************************/ 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 - 1906 - static int stli_portinfo(struct stlibrd *brdp, struct stliport *portp, int portnr, char *pos) 1896 + static void stli_portinfo(struct seq_file *m, struct stlibrd *brdp, struct stliport *portp, int portnr) 1907 1897 { 1908 - char *sp, *uart; 1909 - int rc, cnt; 1898 + char *uart; 1899 + int rc; 1910 1900 1911 1901 rc = stli_portcmdstats(NULL, portp); 1912 1902 ··· 1908 1918 default:uart = "CD1400"; break; 1909 1919 } 1910 1920 } 1911 - 1912 - sp = pos; 1913 - sp += sprintf(sp, "%d: uart:%s ", portnr, uart); 1921 + seq_printf(m, "%d: uart:%s ", portnr, uart); 1914 1922 1915 1923 if ((brdp->state & BST_STARTED) && (rc >= 0)) { 1916 - sp += sprintf(sp, "tx:%d rx:%d", (int) stli_comstats.txtotal, 1924 + char sep; 1925 + 1926 + seq_printf(m, "tx:%d rx:%d", (int) stli_comstats.txtotal, 1917 1927 (int) stli_comstats.rxtotal); 1918 1928 1919 1929 if (stli_comstats.rxframing) 1920 - sp += sprintf(sp, " fe:%d", 1930 + seq_printf(m, " fe:%d", 1921 1931 (int) stli_comstats.rxframing); 1922 1932 if (stli_comstats.rxparity) 1923 - sp += sprintf(sp, " pe:%d", 1933 + seq_printf(m, " pe:%d", 1924 1934 (int) stli_comstats.rxparity); 1925 1935 if (stli_comstats.rxbreaks) 1926 - sp += sprintf(sp, " brk:%d", 1936 + seq_printf(m, " brk:%d", 1927 1937 (int) stli_comstats.rxbreaks); 1928 1938 if (stli_comstats.rxoverrun) 1929 - sp += sprintf(sp, " oe:%d", 1939 + seq_printf(m, " oe:%d", 1930 1940 (int) stli_comstats.rxoverrun); 1931 1941 1932 - cnt = sprintf(sp, "%s%s%s%s%s ", 1933 - (stli_comstats.signals & TIOCM_RTS) ? "|RTS" : "", 1934 - (stli_comstats.signals & TIOCM_CTS) ? "|CTS" : "", 1935 - (stli_comstats.signals & TIOCM_DTR) ? "|DTR" : "", 1936 - (stli_comstats.signals & TIOCM_CD) ? "|DCD" : "", 1937 - (stli_comstats.signals & TIOCM_DSR) ? "|DSR" : ""); 1938 - *sp = ' '; 1939 - sp += cnt; 1942 + sep = ' '; 1943 + if (stli_comstats.signals & TIOCM_RTS) { 1944 + seq_printf(m, "%c%s", sep, "RTS"); 1945 + sep = '|'; 1946 + } 1947 + if (stli_comstats.signals & TIOCM_CTS) { 1948 + seq_printf(m, "%c%s", sep, "CTS"); 1949 + sep = '|'; 1950 + } 1951 + if (stli_comstats.signals & TIOCM_DTR) { 1952 + seq_printf(m, "%c%s", sep, "DTR"); 1953 + sep = '|'; 1954 + } 1955 + if (stli_comstats.signals & TIOCM_CD) { 1956 + seq_printf(m, "%c%s", sep, "DCD"); 1957 + sep = '|'; 1958 + } 1959 + if (stli_comstats.signals & TIOCM_DSR) { 1960 + seq_printf(m, "%c%s", sep, "DSR"); 1961 + sep = '|'; 1962 + } 1940 1963 } 1941 - 1942 - for (cnt = (sp - pos); (cnt < (MAXLINE - 1)); cnt++) 1943 - *sp++ = ' '; 1944 - if (cnt >= MAXLINE) 1945 - pos[(MAXLINE - 2)] = '+'; 1946 - pos[(MAXLINE - 1)] = '\n'; 1947 - 1948 - return(MAXLINE); 1964 + seq_putc(m, '\n'); 1949 1965 } 1950 1966 1951 1967 /*****************************************************************************/ ··· 1960 1964 * Port info, read from the /proc file system. 1961 1965 */ 1962 1966 1963 - static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data) 1967 + static int stli_proc_show(struct seq_file *m, void *v) 1964 1968 { 1965 1969 struct stlibrd *brdp; 1966 1970 struct stliport *portp; 1967 1971 unsigned int brdnr, portnr, totalport; 1968 - int curoff, maxoff; 1969 - char *pos; 1970 1972 1971 - pos = page; 1972 1973 totalport = 0; 1973 - curoff = 0; 1974 1974 1975 - if (off == 0) { 1976 - pos += sprintf(pos, "%s: version %s", stli_drvtitle, 1977 - stli_drvversion); 1978 - while (pos < (page + MAXLINE - 1)) 1979 - *pos++ = ' '; 1980 - *pos++ = '\n'; 1981 - } 1982 - curoff = MAXLINE; 1975 + seq_printf(m, "%s: version %s\n", stli_drvtitle, stli_drvversion); 1983 1976 1984 1977 /* 1985 1978 * We scan through for each board, panel and port. The offset is ··· 1981 1996 if (brdp->state == 0) 1982 1997 continue; 1983 1998 1984 - maxoff = curoff + (brdp->nrports * MAXLINE); 1985 - if (off >= maxoff) { 1986 - curoff = maxoff; 1987 - continue; 1988 - } 1989 - 1990 1999 totalport = brdnr * STL_MAXPORTS; 1991 2000 for (portnr = 0; (portnr < brdp->nrports); portnr++, 1992 2001 totalport++) { 1993 2002 portp = brdp->ports[portnr]; 1994 2003 if (portp == NULL) 1995 2004 continue; 1996 - if (off >= (curoff += MAXLINE)) 1997 - continue; 1998 - if ((pos - page + MAXLINE) > count) 1999 - goto stli_readdone; 2000 - pos += stli_portinfo(brdp, portp, totalport, pos); 2005 + stli_portinfo(m, brdp, portp, totalport); 2001 2006 } 2002 2007 } 2003 - 2004 - *eof = 1; 2005 - 2006 - stli_readdone: 2007 - *start = page; 2008 - return(pos - page); 2008 + return 0; 2009 2009 } 2010 + 2011 + static int stli_proc_open(struct inode *inode, struct file *file) 2012 + { 2013 + return single_open(file, stli_proc_show, NULL); 2014 + } 2015 + 2016 + static const struct file_operations stli_proc_fops = { 2017 + .owner = THIS_MODULE, 2018 + .open = stli_proc_open, 2019 + .read = seq_read, 2020 + .llseek = seq_lseek, 2021 + .release = single_release, 2022 + }; 2010 2023 2011 2024 /*****************************************************************************/ 2012 2025 ··· 4410 4427 .break_ctl = stli_breakctl, 4411 4428 .wait_until_sent = stli_waituntilsent, 4412 4429 .send_xchar = stli_sendxchar, 4413 - .read_proc = stli_readproc, 4414 4430 .tiocmget = stli_tiocmget, 4415 4431 .tiocmset = stli_tiocmset, 4432 + .proc_fops = &stli_proc_fops, 4416 4433 }; 4417 4434 4418 4435 static const struct tty_port_operations stli_port_ops = {