aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2009-03-31 18:19:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-01 11:59:08 -0400
commit444697d61b6d5ae43b317d259db7c362c9d3756a (patch)
tree50639bb00c92ff1eba0e33d076a836ad77456ae5
parentae149b6bec64a09373ba20fce75f8aa6b14b78fd (diff)
proc tty: switch cyclades to ->proc_fops
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Acked-by: 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>
-rw-r--r--drivers/char/cyclades.c54
1 files changed, 20 insertions, 34 deletions
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 6a59f72a9c21..272db0e2b491 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -657,6 +657,7 @@
657 657
658#include <linux/stat.h> 658#include <linux/stat.h>
659#include <linux/proc_fs.h> 659#include <linux/proc_fs.h>
660#include <linux/seq_file.h>
660 661
661static void cy_throttle(struct tty_struct *tty); 662static void cy_throttle(struct tty_struct *tty);
662static void cy_send_xchar(struct tty_struct *tty, char ch); 663static void cy_send_xchar(struct tty_struct *tty, char ch);
@@ -868,8 +869,6 @@ static int cyz_issue_cmd(struct cyclades_card *, __u32, __u8, __u32);
868static unsigned detect_isa_irq(void __iomem *); 869static unsigned detect_isa_irq(void __iomem *);
869#endif /* CONFIG_ISA */ 870#endif /* CONFIG_ISA */
870 871
871static int cyclades_get_proc_info(char *, char **, off_t, int, int *, void *);
872
873#ifndef CONFIG_CYZ_INTR 872#ifndef CONFIG_CYZ_INTR
874static void cyz_poll(unsigned long); 873static void cyz_poll(unsigned long);
875 874
@@ -5216,31 +5215,22 @@ static struct pci_driver cy_pci_driver = {
5216}; 5215};
5217#endif 5216#endif
5218 5217
5219static int 5218static int cyclades_proc_show(struct seq_file *m, void *v)
5220cyclades_get_proc_info(char *buf, char **start, off_t offset, int length,
5221 int *eof, void *data)
5222{ 5219{
5223 struct cyclades_port *info; 5220 struct cyclades_port *info;
5224 unsigned int i, j; 5221 unsigned int i, j;
5225 int len = 0;
5226 off_t begin = 0;
5227 off_t pos = 0;
5228 int size;
5229 __u32 cur_jifs = jiffies; 5222 __u32 cur_jifs = jiffies;
5230 5223
5231 size = sprintf(buf, "Dev TimeOpen BytesOut IdleOut BytesIn " 5224 seq_puts(m, "Dev TimeOpen BytesOut IdleOut BytesIn "
5232 "IdleIn Overruns Ldisc\n"); 5225 "IdleIn Overruns Ldisc\n");
5233 5226
5234 pos += size;
5235 len += size;
5236
5237 /* Output one line for each known port */ 5227 /* Output one line for each known port */
5238 for (i = 0; i < NR_CARDS; i++) 5228 for (i = 0; i < NR_CARDS; i++)
5239 for (j = 0; j < cy_card[i].nports; j++) { 5229 for (j = 0; j < cy_card[i].nports; j++) {
5240 info = &cy_card[i].ports[j]; 5230 info = &cy_card[i].ports[j];
5241 5231
5242 if (info->port.count) 5232 if (info->port.count)
5243 size = sprintf(buf + len, "%3d %8lu %10lu %8lu " 5233 seq_printf(m, "%3d %8lu %10lu %8lu "
5244 "%10lu %8lu %9lu %6ld\n", info->line, 5234 "%10lu %8lu %9lu %6ld\n", info->line,
5245 (cur_jifs - info->idle_stats.in_use) / 5235 (cur_jifs - info->idle_stats.in_use) /
5246 HZ, info->idle_stats.xmit_bytes, 5236 HZ, info->idle_stats.xmit_bytes,
@@ -5251,30 +5241,26 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length,
5251 /* FIXME: double check locking */ 5241 /* FIXME: double check locking */
5252 (long)info->port.tty->ldisc.ops->num); 5242 (long)info->port.tty->ldisc.ops->num);
5253 else 5243 else
5254 size = sprintf(buf + len, "%3d %8lu %10lu %8lu " 5244 seq_printf(m, "%3d %8lu %10lu %8lu "
5255 "%10lu %8lu %9lu %6ld\n", 5245 "%10lu %8lu %9lu %6ld\n",
5256 info->line, 0L, 0L, 0L, 0L, 0L, 0L, 0L); 5246 info->line, 0L, 0L, 0L, 0L, 0L, 0L, 0L);
5257 len += size;
5258 pos = begin + len;
5259
5260 if (pos < offset) {
5261 len = 0;
5262 begin = pos;
5263 }
5264 if (pos > offset + length)
5265 goto done;
5266 } 5247 }
5267 *eof = 1; 5248 return 0;
5268done: 5249}
5269 *start = buf + (offset - begin); /* Start of wanted data */ 5250
5270 len -= (offset - begin); /* Start slop */ 5251static int cyclades_proc_open(struct inode *inode, struct file *file)
5271 if (len > length) 5252{
5272 len = length; /* Ending slop */ 5253 return single_open(file, cyclades_proc_show, NULL);
5273 if (len < 0)
5274 len = 0;
5275 return len;
5276} 5254}
5277 5255
5256static const struct file_operations cyclades_proc_fops = {
5257 .owner = THIS_MODULE,
5258 .open = cyclades_proc_open,
5259 .read = seq_read,
5260 .llseek = seq_lseek,
5261 .release = single_release,
5262};
5263
5278/* The serial driver boot-time initialization code! 5264/* The serial driver boot-time initialization code!
5279 Hardware I/O ports are mapped to character special devices on a 5265 Hardware I/O ports are mapped to character special devices on a
5280 first found, first allocated manner. That is, this code searches 5266 first found, first allocated manner. That is, this code searches
@@ -5311,9 +5297,9 @@ static const struct tty_operations cy_ops = {
5311 .hangup = cy_hangup, 5297 .hangup = cy_hangup,
5312 .break_ctl = cy_break, 5298 .break_ctl = cy_break,
5313 .wait_until_sent = cy_wait_until_sent, 5299 .wait_until_sent = cy_wait_until_sent,
5314 .read_proc = cyclades_get_proc_info,
5315 .tiocmget = cy_tiocmget, 5300 .tiocmget = cy_tiocmget,
5316 .tiocmset = cy_tiocmset, 5301 .tiocmset = cy_tiocmset,
5302 .proc_fops = &cyclades_proc_fops,
5317}; 5303};
5318 5304
5319static int __init cy_init(void) 5305static int __init cy_init(void)