9 /* Turn /lib/modules/2.5.49/kernel/foo.ko(.gz) => foo */
10 static void make_shortname(char *dest
, const char *src
)
15 bname
= my_basename(src
);
17 ext
= strchr(dest
, '.');
22 /* We set driver_data to zero */
23 static void output_pci_entry(struct pci_device_id
*pci
, char *name
, FILE *out
,
27 "%-20s 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x0\n",
29 END(pci
->vendor
, conv
),
30 END(pci
->device
, conv
),
31 END(pci
->subvendor
, conv
),
32 END(pci
->subdevice
, conv
),
33 END(pci
->class, conv
),
34 END(pci
->class_mask
, conv
));
37 void output_pci_table(struct module
*modules
, FILE *out
, char *dirname
)
41 fprintf(out
, "# pci module vendor device subvendor"
42 " subdevice class class_mask driver_data\n");
44 for (i
= modules
; i
; i
= i
->next
) {
45 struct pci_device_id
*e
;
46 char shortname
[strlen(i
->pathname
) + 1];
47 struct module_tables
*t
= &i
->tables
;
52 make_shortname(shortname
, i
->pathname
);
53 for (e
= t
->pci_table
; e
->vendor
; e
= (void *)e
+ t
->pci_size
)
54 output_pci_entry(e
, shortname
, out
, i
->file
->conv
);
58 /* We set driver_info to zero */
59 static void output_usb_entry(struct usb_device_id
*usb
, char *name
, FILE *out
,
62 fprintf(out
, "%-20s 0x%04x 0x%04x 0x%04x 0x%04x"
63 " 0x%04x 0x%02x 0x%02x"
68 END(usb
->match_flags
, conv
),
69 END(usb
->idVendor
, conv
),
70 END(usb
->idProduct
, conv
),
71 END(usb
->bcdDevice_lo
, conv
),
72 END(usb
->bcdDevice_hi
, conv
),
73 END(usb
->bDeviceClass
, conv
),
74 END(usb
->bDeviceSubClass
, conv
),
75 END(usb
->bDeviceProtocol
, conv
),
76 END(usb
->bInterfaceClass
, conv
),
77 END(usb
->bInterfaceSubClass
, conv
),
78 END(usb
->bInterfaceProtocol
, conv
));
81 void output_usb_table(struct module
*modules
, FILE *out
, char *dirname
)
85 fprintf(out
, "# usb module ");
86 /* Requires all users to be on kernel 2.4.0 or later */
87 fprintf(out
, "match_flags ");
88 fprintf(out
, "idVendor idProduct bcdDevice_lo bcdDevice_hi"
89 " bDeviceClass bDeviceSubClass bDeviceProtocol"
90 " bInterfaceClass bInterfaceSubClass"
91 " bInterfaceProtocol driver_info\n");
93 for (i
= modules
; i
; i
= i
->next
) {
94 struct usb_device_id
*e
;
95 char shortname
[strlen(i
->pathname
) + 1];
96 struct module_tables
*t
= &i
->tables
;
101 make_shortname(shortname
, i
->pathname
);
102 for (e
= t
->usb_table
;
103 e
->idVendor
|| e
->bDeviceClass
|| e
->bInterfaceClass
;
104 e
= (void *)e
+ t
->usb_size
)
105 output_usb_entry(e
, shortname
, out
, i
->file
->conv
);
109 static void output_ieee1394_entry(struct ieee1394_device_id
*fw
, char *name
,
112 fprintf(out
, "%-20s 0x%08x 0x%06x 0x%06x 0x%06x 0x%06x\n",
114 END(fw
->match_flags
, conv
),
115 END(fw
->vendor_id
, conv
),
116 END(fw
->model_id
, conv
),
117 END(fw
->specifier_id
, conv
),
118 END(fw
->version
, conv
));
121 void output_ieee1394_table(struct module
*modules
, FILE *out
, char *dirname
)
125 fprintf(out
, "# ieee1394 module ");
126 fprintf(out
, "match_flags vendor_id model_id specifier_id version\n");
128 for (i
= modules
; i
; i
= i
->next
) {
129 struct ieee1394_device_id
*fw
;
130 char shortname
[strlen(i
->pathname
) + 1];
131 struct module_tables
*t
= &i
->tables
;
133 if (!t
->ieee1394_table
)
136 make_shortname(shortname
, i
->pathname
);
137 for (fw
= t
->ieee1394_table
; fw
->match_flags
;
138 fw
= (void *) fw
+ t
->ieee1394_size
)
139 output_ieee1394_entry(fw
, shortname
, out
, i
->file
->conv
);
144 /* We set driver_data to zero */
145 static void output_ccw_entry(struct ccw_device_id
*ccw
, char *name
, FILE *out
,
148 fprintf(out
, "%-20s 0x%04x 0x%04x 0x%02x 0x%04x 0x%02x\n",
149 name
, END(ccw
->match_flags
, conv
),
150 END(ccw
->cu_type
, conv
), END(ccw
->cu_model
, conv
),
151 END(ccw
->dev_type
, conv
), END(ccw
->dev_model
, conv
));
154 void output_ccw_table(struct module
*modules
, FILE *out
, char *dirname
)
158 fprintf(out
, "# ccw module ");
159 fprintf(out
, "match_flags cu_type cu_model dev_type dev_model\n");
161 for (i
= modules
; i
; i
= i
->next
) {
162 struct ccw_device_id
*e
;
163 char shortname
[strlen(i
->pathname
) + 1];
164 struct module_tables
*t
= &i
->tables
;
169 make_shortname(shortname
, i
->pathname
);
170 for (e
= t
->ccw_table
;
171 e
->cu_type
|| e
->cu_model
|| e
->dev_type
|| e
->dev_model
;
172 e
= (void *) e
+ t
->ccw_size
)
173 output_ccw_entry(e
, shortname
, out
, i
->file
->conv
);
177 #define ISAPNP_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\
178 ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
179 ((((c)-'A'+1)&0x1f)<<8))
180 #define ISAPNP_DEVICE(x) ((((x)&0xf000)>>8)|\
185 static void put_isapnp_id(FILE *out
, const char *id
)
187 unsigned short vendor
, device
;
189 vendor
= ISAPNP_VENDOR(id
[0], id
[1], id
[2]);
190 device
= (unsigned short)strtol(&id
[3], NULL
, 16);
191 device
= ISAPNP_DEVICE(device
);
192 fprintf(out
, " 0x%04x 0x%04x ", vendor
, device
);
195 void output_isapnp_table(struct module
*modules
, FILE *out
, char *dirname
)
199 fprintf(out
, "# isapnp module ");
200 fprintf(out
, "cardvendor carddevice driver_data vendor function ...\n");
202 for (i
= modules
; i
; i
= i
->next
) {
203 char shortname
[strlen(i
->pathname
) + 1];
204 struct module_tables
*t
= &i
->tables
;
207 struct pnp_device_id
*id
;
208 make_shortname(shortname
, i
->pathname
);
209 for (id
= t
->pnp_table
;
211 id
= (void *)id
+ t
->pnp_size
) {
212 fprintf(out
, "%-20s", shortname
);
213 fprintf(out
, " 0xffff 0xffff ");
214 fprintf(out
, " 0x00000000 "); /* driver_data */
215 put_isapnp_id(out
, id
->id
);
219 if (t
->pnp_card_table
) {
221 make_shortname(shortname
, i
->pathname
);
222 for (id
= t
->pnp_card_table
;
224 id
+= t
->pnp_card_size
) {
226 struct pnp_card_devid
*devid
227 = id
+ t
->pnp_card_offset
;
229 fprintf(out
, "%-20s", shortname
);
230 put_isapnp_id(out
, id
);
231 fprintf(out
, " 0x00000000 "); /* driver_data */
232 for (idx
= 0; idx
< 8; idx
++) {
233 if (!devid
->devid
[idx
][0])
235 put_isapnp_id(out
, devid
->devid
[idx
]);
243 #define MATCH_bustype 1
244 #define MATCH_vendor 2
245 #define MATCH_product 4
246 #define MATCH_version 8
248 #define MATCH_evbit 0x010
249 #define MATCH_keybit 0x020
250 #define MATCH_relbit 0x040
251 #define MATCH_absbit 0x080
252 #define MATCH_mscbit 0x100
253 #define MATCH_ledbit 0x200
254 #define MATCH_sndbit 0x400
255 #define MATCH_ffbit 0x800
256 #define MATCH_swbit 0x1000
258 #define MATCH(x) (END(input->match_flags, conv) & MATCH_ ## x)
259 #define PRINT_SCALAR(n) fprintf(out, " 0x%lx", MATCH(n) ? END(input->n, conv) : 0l)
260 #define PRINT_ARRAY64(n) do { \
263 output_input_bits_64(out, input->n, sizeof(input->n), conv); \
265 fprintf(out, "%d", 0); \
268 #define PRINT_ARRAY32(n) do { \
271 output_input_bits_32(out, input->n, sizeof(input->n), conv); \
273 fprintf(out, "%d", 0); \
276 static void output_input_bits_32(FILE *out
, unsigned int *bits
, int size
,
281 size
/= sizeof(*bits
);
282 for (i
= size
- 1; i
>= 0; i
--)
283 if (END(bits
[i
], conv
))
287 fprintf(out
, "%x", END(bits
[i
], conv
));
288 for (j
= i
- 1; j
>= 0; j
--)
289 fprintf(out
, ":%x", END(bits
[j
], conv
));
292 static void output_input_bits_64(FILE *out
, unsigned long long *bits
, int size
,
297 size
/= sizeof(*bits
);
298 for (i
= size
- 1; i
>= 0; i
--)
299 if (END(bits
[i
], conv
))
303 fprintf(out
, "%llx", END(bits
[i
], conv
));
304 for (j
= i
- 1; j
>= 0; j
--)
305 fprintf(out
, ":%llx", END(bits
[j
], conv
));
308 /* Formats are too different to */
309 static int output_input_entry_32(struct input_device_id_32
*input
,
310 char *name
, FILE *out
, int conv
)
312 if (!input
->match_flags
&& !input
->driver_info
)
315 fprintf(out
, "%-20s0x%x", name
, END(input
->match_flags
, conv
));
317 PRINT_SCALAR(bustype
);
318 PRINT_SCALAR(vendor
);
319 PRINT_SCALAR(product
);
320 PRINT_SCALAR(version
);
322 PRINT_ARRAY32(evbit
);
323 PRINT_ARRAY32(keybit
);
324 PRINT_ARRAY32(relbit
);
325 PRINT_ARRAY32(absbit
);
326 PRINT_ARRAY32(mscbit
);
327 PRINT_ARRAY32(ledbit
);
328 PRINT_ARRAY32(sndbit
);
329 PRINT_ARRAY32(ffbit
);
330 PRINT_ARRAY32(swbit
);
332 fprintf(out
, " 0x%x\n", END(input
->driver_info
, conv
));
336 static int output_input_entry_32_old(struct input_device_id_old_32
*input
,
337 char *name
, FILE *out
, int conv
)
339 if (!input
->match_flags
&& !input
->driver_info
)
342 fprintf(out
, "%-20s0x%x", name
, END(input
->match_flags
, conv
));
344 PRINT_SCALAR(bustype
);
345 PRINT_SCALAR(vendor
);
346 PRINT_SCALAR(product
);
347 PRINT_SCALAR(version
);
349 PRINT_ARRAY32(evbit
);
350 PRINT_ARRAY32(keybit
);
351 PRINT_ARRAY32(relbit
);
352 PRINT_ARRAY32(absbit
);
353 PRINT_ARRAY32(mscbit
);
354 PRINT_ARRAY32(ledbit
);
355 PRINT_ARRAY32(sndbit
);
356 PRINT_ARRAY32(ffbit
);
358 fprintf(out
, " 0x%x\n", END(input
->driver_info
, conv
));
362 static int output_input_entry_64(struct input_device_id_64
*input
,
363 char *name
, FILE *out
, int conv
)
365 if (!input
->match_flags
&& !input
->driver_info
)
368 fprintf(out
, "%-20s0x%llx", name
, END(input
->match_flags
, conv
));
370 PRINT_SCALAR(bustype
);
371 PRINT_SCALAR(vendor
);
372 PRINT_SCALAR(product
);
373 PRINT_SCALAR(version
);
375 PRINT_ARRAY64(evbit
);
376 PRINT_ARRAY64(keybit
);
377 PRINT_ARRAY64(relbit
);
378 PRINT_ARRAY64(absbit
);
379 PRINT_ARRAY64(mscbit
);
380 PRINT_ARRAY64(ledbit
);
381 PRINT_ARRAY64(sndbit
);
382 PRINT_ARRAY64(ffbit
);
383 PRINT_ARRAY64(swbit
);
385 fprintf(out
, " 0x%llx\n", END(input
->driver_info
, conv
));
389 static int output_input_entry_64_old(struct input_device_id_old_64
*input
,
390 char *name
, FILE *out
, int conv
)
392 if (!input
->match_flags
&& !input
->driver_info
)
395 fprintf(out
, "%-20s0x%llx", name
, END(input
->match_flags
, conv
));
397 PRINT_SCALAR(bustype
);
398 PRINT_SCALAR(vendor
);
399 PRINT_SCALAR(product
);
400 PRINT_SCALAR(version
);
402 PRINT_ARRAY64(evbit
);
403 PRINT_ARRAY64(keybit
);
404 PRINT_ARRAY64(relbit
);
405 PRINT_ARRAY64(absbit
);
406 PRINT_ARRAY64(mscbit
);
407 PRINT_ARRAY64(ledbit
);
408 PRINT_ARRAY64(sndbit
);
409 PRINT_ARRAY64(ffbit
);
411 fprintf(out
, " 0x%llx\n", END(input
->driver_info
, conv
));
415 void output_input_table(struct module
*modules
, FILE *out
, char *dirname
)
419 fprintf(out
, "# module matchBits");
420 fprintf(out
, " bustype vendor product version evBits keyBits relBits");
421 fprintf(out
, " absBits mscBits ledBits sndBits ffBits [swBits] driver_info\n");
423 for (i
= modules
; i
; i
= i
->next
) {
425 char shortname
[strlen(i
->pathname
) + 1];
427 struct module_tables
*t
= &i
->tables
;
428 int conv
= i
->file
->conv
;
433 make_shortname(shortname
, i
->pathname
);
434 /* Guess what size it really is, based on size of
435 * whole table. Table changed in 2.6.14. This is a hack. */
436 if (t
->input_size
== sizeof(struct input_device_id_old_64
)) {
437 if ((t
->input_table_size
% t
->input_size
) != 0) {
439 = sizeof(struct input_device_id_64
);
442 if ((t
->input_table_size
% t
->input_size
) != 0) {
444 = sizeof(struct input_device_id_32
);
448 for (p
= t
->input_table
; !done
; p
+= t
->input_size
) {
449 switch (t
->input_size
) {
450 case sizeof(struct input_device_id_old_64
):
451 done
= output_input_entry_64_old(p
,
455 case sizeof(struct input_device_id_64
):
456 done
= output_input_entry_64(p
, shortname
,
459 case sizeof(struct input_device_id_old_32
):
460 done
= output_input_entry_32_old(p
,
464 case sizeof(struct input_device_id_32
):
465 done
= output_input_entry_32(p
, shortname
,
473 static void output_serio_entry(struct serio_device_id
*serio
, char *name
, FILE *out
)
476 "%-20s 0x%02x 0x%02x 0x%02x 0x%02x\n",
485 void output_serio_table(struct module
*modules
, FILE *out
, char *dirname
)
489 fprintf(out
, "# serio module type extra id proto\n");
491 for (i
= modules
; i
; i
= i
->next
) {
492 struct serio_device_id
*e
;
493 char shortname
[strlen(i
->pathname
) + 1];
494 struct module_tables
*t
= &i
->tables
;
499 make_shortname(shortname
, i
->pathname
);
500 for (e
= t
->serio_table
; e
->type
|| e
->proto
; e
= (void *)e
+ t
->serio_size
)
501 output_serio_entry(e
, shortname
, out
);
507 strip_whitespace (char *str
, char chr
)
512 for (i
= strlen (str
); i
>= 0; --i
)
517 /* We set driver_data to zero */
518 static void output_of_entry(struct of_device_id
*dev
, char *name
, FILE *out
)
520 char *ofname
= NULL
, *type
= NULL
, *compatible
= NULL
;
522 ofname
= strdup (dev
->name
);
523 strip_whitespace (ofname
, '_');
527 type
= strdup (dev
->type
);
528 strip_whitespace (type
, '_');
531 if (dev
->compatible
[0]) {
532 compatible
= strdup (dev
->compatible
);
533 strip_whitespace (compatible
, '_');
536 fprintf (out
, "%-20s %-20s %-20s %s\n",
537 name
, ofname
? ofname
: "*", type
? type
: "*",
538 compatible
? compatible
: "*");
545 void output_of_table(struct module
*modules
, FILE *out
, char *dirname
)
549 fprintf (out
, "# of module name type compatible\n");
550 for (i
= modules
; i
; i
= i
->next
) {
551 struct of_device_id
*e
;
552 char shortname
[strlen(i
->pathname
) + 1];
553 struct module_tables
*t
= &i
->tables
;
558 make_shortname(shortname
, i
->pathname
);
559 for (e
= t
->of_table
; e
->name
[0]|e
->type
[0]|e
->compatible
[0];
560 e
= (void *)e
+ t
->of_size
)
561 output_of_entry(e
, shortname
, out
);