summaryrefslogtreecommitdiff
blob: 26b638147aa743222aa7fe5417c821e5d174254d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
--- driver.c~	2010-05-17 11:51:30.315940940 +0200
+++ driver.c	2010-05-17 11:51:30.362264370 +0200
@@ -48,6 +48,8 @@
 #include "defs.h"
 #include "lib.h"
 #include "driver.h"
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 
 /*---------------------------------------------------------------------------*\
 \*---------------------------------------------------------------------------*/
@@ -490,39 +492,34 @@
 
 /*---------------------------------------------------------------------------*\
 \*---------------------------------------------------------------------------*/
-static int __kcapi ctr_info (
-	char *			page, 
-	char **			start, 
-	off_t			ofs,
-	int			count, 
-	int *			eof,
-	struct capi_ctr *	ctrl
+
+static int __kcapi ctr_info (struct seq_file *m, void *v
 ) {
+        struct capi_ctr *ctrl = m->private;
 	card_t *		card;
 	char *			temp;
 	unsigned char		flag;
-	int			len = 0;
 
 	assert (ctrl != NULL);
 	card = (card_t *) ctrl->driverdata;
 	assert (card != NULL);
-	pprintf (page, &len, "%-16s %s\n", "name", SHORT_LOGO);
-	pprintf (page, &len, "%-16s 0x%04x\n", "io", card->base);
-	pprintf (page, &len, "%-16s %d\n", "irq", card->irq);
+	seq_printf(m, "%-16s %s\n", "name", SHORT_LOGO);
+	seq_printf(m, "%-16s 0x%04x\n", "io", card->base);
+	seq_printf(m, "%-16s %d\n", "irq", card->irq);
 	temp = card->version ? card->string[1] : "A1";
-	pprintf (page, &len, "%-16s %s\n", "type", temp);
+	seq_printf(m, "%-16s %s\n", "type", temp);
 	temp = card->version ? card->string[0] : "-";
 #if defined (__fcclassic__) || defined (__fcpcmcia__)
-	pprintf (page, &len, "%-16s 0x%04x\n", "revision", card->info);
+	seq_printf(m, "%-16s 0x%04x\n", "revision", card->info);
 #elif defined (__fcpci__)
-	pprintf (page, &len, "%-16s %d\n", "class", card_id);
+	seq_printf(m, "%-16s %d\n", "class", card_id);
 #endif
-	pprintf (page, &len, "%-16s %s\n", "ver_driver", temp);
-	pprintf (page, &len, "%-16s %s\n", "ver_cardtype", SHORT_LOGO);
+	seq_printf(m, "%-16s %s\n", "ver_driver", temp);
+	seq_printf(m, "%-16s %s\n", "ver_cardtype", SHORT_LOGO);
 
 	flag = ((unsigned char *) (ctrl->profile.manu))[3];
 	if (flag) {
-		pprintf(page, &len, "%-16s%s%s%s%s%s%s%s\n", "protocol",
+		seq_printf(m, "%-16s%s%s%s%s%s%s%s\n", "protocol",
 			(flag & 0x01) ? " DSS1" : "",
 			(flag & 0x02) ? " CT1" : "",
 			(flag & 0x04) ? " VN3" : "",
@@ -534,21 +531,30 @@
 	}
 	flag = ((unsigned char *) (ctrl->profile.manu))[5];
 	if (flag) {
-		pprintf(page, &len, "%-16s%s%s%s%s\n", "linetype",
+		seq_printf(m, "%-16s%s%s%s%s\n", "linetype",
 			(flag & 0x01) ? " point to point" : "",
 			(flag & 0x02) ? " point to multipoint" : "",
 			(flag & 0x08) ? " leased line without D-channel" : "",
 			(flag & 0x04) ? " leased line with D-channel" : ""
 		);
 	}
-	if (len < ofs) {
-		return 0;
-	}
-	*eof = 1;
-	*start = page - ofs;
-	return ((count < len - ofs) ? count : len - ofs);
+
+       return 0;
 } /* ctr_info */
 
+static int ctr_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, ctr_info, PDE(inode)->data);
+}
+
+const struct file_operations ctr_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = ctr_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
 /*---------------------------------------------------------------------------*\
 \*---------------------------------------------------------------------------*/
 static void __kcapi reset_ctrl (struct capi_ctr * ctrl) {
--- driver.c~	2010-05-17 19:55:09.158499792 +0200
+++ driver.c	2010-05-17 19:55:09.190784099 +0200
@@ -222,16 +222,6 @@
 } /* kill_version */
 
 /*---------------------------------------------------------------------------*\
-\*---------------------------------------------------------------------------*/
-static void pprintf (char * page, int * len, const char * fmt, ...) {
-	va_list args;
-
-	va_start (args, fmt);
-	*len += vsprintf (page + *len, fmt, args);
-	va_end (args);
-} /* pprintf */
-
-/*---------------------------------------------------------------------------*\
 \*-C-------------------------------------------------------------------------*/
 static inline int in_critical (void) {
 	
@@ -632,7 +622,7 @@
 	ctrl->release_appl =	release_appl;
 	ctrl->send_message =	send_msg;
 	ctrl->procinfo =	proc_info;
-	ctrl->ctr_read_proc =	ctr_info;
+	ctrl->proc_fops =	&ctr_proc_fops;
 	if (0 != (res = attach_capi_ctr (ctrl))) {
 		dec_use_count ();
 		stop (card);