aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2009-03-31 18:19:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-01 11:59:10 -0400
commitd594027d62808f6649b273544ab8c19ed5b98fd1 (patch)
treea5e58881b75abcd29a93b2b10299e9937a1833e7 /drivers/char
parent3d3041768296c4993c0aba686bf0775faab5236a (diff)
proc tty: switch amiserial 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')
-rw-r--r--drivers/char/amiserial.c62
1 files changed, 28 insertions, 34 deletions
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index a58869ea8513..fd3ebd1be570 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -79,6 +79,7 @@ static char *serial_version = "4.30";
79#include <linux/ptrace.h> 79#include <linux/ptrace.h>
80#include <linux/ioport.h> 80#include <linux/ioport.h>
81#include <linux/mm.h> 81#include <linux/mm.h>
82#include <linux/seq_file.h>
82#include <linux/slab.h> 83#include <linux/slab.h>
83#include <linux/init.h> 84#include <linux/init.h>
84#include <linux/bitops.h> 85#include <linux/bitops.h>
@@ -1825,14 +1826,13 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
1825 * /proc fs routines.... 1826 * /proc fs routines....
1826 */ 1827 */
1827 1828
1828static inline int line_info(char *buf, struct serial_state *state) 1829static inline void line_info(struct seq_file *m, struct serial_state *state)
1829{ 1830{
1830 struct async_struct *info = state->info, scr_info; 1831 struct async_struct *info = state->info, scr_info;
1831 char stat_buf[30], control, status; 1832 char stat_buf[30], control, status;
1832 int ret;
1833 unsigned long flags; 1833 unsigned long flags;
1834 1834
1835 ret = sprintf(buf, "%d: uart:amiga_builtin",state->line); 1835 seq_printf(m, "%d: uart:amiga_builtin",state->line);
1836 1836
1837 /* 1837 /*
1838 * Figure out the current RS-232 lines 1838 * Figure out the current RS-232 lines
@@ -1864,55 +1864,49 @@ static inline int line_info(char *buf, struct serial_state *state)
1864 strcat(stat_buf, "|CD"); 1864 strcat(stat_buf, "|CD");
1865 1865
1866 if (info->quot) { 1866 if (info->quot) {
1867 ret += sprintf(buf+ret, " baud:%d", 1867 seq_printf(m, " baud:%d", state->baud_base / info->quot);
1868 state->baud_base / info->quot);
1869 } 1868 }
1870 1869
1871 ret += sprintf(buf+ret, " tx:%d rx:%d", 1870 seq_printf(m, " tx:%d rx:%d", state->icount.tx, state->icount.rx);
1872 state->icount.tx, state->icount.rx);
1873 1871
1874 if (state->icount.frame) 1872 if (state->icount.frame)
1875 ret += sprintf(buf+ret, " fe:%d", state->icount.frame); 1873 seq_printf(m, " fe:%d", state->icount.frame);
1876 1874
1877 if (state->icount.parity) 1875 if (state->icount.parity)
1878 ret += sprintf(buf+ret, " pe:%d", state->icount.parity); 1876 seq_printf(m, " pe:%d", state->icount.parity);
1879 1877
1880 if (state->icount.brk) 1878 if (state->icount.brk)
1881 ret += sprintf(buf+ret, " brk:%d", state->icount.brk); 1879 seq_printf(m, " brk:%d", state->icount.brk);
1882 1880
1883 if (state->icount.overrun) 1881 if (state->icount.overrun)
1884 ret += sprintf(buf+ret, " oe:%d", state->icount.overrun); 1882 seq_printf(m, " oe:%d", state->icount.overrun);
1885 1883
1886 /* 1884 /*
1887 * Last thing is the RS-232 status lines 1885 * Last thing is the RS-232 status lines
1888 */ 1886 */
1889 ret += sprintf(buf+ret, " %s\n", stat_buf+1); 1887 seq_printf(m, " %s\n", stat_buf+1);
1890 return ret;
1891} 1888}
1892 1889
1893static int rs_read_proc(char *page, char **start, off_t off, int count, 1890static int rs_proc_show(struct seq_file *m, void *v)
1894 int *eof, void *data)
1895{ 1891{
1896 int len = 0, l; 1892 seq_printf(m, "serinfo:1.0 driver:%s\n", serial_version);
1897 off_t begin = 0; 1893 line_info(m, &rs_table[0]);
1898 1894 return 0;
1899 len += sprintf(page, "serinfo:1.0 driver:%s\n", serial_version);
1900 l = line_info(page + len, &rs_table[0]);
1901 len += l;
1902 if (len+begin > off+count)
1903 goto done;
1904 if (len+begin < off) {
1905 begin += len;
1906 len = 0;
1907 }
1908 *eof = 1;
1909done:
1910 if (off >= len+begin)
1911 return 0;
1912 *start = page + (off-begin);
1913 return ((count < begin+len-off) ? count : begin+len-off);
1914} 1895}
1915 1896
1897static int rs_proc_open(struct inode *inode, struct file *file)
1898{
1899 return single_open(file, rs_proc_show, NULL);
1900}
1901
1902static const struct file_operations rs_proc_fops = {
1903 .owner = THIS_MODULE,
1904 .open = rs_proc_open,
1905 .read = seq_read,
1906 .llseek = seq_lseek,
1907 .release = single_release,
1908};
1909
1916/* 1910/*
1917 * --------------------------------------------------------------------- 1911 * ---------------------------------------------------------------------
1918 * rs_init() and friends 1912 * rs_init() and friends
@@ -1951,9 +1945,9 @@ static const struct tty_operations serial_ops = {
1951 .break_ctl = rs_break, 1945 .break_ctl = rs_break,
1952 .send_xchar = rs_send_xchar, 1946 .send_xchar = rs_send_xchar,
1953 .wait_until_sent = rs_wait_until_sent, 1947 .wait_until_sent = rs_wait_until_sent,
1954 .read_proc = rs_read_proc,
1955 .tiocmget = rs_tiocmget, 1948 .tiocmget = rs_tiocmget,
1956 .tiocmset = rs_tiocmset, 1949 .tiocmset = rs_tiocmset,
1950 .proc_fops = &rs_proc_fops,
1957}; 1951};
1958 1952
1959/* 1953/*