Commit 87687144b4fce2ad083e689eec8b219054c292ae
Committed by
Linus Torvalds
1 parent
5bd6de7dad
Exists in
master
and in
7 other branches
proc tty: switch synclink_cs 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 34 additions and 39 deletions Side-by-side Diff
drivers/char/pcmcia/synclink_cs.c
... | ... | @@ -51,6 +51,7 @@ |
51 | 51 | #include <linux/ptrace.h> |
52 | 52 | #include <linux/ioport.h> |
53 | 53 | #include <linux/mm.h> |
54 | +#include <linux/seq_file.h> | |
54 | 55 | #include <linux/slab.h> |
55 | 56 | #include <linux/netdevice.h> |
56 | 57 | #include <linux/vmalloc.h> |
57 | 58 | |
58 | 59 | |
... | ... | @@ -2619,13 +2620,12 @@ |
2619 | 2620 | * /proc fs routines.... |
2620 | 2621 | */ |
2621 | 2622 | |
2622 | -static inline int line_info(char *buf, MGSLPC_INFO *info) | |
2623 | +static inline void line_info(struct seq_file *m, MGSLPC_INFO *info) | |
2623 | 2624 | { |
2624 | 2625 | char stat_buf[30]; |
2625 | - int ret; | |
2626 | 2626 | unsigned long flags; |
2627 | 2627 | |
2628 | - ret = sprintf(buf, "%s:io:%04X irq:%d", | |
2628 | + seq_printf(m, "%s:io:%04X irq:%d", | |
2629 | 2629 | info->device_name, info->io_base, info->irq_level); |
2630 | 2630 | |
2631 | 2631 | /* output current serial signal states */ |
2632 | 2632 | |
2633 | 2633 | |
2634 | 2634 | |
2635 | 2635 | |
2636 | 2636 | |
2637 | 2637 | |
2638 | 2638 | |
2639 | 2639 | |
2640 | 2640 | |
2641 | 2641 | |
2642 | 2642 | |
2643 | 2643 | |
2644 | 2644 | |
2645 | 2645 | |
2646 | 2646 | |
2647 | 2647 | |
2648 | 2648 | |
2649 | 2649 | |
2650 | 2650 | |
2651 | 2651 | |
2652 | 2652 | |
... | ... | @@ -2649,75 +2649,70 @@ |
2649 | 2649 | strcat(stat_buf, "|RI"); |
2650 | 2650 | |
2651 | 2651 | if (info->params.mode == MGSL_MODE_HDLC) { |
2652 | - ret += sprintf(buf+ret, " HDLC txok:%d rxok:%d", | |
2652 | + seq_printf(m, " HDLC txok:%d rxok:%d", | |
2653 | 2653 | info->icount.txok, info->icount.rxok); |
2654 | 2654 | if (info->icount.txunder) |
2655 | - ret += sprintf(buf+ret, " txunder:%d", info->icount.txunder); | |
2655 | + seq_printf(m, " txunder:%d", info->icount.txunder); | |
2656 | 2656 | if (info->icount.txabort) |
2657 | - ret += sprintf(buf+ret, " txabort:%d", info->icount.txabort); | |
2657 | + seq_printf(m, " txabort:%d", info->icount.txabort); | |
2658 | 2658 | if (info->icount.rxshort) |
2659 | - ret += sprintf(buf+ret, " rxshort:%d", info->icount.rxshort); | |
2659 | + seq_printf(m, " rxshort:%d", info->icount.rxshort); | |
2660 | 2660 | if (info->icount.rxlong) |
2661 | - ret += sprintf(buf+ret, " rxlong:%d", info->icount.rxlong); | |
2661 | + seq_printf(m, " rxlong:%d", info->icount.rxlong); | |
2662 | 2662 | if (info->icount.rxover) |
2663 | - ret += sprintf(buf+ret, " rxover:%d", info->icount.rxover); | |
2663 | + seq_printf(m, " rxover:%d", info->icount.rxover); | |
2664 | 2664 | if (info->icount.rxcrc) |
2665 | - ret += sprintf(buf+ret, " rxcrc:%d", info->icount.rxcrc); | |
2665 | + seq_printf(m, " rxcrc:%d", info->icount.rxcrc); | |
2666 | 2666 | } else { |
2667 | - ret += sprintf(buf+ret, " ASYNC tx:%d rx:%d", | |
2667 | + seq_printf(m, " ASYNC tx:%d rx:%d", | |
2668 | 2668 | info->icount.tx, info->icount.rx); |
2669 | 2669 | if (info->icount.frame) |
2670 | - ret += sprintf(buf+ret, " fe:%d", info->icount.frame); | |
2670 | + seq_printf(m, " fe:%d", info->icount.frame); | |
2671 | 2671 | if (info->icount.parity) |
2672 | - ret += sprintf(buf+ret, " pe:%d", info->icount.parity); | |
2672 | + seq_printf(m, " pe:%d", info->icount.parity); | |
2673 | 2673 | if (info->icount.brk) |
2674 | - ret += sprintf(buf+ret, " brk:%d", info->icount.brk); | |
2674 | + seq_printf(m, " brk:%d", info->icount.brk); | |
2675 | 2675 | if (info->icount.overrun) |
2676 | - ret += sprintf(buf+ret, " oe:%d", info->icount.overrun); | |
2676 | + seq_printf(m, " oe:%d", info->icount.overrun); | |
2677 | 2677 | } |
2678 | 2678 | |
2679 | 2679 | /* Append serial signal status to end */ |
2680 | - ret += sprintf(buf+ret, " %s\n", stat_buf+1); | |
2680 | + seq_printf(m, " %s\n", stat_buf+1); | |
2681 | 2681 | |
2682 | - ret += sprintf(buf+ret, "txactive=%d bh_req=%d bh_run=%d pending_bh=%x\n", | |
2682 | + seq_printf(m, "txactive=%d bh_req=%d bh_run=%d pending_bh=%x\n", | |
2683 | 2683 | info->tx_active,info->bh_requested,info->bh_running, |
2684 | 2684 | info->pending_bh); |
2685 | - | |
2686 | - return ret; | |
2687 | 2685 | } |
2688 | 2686 | |
2689 | 2687 | /* Called to print information about devices |
2690 | 2688 | */ |
2691 | -static int mgslpc_read_proc(char *page, char **start, off_t off, int count, | |
2692 | - int *eof, void *data) | |
2689 | +static int mgslpc_proc_show(struct seq_file *m, void *v) | |
2693 | 2690 | { |
2694 | - int len = 0, l; | |
2695 | - off_t begin = 0; | |
2696 | 2691 | MGSLPC_INFO *info; |
2697 | 2692 | |
2698 | - len += sprintf(page, "synclink driver:%s\n", driver_version); | |
2693 | + seq_printf(m, "synclink driver:%s\n", driver_version); | |
2699 | 2694 | |
2700 | 2695 | info = mgslpc_device_list; |
2701 | 2696 | while( info ) { |
2702 | - l = line_info(page + len, info); | |
2703 | - len += l; | |
2704 | - if (len+begin > off+count) | |
2705 | - goto done; | |
2706 | - if (len+begin < off) { | |
2707 | - begin += len; | |
2708 | - len = 0; | |
2709 | - } | |
2697 | + line_info(m, info); | |
2710 | 2698 | info = info->next_device; |
2711 | 2699 | } |
2700 | + return 0; | |
2701 | +} | |
2712 | 2702 | |
2713 | - *eof = 1; | |
2714 | -done: | |
2715 | - if (off >= len+begin) | |
2716 | - return 0; | |
2717 | - *start = page + (off-begin); | |
2718 | - return ((count < begin+len-off) ? count : begin+len-off); | |
2703 | +static int mgslpc_proc_open(struct inode *inode, struct file *file) | |
2704 | +{ | |
2705 | + return single_open(file, mgslpc_proc_show, NULL); | |
2719 | 2706 | } |
2720 | 2707 | |
2708 | +static const struct file_operations mgslpc_proc_fops = { | |
2709 | + .owner = THIS_MODULE, | |
2710 | + .open = mgslpc_proc_open, | |
2711 | + .read = seq_read, | |
2712 | + .llseek = seq_lseek, | |
2713 | + .release = single_release, | |
2714 | +}; | |
2715 | + | |
2721 | 2716 | static int rx_alloc_buffers(MGSLPC_INFO *info) |
2722 | 2717 | { |
2723 | 2718 | /* each buffer has header and data */ |
2724 | 2719 | |
... | ... | @@ -2861,13 +2856,13 @@ |
2861 | 2856 | .send_xchar = mgslpc_send_xchar, |
2862 | 2857 | .break_ctl = mgslpc_break, |
2863 | 2858 | .wait_until_sent = mgslpc_wait_until_sent, |
2864 | - .read_proc = mgslpc_read_proc, | |
2865 | 2859 | .set_termios = mgslpc_set_termios, |
2866 | 2860 | .stop = tx_pause, |
2867 | 2861 | .start = tx_release, |
2868 | 2862 | .hangup = mgslpc_hangup, |
2869 | 2863 | .tiocmget = tiocmget, |
2870 | 2864 | .tiocmset = tiocmset, |
2865 | + .proc_fops = &mgslpc_proc_fops, | |
2871 | 2866 | }; |
2872 | 2867 | |
2873 | 2868 | static void synclink_cs_cleanup(void) |