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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
Add sysfs support to slmodem drivers.
- Daniel Drake <dsd@gentoo.org>
diff -urNp slmodem-2.9.8/drivers/amrmo_init.c slmodem-dsd/drivers/amrmo_init.c
--- slmodem-2.9.8/drivers/amrmo_init.c 2004-04-22 16:55:35.000000000 +0100
+++ slmodem-dsd/drivers/amrmo_init.c 2004-06-18 20:48:12.604672976 +0100
@@ -54,6 +54,7 @@
#include <linux/fs.h>
#include <asm/uaccess.h>
#include <linux/devfs_fs_kernel.h>
+#include <linux/device.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
#define OLD_KERNEL 1
@@ -270,7 +271,7 @@ MODULE_DEVICE_TABLE (pci, amrmo_pci_tbl)
static struct amrmo_struct *amrmo_table[MAXNUM] = {};
-
+static struct class_simple *amrmo_class;
/*
* debug stuff
@@ -613,6 +614,7 @@ static int __init amrmo_pci_probe(struct
}
#endif
#else
+ class_simple_device_add(amrmo_class, MKDEV(AMRMO_MAJOR, i), NULL, "slamr%d", i);
devfs_mk_cdev(MKDEV(AMRMO_MAJOR,i), S_IFCHR|S_IRUSR|S_IWUSR, "slamr%d", i);
#endif
return 0;
@@ -644,6 +646,7 @@ static void __exit amrmo_pci_remove(stru
}
#endif
#else
+ class_simple_device_remove(MKDEV(AMRMO_MAJOR, amrmo->num));
devfs_remove("slamr%d", amrmo->num);
#endif
amrmo_table[amrmo->num] = NULL;
@@ -720,23 +723,39 @@ static int __init amrmo_init(void)
}
#endif
}
+ }
+
+ /* must create class_simple before the bus gets probed */
+#ifndef OLD_KERNEL
+ amrmo_class = class_simple_create(THIS_MODULE, "slamr");
+ if (IS_ERR(amrmo_class)) {
+ int err = PTR_ERR(amrmo_class);
+ printk(KERN_INFO "slamr: failure creating simple class, error %d\n", err);
+ return err;
}
+#endif
if (!pci_register_driver(&amrmo_pci_driver)) {
pci_unregister_driver(&amrmo_pci_driver);
- return -ENODEV;
+ class_simple_destroy(amrmo_class);
+ return -ENODEV;
}
if(register_chrdev(AMRMO_MAJOR, "slamr", &amrmo_fops) < 0) {
pci_unregister_driver(&amrmo_pci_driver);
+ class_simple_destroy(amrmo_class);
return -ENOMEM;
}
+
return 0;
}
static void __exit amrmo_exit(void)
{
AMRMO_DBG("slamr: exit...\n");
+#ifndef OLD_KERNEL
+ class_simple_destroy(amrmo_class);
+#endif
unregister_chrdev(AMRMO_MAJOR,"slamr");
pci_unregister_driver(&amrmo_pci_driver);
}
diff -urNp slmodem-2.9.8/drivers/old_st7554.c slmodem-dsd/drivers/old_st7554.c
--- slmodem-2.9.8/drivers/old_st7554.c 2004-06-14 15:19:26.000000000 +0100
+++ slmodem-dsd/drivers/old_st7554.c 2004-06-18 20:47:02.738294280 +0100
@@ -55,6 +55,7 @@
#include <linux/poll.h>
#include <linux/usb.h>
#include <linux/devfs_fs_kernel.h>
+#include <linux/device.h>
#include <modem_defs.h>
@@ -73,6 +74,10 @@
#define MY_MAJOR 213
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#define OLD_KERNEL 1
+#endif
+
static int debug = 0;
MODULE_PARM(debug,"i");
MODULE_PARM_DESC(debug,"Debug level: 0-3 (default=0)");
@@ -201,6 +206,7 @@ struct st7554_state {
static struct st7554_state *st7554_table[MAX_MODEMS];
+static struct class_simple *st7554_class;
static DECLARE_MUTEX(open_sem);
@@ -1299,6 +1305,10 @@ static void *st7554_probe(struct usb_dev
mo_free(s); mi_free(s);
goto error1;
}
+
+#ifndef OLD_KERNEL
+ class_simple_device_add(st7554_class, MKDEV(MY_MAJOR, s->minor), NULL, "slusb%d", i);
+#endif
#ifdef CONFIG_DEVFS_FS
{
char buf[8];
@@ -1333,6 +1343,10 @@ static void st7554_disconnect(struct usb
s->file->private_data = NULL;
s->file = NULL;
}
+
+#ifndef OLD_KERNEL
+ class_simple_device_remove(MKDEV(MY_MAJOR, s->minor));
+#endif
#ifdef CONFIG_DEVFS_FS
{
char buf[8];
@@ -1343,6 +1357,7 @@ static void st7554_disconnect(struct usb
devfs_unregister (handle);
}
#endif
+
st7554_stop(s);
st7554_release(s);
s->usbdev = NULL;
@@ -1362,15 +1377,29 @@ static int __init st7554_modem_init(void
{
int ret;
USB_INFO ("ST7554 USB Modem.\n");
+
+ /* must create class_simple before the bus gets probed */
+#ifndef OLD_KERNEL
+ st7554_class = class_simple_create(THIS_MODULE, "slusb");
+ if (IS_ERR(st7554_class)) {
+ ret = PTR_ERR(st7554_class);
+ USB_ERR("st7554_modem_init: failed to create sysfs class, error %d\n", ret);
+ return PTR_ERR(st7554_class);
+ }
+#endif
+
ret = usb_register(&st7554_usb_driver);
if ( ret ) {
USB_ERR ("st7554_modem_init: cannot register usb device.\n");
+ class_simple_destroy(st7554_class);
return ret;
}
if(register_chrdev(MY_MAJOR, "slusb", &st7554_fops) < 0) {
+ class_simple_destroy(st7554_class);
usb_deregister(&st7554_usb_driver);
return -ENOMEM;
}
+
return 0;
}
@@ -1378,6 +1407,9 @@ static int __init st7554_modem_init(void
static void __exit st7554_modem_exit(void)
{
USB_DBG ("st7554: exit...\n");
+#ifndef OLD_KERNEL
+ class_simple_destroy(st7554_class);
+#endif
unregister_chrdev(MY_MAJOR,"slusb");
usb_deregister(&st7554_usb_driver);
}
diff -urNp slmodem-2.9.8/drivers/st7554.c slmodem-dsd/drivers/st7554.c
--- slmodem-2.9.8/drivers/st7554.c 2004-06-01 19:28:00.000000000 +0100
+++ slmodem-dsd/drivers/st7554.c 2004-06-18 20:46:41.255560152 +0100
@@ -55,6 +55,7 @@
#include <linux/poll.h>
#include <linux/usb.h>
#include <linux/devfs_fs_kernel.h>
+#include <linux/device.h>
#include <modem_defs.h>
@@ -67,6 +68,10 @@
#define DEBUG_URB_PRINT 0
#define USB_DBG_URB(fmt...) // USB_DBG(fmt)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#define OLD_KERNEL 1
+#endif
+
static int debug = 0;
MODULE_PARM(debug,"i");
MODULE_PARM_DESC(debug,"Debug level: 0-3 (default=0)");
@@ -205,6 +210,7 @@ struct st7554_state {
static struct st7554_state *st7554_table[MAX_MODEMS] = {};
+static struct class_simple *st7554_class;
static DECLARE_MUTEX(open_sem);
@@ -1275,6 +1281,9 @@ static int st7554_probe(struct usb_inter
}
usb_set_intfdata(interface, s );
+#ifndef OLD_KERNEL
+ class_simple_device_add(st7554_class, MKDEV(213, i), NULL, "slusb%d", i);
+#endif
devfs_mk_cdev(MKDEV(213,i),S_IFCHR|S_IRUSR|S_IWUSR,"slusb%d",i);
USB_INFO(KERN_INFO "slusb: slusb%d is found.\n", s->minor);
@@ -1298,11 +1307,14 @@ static void st7554_disconnect(struct usb
struct st7554_state *s = usb_get_intfdata(interface);
usb_set_intfdata(interface, NULL );
USB_DBG("st7554 disconnect...\n");
- if (!s || !s->usbdev) {
- USB_DBG("st7554 disconnect: no dev.\n");
- return;
- }
+ if (!s || !s->usbdev) {
+ USB_DBG("st7554 disconnect: no dev.\n");
+ return;
+ }
+#ifndef OLD_KERNEL
+ class_simple_device_remove(MKDEV(213, s->minor));
+#endif
devfs_remove("slusb%d",s->minor);
st7554_stop(s);
@@ -1335,15 +1347,29 @@ static int __init st7554_modem_init(void
{
int ret;
USB_INFO ("ST7554 USB Modem.\n");
+
+ /* must create class_simple before the bus gets probed */
+#ifndef OLD_KERNEL
+ st7554_class = class_simple_create(THIS_MODULE, "slusb");
+ if (IS_ERR(st7554_class)) {
+ ret = PTR_ERR(st7554_class);
+ USB_ERR("st7554_modem_init: failed to create sysfs class, error %d\n", ret);
+ return ret;
+ }
+#endif
+
ret = usb_register(&st7554_usb_driver);
if ( ret ) {
USB_ERR ("st7554_modem_init: cannot register usb device.\n");
+ class_simple_destroy(st7554_class);
return ret;
}
if(register_chrdev(213, "slusb", &st7554_fops) < 0) {
usb_deregister(&st7554_usb_driver);
+ class_simple_destroy(st7554_class);
return -ENOMEM;
}
+
return 0;
}
@@ -1351,6 +1377,9 @@ static int __init st7554_modem_init(void
static void __exit st7554_modem_exit(void)
{
USB_DBG ("st7554: exit...\n");
+#ifndef OLD_KERNEL
+ class_simple_destroy(st7554_class);
+#endif
unregister_chrdev(213,"slusb");
usb_deregister(&st7554_usb_driver);
}
|