Commit 201a50ba6627dd00aa7b7673a5c454ca387095fb

Authored by Alexey Dobriyan
Committed by Linus Torvalds
1 parent e6c8dd8a5c

proc tty: switch sdio_uart 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>

Showing 1 changed file with 30 additions and 32 deletions Side-by-side Diff

drivers/mmc/card/sdio_uart.c
... ... @@ -30,6 +30,7 @@
30 30 #include <linux/init.h>
31 31 #include <linux/kernel.h>
32 32 #include <linux/mutex.h>
  33 +#include <linux/seq_file.h>
33 34 #include <linux/serial_reg.h>
34 35 #include <linux/circ_buf.h>
35 36 #include <linux/gfp.h>
36 37  
37 38  
38 39  
39 40  
40 41  
41 42  
42 43  
43 44  
44 45  
45 46  
46 47  
47 48  
48 49  
49 50  
50 51  
51 52  
52 53  
53 54  
54 55  
... ... @@ -933,67 +934,64 @@
933 934 return result;
934 935 }
935 936  
936   -static int sdio_uart_read_proc(char *page, char **start, off_t off,
937   - int count, int *eof, void *data)
  937 +static int sdio_uart_proc_show(struct seq_file *m, void *v)
938 938 {
939   - int i, len = 0;
940   - off_t begin = 0;
  939 + int i;
941 940  
942   - len += sprintf(page, "serinfo:1.0 driver%s%s revision:%s\n",
  941 + seq_printf(m, "serinfo:1.0 driver%s%s revision:%s\n",
943 942 "", "", "");
944   - for (i = 0; i < UART_NR && len < PAGE_SIZE - 96; i++) {
  943 + for (i = 0; i < UART_NR; i++) {
945 944 struct sdio_uart_port *port = sdio_uart_port_get(i);
946 945 if (port) {
947   - len += sprintf(page+len, "%d: uart:SDIO", i);
  946 + seq_printf(m, "%d: uart:SDIO", i);
948 947 if(capable(CAP_SYS_ADMIN)) {
949   - len += sprintf(page + len, " tx:%d rx:%d",
  948 + seq_printf(m, " tx:%d rx:%d",
950 949 port->icount.tx, port->icount.rx);
951 950 if (port->icount.frame)
952   - len += sprintf(page + len, " fe:%d",
  951 + seq_printf(m, " fe:%d",
953 952 port->icount.frame);
954 953 if (port->icount.parity)
955   - len += sprintf(page + len, " pe:%d",
  954 + seq_printf(m, " pe:%d",
956 955 port->icount.parity);
957 956 if (port->icount.brk)
958   - len += sprintf(page + len, " brk:%d",
  957 + seq_printf(m, " brk:%d",
959 958 port->icount.brk);
960 959 if (port->icount.overrun)
961   - len += sprintf(page + len, " oe:%d",
  960 + seq_printf(m, " oe:%d",
962 961 port->icount.overrun);
963 962 if (port->icount.cts)
964   - len += sprintf(page + len, " cts:%d",
  963 + seq_printf(m, " cts:%d",
965 964 port->icount.cts);
966 965 if (port->icount.dsr)
967   - len += sprintf(page + len, " dsr:%d",
  966 + seq_printf(m, " dsr:%d",
968 967 port->icount.dsr);
969 968 if (port->icount.rng)
970   - len += sprintf(page + len, " rng:%d",
  969 + seq_printf(m, " rng:%d",
971 970 port->icount.rng);
972 971 if (port->icount.dcd)
973   - len += sprintf(page + len, " dcd:%d",
  972 + seq_printf(m, " dcd:%d",
974 973 port->icount.dcd);
975 974 }
976   - strcat(page, "\n");
977   - len++;
978 975 sdio_uart_port_put(port);
  976 + seq_putc(m, '\n');
979 977 }
980   -
981   - if (len + begin > off + count)
982   - goto done;
983   - if (len + begin < off) {
984   - begin += len;
985   - len = 0;
986   - }
987 978 }
988   - *eof = 1;
  979 + return 0;
  980 +}
989 981  
990   -done:
991   - if (off >= len + begin)
992   - return 0;
993   - *start = page + (off - begin);
994   - return (count < begin + len - off) ? count : (begin + len - off);
  982 +static int sdio_uart_proc_open(struct inode *inode, struct file *file)
  983 +{
  984 + return single_open(file, sdio_uart_proc_show, NULL);
995 985 }
996 986  
  987 +static const struct file_operations sdio_uart_proc_fops = {
  988 + .owner = THIS_MODULE,
  989 + .open = sdio_uart_proc_open,
  990 + .read = seq_read,
  991 + .llseek = seq_lseek,
  992 + .release = single_release,
  993 +};
  994 +
997 995 static const struct tty_operations sdio_uart_ops = {
998 996 .open = sdio_uart_open,
999 997 .close = sdio_uart_close,
... ... @@ -1007,7 +1005,7 @@
1007 1005 .break_ctl = sdio_uart_break_ctl,
1008 1006 .tiocmget = sdio_uart_tiocmget,
1009 1007 .tiocmset = sdio_uart_tiocmset,
1010   - .read_proc = sdio_uart_read_proc,
  1008 + .proc_fops = &sdio_uart_proc_fops,
1011 1009 };
1012 1010  
1013 1011 static struct tty_driver *sdio_uart_tty_driver;