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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
--- zaptel/zaptel.c.orig 2005-01-03 23:31:28.266487240 +0100
+++ zaptel/zaptel.c 2005-01-03 23:20:16.149664528 +0100
@@ -143,12 +143,14 @@
/* Here are a couple important little additions for devfs */
#ifdef CONFIG_DEVFS_FS
+#ifndef LINUX26
static devfs_handle_t zaptel_devfs_dir;
static devfs_handle_t channel;
static devfs_handle_t pseudo;
static devfs_handle_t ctl;
static devfs_handle_t timer;
#endif
+#endif
/* udev necessary data structures. Yeah! */
#ifdef CONFIG_ZAP_UDEV
@@ -1087,6 +1089,7 @@
}
#ifdef CONFIG_DEVFS_FS
+#ifndef LINUX26
static devfs_handle_t register_devfs_channel(struct zt_chan *chan, devfs_handle_t dir)
{
char path[100];
@@ -1129,6 +1132,36 @@
return chan_dev;
}
+#else
+static dev_t register_devfs_channel(struct zt_chan *chan, dev_t dir)
+{
+#ifdef HAS_DEVFS_MK_SYMLINK
+ char link[100];
+ char path[100];
+#endif
+ dev_t chan_dev;
+ umode_t mode = S_IFCHR|S_IRUGO|S_IWUGO;
+
+ /* create /dev/zap/span%d/%d channel device node */
+ if ((chan_dev = devfs_mk_cdev(MKDEV(ZT_MAJOR, chan->channo), mode, "zap/span%d/%d", dir, chan->chanpos)) < 0) {
+ printk("zaptel: Something really bad happened. Unable to register devfs entry\n");
+ return 0;
+ }
+
+#ifdef HAS_DEVFS_MK_SYMLINK
+ /* link /dev/zap/span%d/%d -> /dev/zap/%d ?!? */
+ sprintf(path, "zap/span%d/%d", dir, chan->chanpos);
+ sprintf(link, "zap/%d", chan->channo);
+ devfs_mk_symlink(link, path);
+#else
+ /* register /dev/zap/%d channel node directly */
+ if(devfs_mk_cdev(MKDEV(ZT_MAJOR, chan->channo), mode, "zap/%d", chan->channo) < 0) {
+ printk("zaptel: Unable to register compat devfs entry\n");
+ }
+#endif
+ return chan_dev;
+}
+#endif
#endif /* CONFIG_DEVFS_FS */
static int zt_chan_reg(struct zt_chan *chan)
@@ -4304,6 +4337,7 @@
#endif
#ifdef CONFIG_DEVFS_FS
+#ifndef LINUX26
{
char span_name[50];
sprintf(span_name, "span%d", span->spanno);
@@ -4313,6 +4347,15 @@
chan->fhandle = register_devfs_channel(chan, chan->span->dhandle); /* Register our stuff with devfs */
}
}
+#else
+ {
+ devfs_mk_dir("zap/span%d", span->spanno);
+ for (x = 0; x < span->channels; x++) {
+ struct zt_chan *chan = &span->chans[x];
+ register_devfs_channel(chan, span->spanno); /* Register our stuff with devfs */
+ }
+ }
+#endif
#endif /* CONFIG_DEVFS_FS */
#ifdef CONFIG_ZAP_UDEV
@@ -4360,11 +4403,22 @@
remove_proc_entry(tempfile, NULL);
#endif /* CONFIG_PROC_FS */
#ifdef CONFIG_DEVFS_FS
+#ifndef LINUX26
for (x = 0; x < span->channels; x++) {
devfs_unregister(span->chans[x].fhandle);
devfs_unregister(span->chans[x].fhandle_symlink);
}
devfs_unregister(span->dhandle);
+#else
+ for (x = 0; x < span->channels; x++) {
+ /* remove symlink/compat device first */
+ devfs_remove("zap/%d", span->chans[x].channo);
+ /* remove channel device */
+ devfs_remove("zap/span%d/%d", span->spanno, span->chans[x].chanpos);
+ }
+ /* remove span dir */
+ devfs_remove("zap/span%d", span->spanno);
+#endif
#endif /* CONFIG_DEVFS_FS */
#ifdef CONFIG_ZAP_UDEV
@@ -6301,6 +6355,7 @@
#endif /* CONFIG_ZAP_UDEV */
#ifdef CONFIG_DEVFS_FS
+#ifndef LINUX26
{
umode_t mode = S_IFCHR|S_IRUGO|S_IWUGO;
devfs_register_chrdev(ZT_MAJOR, "zaptel", &zt_fops);
@@ -6312,6 +6367,22 @@
ctl = devfs_register(zaptel_devfs_dir, "ctl", DEVFS_FL_DEFAULT, ZT_MAJOR, 0, mode, &zt_fops, NULL);
}
#else
+ {
+ umode_t mode = S_IFCHR|S_IRUGO|S_IWUGO;
+ if ((res = register_chrdev(ZT_MAJOR, "zaptel", &zt_fops)) < 0) {
+ printk(KERN_ERR "Unable to register for device on %d, error: %d\n", ZT_MAJOR, res);
+ return res;
+ }
+
+ devfs_mk_dir("zap");
+
+ devfs_mk_cdev(MKDEV(ZT_MAJOR, 253), mode, "zap/timer");
+ devfs_mk_cdev(MKDEV(ZT_MAJOR, 254), mode, "zap/channel");
+ devfs_mk_cdev(MKDEV(ZT_MAJOR, 255), mode, "zap/pseudo");
+ devfs_mk_cdev(MKDEV(ZT_MAJOR, 0), mode, "zap/ctl");
+ }
+#endif
+#else
if ((res = register_chrdev(ZT_MAJOR, "zaptel", &zt_fops))) {
printk(KERN_ERR "Unable to register tor device on %d\n", ZT_MAJOR);
return res;
@@ -6342,6 +6413,7 @@
if (tone_zones[x])
kfree(tone_zones[x]);
#ifdef CONFIG_DEVFS_FS
+#ifndef LINUX26
devfs_unregister(timer);
devfs_unregister(channel);
devfs_unregister(pseudo);
@@ -6357,6 +6429,16 @@
class_simple_destroy(zap_class);
#endif /* CONFIG_ZAP_UDEV */
unregister_chrdev(ZT_MAJOR, "zaptel");
+
+ devfs_remove("zap/timer");
+ devfs_remove("zap/ctl");
+ devfs_remove("zap/pseudo");
+ devfs_remove("zap/channel");
+
+ devfs_remove("zap");
+#endif
+#else
+ unregister_chrdev(ZT_MAJOR, "zaptel");
#endif
#ifdef CONFIG_ZAPTEL_WATCHDOG
watchdog_cleanup();
--- zaptel/zaptel.h.orig 2005-01-03 23:31:32.029915112 +0100
+++ zaptel/zaptel.h 2005-01-03 23:20:18.380325416 +0100
@@ -46,18 +46,17 @@
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
#define LINUX26
+/* devfs_mk_symlink has been removed in 2.6.10 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
+#define HAS_DEVFS_MK_SYMLINK
+#endif
#endif
#include "ecdis.h"
#include "fasthdlc.h"
#endif
#ifdef CONFIG_DEVFS_FS
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
#include <linux/devfs_fs_kernel.h>
-#else
-#undef CONFIG_DEVFS_FS
-//#warning "Zaptel doesn't support DEVFS in post 2.4 kernels. Disabling DEVFS in zaptel"
-#endif
#endif /* CONFIG_DEVFS_FS */
#include <linux/ioctl.h>
@@ -65,6 +64,8 @@
#define ELAST 500
#endif
+
+
/* Per-span configuration values */
#define ZT_CONFIG_TXLEVEL 7 /* bits 0-2 are tx level */
@@ -1123,8 +1124,10 @@
#endif
#ifdef CONFIG_DEVFS_FS
+#ifndef LINUX26
devfs_handle_t fhandle; /* File handle in devfs for the channel */
devfs_handle_t fhandle_symlink;
+#endif
#endif /* CONFIG_DEVFS_FS */
};
@@ -1254,7 +1257,9 @@
int lastalarms; /* Previous alarms */
#ifdef CONFIG_DEVFS_FS
+#ifndef LINUX26
devfs_handle_t dhandle; /* Directory name */
+#endif
#endif
/* If the watchdog detects no received data, it will call the
watchdog routine */
|