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
|
diff -urpwN svgalib-1.9.18/kernel/svgalib_helper/Makefile.alt svgalib-1.9.18.kernel2.6/kernel/svgalib_helper/Makefile.alt
--- svgalib-1.9.18/kernel/svgalib_helper/Makefile.alt 2002-10-28 18:25:47.000000000 +0200
+++ svgalib-1.9.18.kernel2.6/kernel/svgalib_helper/Makefile.alt 2003-08-03 14:34:40.000000000 +0200
@@ -37,7 +37,7 @@
CFLAGS += -DSVGALIB_HELPER_MAJOR=$(SVGALIB_HELPER_MAJOR)
ifeq (1,$(findstring 1,$(MODVER)))
- CFLAGS += -DMODVERSIONS -include $(INCLUDEDIR)/linux/modversions.h
+ CFLAGS += -DMODVERSIONS -DCONFIG_MODVERSIONS=1
endif
TARGET = svgalib_helper
@@ -50,7 +50,8 @@
endif
endif
-all: .depend $(OBJS)
+modules: $(OBJS)
+all: .depend modules
$(TARGET).o: $(SRC:.c=.o)
$(LD) -r $^ -o $@
@@ -61,8 +62,8 @@
install: device modules_install
modules_install: $(OBJS)
- mkdir -p /lib/modules/$(VER)/kernel/misc
- install -m 0644 -c $(OBJS) /lib/modules/$(VER)/kernel/misc
+ mkdir -p $(TOPDIR)/lib/modules/$(VER)/kernel/misc
+ install -m 0644 -c $(OBJS) $(TOPDIR)/lib/modules/$(VER)/kernel/misc
device:
rm -f /dev/svgalib_helper* /dev/svga_helper* /dev/svga /dev/svga?
diff -urpN svgalib-1.9.18/kernel/svgalib_helper/kernel26compat.h svgalib-1.9.18.new/kernel/svgalib_helper/kernel26compat.h
--- svgalib-1.9.18/kernel/svgalib_helper/kernel26compat.h 2003-10-04 15:42:01.000000000 +0200
+++ svgalib-1.9.18.new/kernel/svgalib_helper/kernel26compat.h 2004-02-23 00:41:03.176196576 +0200
@@ -52,6 +52,33 @@ static inline int devfs_unregister_chrde
}
#endif
+#if defined(KERNEL_2_6) && !defined(CONFIG_DEVFS_FS)
+# define SLH_SYSFS_REGISTER \
+ svgalib_helper_class = class_simple_create(THIS_MODULE, "svgalib_helper");
+
+# define SLH_SYSFS_ADD_CONTROL \
+ class_simple_device_add(svgalib_helper_class, \
+ MKDEV(SVGALIB_HELPER_MAJOR, 0), \
+ NULL, "svga");
+
+# define SLH_SYSFS_ADD_DEVICE(_name, _minor) \
+ class_simple_device_add(svgalib_helper_class, \
+ MKDEV(SVGALIB_HELPER_MAJOR, _minor), \
+ &sh_pci_devs[_minor]->dev->dev, _name);
+
+# define SLH_SYSFS_REMOVE_DEVICE(i) \
+ class_simple_device_remove(MKDEV(SVGALIB_HELPER_MAJOR, i));
+
+# define SLH_SYSFS_UNREGISTER \
+ class_simple_destroy(svgalib_helper_class);
+#else
+# define SLH_SYSFS_REGISTER
+# define SLH_SYSFS_ADD_CONTROL
+# define SLH_SYSFS_ADD_DEVICE(_name, _minor)
+# define SLH_SYSFS_REMOVE_DEVICE(i)
+# define SLH_SYSFS_UNREGISTER
+#endif
+
#if (defined MINOR)
# define my_minor(x) MINOR(x)
#else
diff -urpN svgalib-1.9.18/kernel/svgalib_helper/main.c svgalib-1.9.18.new/kernel/svgalib_helper/main.c
--- svgalib-1.9.18/kernel/svgalib_helper/main.c 2003-10-04 12:34:20.000000000 +0200
+++ svgalib-1.9.18.new/kernel/svgalib_helper/main.c 2004-02-23 00:42:25.490682872 +0200
@@ -51,6 +51,10 @@ static int irqs[MAX_NR_DEVICES];
static devfs_handle_t devfs_handle;
#endif
+#if defined(KERNEL_2_6) && !defined(CONFIG_DEVFS_FS)
+struct class_simple *svgalib_helper_class;
+#endif
+
static int check_io_range(int port, int device) {
return 1;
}
@@ -467,6 +471,7 @@ int init_module(void)
{
int result, i, j;
struct pci_dev *dev=NULL;
+ char name[255];
#ifdef CONFIG_DEVFS_FS
# ifndef KERNEL_2_6
devfs_handle_t slave_handle;
@@ -513,9 +518,9 @@ int init_module(void)
printk(KERN_INFO "svgalib_helper: Initializing, version %s\n", versionstr);
- result = devfs_register_chrdev(SVGALIB_HELPER_MAJOR, "svgalib_helper", &svgalib_helper_fops);
+ result = devfs_register_chrdev(SVGALIB_HELPER_MAJOR, "svgalib_helper", &svgalib_helper_fops);
- if (result < 0) {
+ if (result < 0) {
printk(KERN_WARNING "svgalib_helper: can't get major %d\n",SVGALIB_HELPER_MAJOR);
return result;
}
@@ -523,7 +528,7 @@ int init_module(void)
if((sh_pci_devs[0]=kmalloc(sizeof(struct sh_pci_device),GFP_KERNEL))==NULL) {
goto nomem_error;
}
-
+
memset(sh_pci_devs[0],0,sizeof(struct sh_pci_device));
num_devices=1;
for(i=1;i<MAX_NR_DEVICES;i++) sh_pci_devs[i]=NULL;
@@ -537,19 +542,22 @@ int init_module(void)
devfs_mk_symlink( NULL, "svga", 0, "svga_helper/0", &slave_handle, NULL );
devfs_auto_unregister( devfs_handle, slave_handle );
# else
- devfs_mk_dir ("svga_helper");
- for (i = 0; i < 8; i++) {
- devfs_mk_cdev(MKDEV(SVGALIB_HELPER_MAJOR, i),
- S_IFCHR | S_IRUGO | S_IRWXU, "svga_helper/%d", i);
- }
- devfs_mk_symlink("svga", "svga_helper/0");
+ devfs_mk_dir ("svga_helper");
+ for (i = 0; i < 8; i++) {
+ devfs_mk_cdev(MKDEV(SVGALIB_HELPER_MAJOR, i),
+ S_IFCHR | S_IRUGO | S_IRWXU, "svga_helper/%d", i);
+ }
+ devfs_mk_symlink("svga", "svga_helper/0");
# endif
#endif /* devfsd support */
+ SLH_SYSFS_REGISTER;
+ SLH_SYSFS_ADD_CONTROL;
+
if(pci_present()) {
while((dev= all_devices ?
- pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev) :
- pci_find_class(PCI_CLASS_DISPLAY_VGA<<8,dev)) &&
+ pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev) :
+ pci_find_class(PCI_CLASS_DISPLAY_VGA<<8,dev)) &&
(num_devices<=MAX_NR_DEVICES)) {
if((sh_pci_devs[num_devices]=kmalloc(sizeof(struct sh_pci_device),GFP_KERNEL))==NULL) {
goto nomem_error;
@@ -581,6 +589,10 @@ int init_module(void)
sh_pci_devs[num_devices]->startad=-1;
#endif
sh_pci_devs[num_devices]->opencount=0;
+
+ sprintf(name, "svga%d", num_devices);
+ SLH_SYSFS_ADD_DEVICE(name, num_devices);
+
num_devices++;
}
}
@@ -600,39 +612,51 @@ int init_module(void)
init_waitqueue_head(&vsync_wait);
#ifndef KERNEL_2_6
- EXPORT_NO_SYMBOLS;
+ EXPORT_NO_SYMBOLS;
#endif
-
+
return 0; /* succeed */
nomem_error:
- for(i=0;i<MAX_NR_DEVICES;i++)
- if(sh_pci_devs[i])kfree(sh_pci_devs[i]);
+ for(i=0;i<MAX_NR_DEVICES;i++) {
+ if(sh_pci_devs[i]) {
+ SLH_SYSFS_REMOVE_DEVICE(i);
+ kfree(sh_pci_devs[i]);
+ }
+ }
+
+ SLH_SYSFS_REMOVE_DEVICE(0);
+ SLH_SYSFS_UNREGISTER;
+
+ devfs_unregister_chrdev(SVGALIB_HELPER_MAJOR, "svgalib_helper");
- devfs_unregister_chrdev(SVGALIB_HELPER_MAJOR, "svgalib_helper");
-
- return result;
+ return result;
}
void cleanup_module(void)
{
int i;
- for(i=0;i<MAX_NR_DEVICES;i++)
+ for(i=0;i<MAX_NR_DEVICES;i++) {
if(sh_pci_devs[i]) {
+ SLH_SYSFS_REMOVE_DEVICE(i);
kfree(sh_pci_devs[i]);
}
+ }
+
+ SLH_SYSFS_REMOVE_DEVICE(0);
+ SLH_SYSFS_UNREGISTER;
#ifdef CONFIG_DEVFS_FS
# ifndef KERNEL_2_6
- devfs_unregister(devfs_handle);
+ devfs_unregister(devfs_handle);
# else
- for (i = 0; i < 8; i++)
- devfs_remove("svga_helper/%d", i);
- devfs_remove("svga_helper");
- devfs_remove("svga");
-# endif
+ for (i = 0; i < 8; i++)
+ devfs_remove("svga_helper/%d", i);
+ devfs_remove("svga_helper");
+ devfs_remove("svga");
+# endif
#endif
-
+
devfs_unregister_chrdev(SVGALIB_HELPER_MAJOR, "svgalib_helper");
}
--- svgalib-1.9.19/kernel/svgalib_helper/kernel26compat.h.orig 2004-07-20 19:05:13.491390800 -0400
+++ svgalib-1.9.19/kernel/svgalib_helper/kernel26compat.h 2004-07-20 19:05:29.217999992 -0400
@@ -7,7 +7,7 @@
# undef KERNEL_2_6
# endif
-# if defined (PG_chainlock)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,3)
# define my_io_remap_page_range(vma, start, ofs, len, prot) \
io_remap_page_range(vma,start,ofs,len,prot)
# else
|