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];
51 make_shortname(shortname
, i
->pathname
);
52 for (e
= i
->pci_table
; e
->vendor
; e
= (void *)e
+ i
->pci_size
)
53 output_pci_entry(e
, shortname
, out
, i
->conv
);
57 /* We set driver_info to zero */
58 static void output_usb_entry(struct usb_device_id
*usb
, char *name
, FILE *out
,
61 fprintf(out
, "%-20s 0x%04x 0x%04x 0x%04x 0x%04x"
62 " 0x%04x 0x%02x 0x%02x"
67 END(usb
->match_flags
, conv
),
68 END(usb
->idVendor
, conv
),
69 END(usb
->idProduct
, conv
),
70 END(usb
->bcdDevice_lo
, conv
),
71 END(usb
->bcdDevice_hi
, conv
),
72 END(usb
->bDeviceClass
, conv
),
73 END(usb
->bDeviceSubClass
, conv
),
74 END(usb
->bDeviceProtocol
, conv
),
75 END(usb
->bInterfaceClass
, conv
),
76 END(usb
->bInterfaceSubClass
, conv
),
77 END(usb
->bInterfaceProtocol
, conv
));
80 void output_usb_table(struct module
*modules
, FILE *out
, char *dirname
)
84 fprintf(out
, "# usb module ");
85 /* Requires all users to be on kernel 2.4.0 or later */
86 fprintf(out
, "match_flags ");
87 fprintf(out
, "idVendor idProduct bcdDevice_lo bcdDevice_hi"
88 " bDeviceClass bDeviceSubClass bDeviceProtocol"
89 " bInterfaceClass bInterfaceSubClass"
90 " bInterfaceProtocol driver_info\n");
92 for (i
= modules
; i
; i
= i
->next
) {
93 struct usb_device_id
*e
;
94 char shortname
[strlen(i
->pathname
) + 1];
99 make_shortname(shortname
, i
->pathname
);
100 for (e
= i
->usb_table
;
101 e
->idVendor
|| e
->bDeviceClass
|| e
->bInterfaceClass
;
102 e
= (void *)e
+ i
->usb_size
)
103 output_usb_entry(e
, shortname
, out
, i
->conv
);
107 static void output_ieee1394_entry(struct ieee1394_device_id
*fw
, char *name
,
110 fprintf(out
, "%-20s 0x%08x 0x%06x 0x%06x 0x%06x 0x%06x\n",
112 END(fw
->match_flags
, conv
),
113 END(fw
->vendor_id
, conv
),
114 END(fw
->model_id
, conv
),
115 END(fw
->specifier_id
, conv
),
116 END(fw
->version
, conv
));
119 void output_ieee1394_table(struct module
*modules
, FILE *out
, char *dirname
)
123 fprintf(out
, "# ieee1394 module ");
124 fprintf(out
, "match_flags vendor_id model_id specifier_id version\n");
126 for (i
= modules
; i
; i
= i
->next
) {
127 struct ieee1394_device_id
*fw
;
128 char shortname
[strlen(i
->pathname
) + 1];
130 if (!i
->ieee1394_table
)
133 make_shortname(shortname
, i
->pathname
);
134 for (fw
= i
->ieee1394_table
; fw
->match_flags
;
135 fw
= (void *) fw
+ i
->ieee1394_size
)
136 output_ieee1394_entry(fw
, shortname
, out
, i
->conv
);
141 /* We set driver_data to zero */
142 static void output_ccw_entry(struct ccw_device_id
*ccw
, char *name
, FILE *out
,
145 fprintf(out
, "%-20s 0x%04x 0x%04x 0x%02x 0x%04x 0x%02x\n",
146 name
, END(ccw
->match_flags
, conv
),
147 END(ccw
->cu_type
, conv
), END(ccw
->cu_model
, conv
),
148 END(ccw
->dev_type
, conv
), END(ccw
->dev_model
, conv
));
151 void output_ccw_table(struct module
*modules
, FILE *out
, char *dirname
)
155 fprintf(out
, "# ccw module ");
156 fprintf(out
, "match_flags cu_type cu_model dev_type dev_model\n");
158 for (i
= modules
; i
; i
= i
->next
) {
159 struct ccw_device_id
*e
;
160 char shortname
[strlen(i
->pathname
) + 1];
165 make_shortname(shortname
, i
->pathname
);
166 for (e
= i
->ccw_table
;
167 e
->cu_type
|| e
->cu_model
|| e
->dev_type
|| e
->dev_model
;
168 e
= (void *) e
+ i
->ccw_size
)
169 output_ccw_entry(e
, shortname
, out
, i
->conv
);
173 #define ISAPNP_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\
174 ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
175 ((((c)-'A'+1)&0x1f)<<8))
176 #define ISAPNP_DEVICE(x) ((((x)&0xf000)>>8)|\
181 static void put_isapnp_id(FILE *out
, const char *id
)
183 unsigned short vendor
, device
;
185 vendor
= ISAPNP_VENDOR(id
[0], id
[1], id
[2]);
186 device
= (unsigned short)strtol(&id
[3], NULL
, 16);
187 device
= ISAPNP_DEVICE(device
);
188 fprintf(out
, " 0x%04x 0x%04x ", vendor
, device
);
191 void output_isapnp_table(struct module
*modules
, FILE *out
, char *dirname
)
195 fprintf(out
, "# isapnp module ");
196 fprintf(out
, "cardvendor carddevice driver_data vendor function ...\n");
198 for (i
= modules
; i
; i
= i
->next
) {
199 char shortname
[strlen(i
->pathname
) + 1];
202 struct pnp_device_id
*id
;
203 make_shortname(shortname
, i
->pathname
);
204 for (id
= i
->pnp_table
;
206 id
= (void *)id
+ i
->pnp_size
) {
207 fprintf(out
, "%-20s", shortname
);
208 fprintf(out
, " 0xffff 0xffff ");
209 fprintf(out
, " 0x00000000 "); /* driver_data */
210 put_isapnp_id(out
, id
->id
);
214 if (i
->pnp_card_table
) {
216 make_shortname(shortname
, i
->pathname
);
217 for (id
= i
->pnp_card_table
;
219 id
+= i
->pnp_card_size
) {
221 struct pnp_card_devid
*devid
222 = id
+ i
->pnp_card_offset
;
224 fprintf(out
, "%-20s", shortname
);
225 put_isapnp_id(out
, id
);
226 fprintf(out
, " 0x00000000 "); /* driver_data */
227 for (idx
= 0; idx
< 8; idx
++) {
228 if (!devid
->devid
[idx
][0])
230 put_isapnp_id(out
, devid
->devid
[idx
]);
238 #define MATCH_bustype 1
239 #define MATCH_vendor 2
240 #define MATCH_product 4
241 #define MATCH_version 8
243 #define MATCH_evbit 0x010
244 #define MATCH_keybit 0x020
245 #define MATCH_relbit 0x040
246 #define MATCH_absbit 0x080
247 #define MATCH_mscbit 0x100
248 #define MATCH_ledbit 0x200
249 #define MATCH_sndbit 0x400
250 #define MATCH_ffbit 0x800
251 #define MATCH_swbit 0x1000
253 #define MATCH(x) (END(input->match_flags, conv) & MATCH_ ## x)
254 #define PRINT_SCALAR(n) fprintf(out, " 0x%lx", MATCH(n) ? END(input->n, conv) : 0l)
255 #define PRINT_ARRAY64(n) do { \
258 output_input_bits_64(out, input->n, sizeof(input->n), conv); \
260 fprintf(out, "%d", 0); \
263 #define PRINT_ARRAY32(n) do { \
266 output_input_bits_32(out, input->n, sizeof(input->n), conv); \
268 fprintf(out, "%d", 0); \
271 static void output_input_bits_32(FILE *out
, unsigned int *bits
, int size
,
276 size
/= sizeof(*bits
);
277 for (i
= size
- 1; i
>= 0; i
--)
278 if (END(bits
[i
], conv
))
282 fprintf(out
, "%x", END(bits
[i
], conv
));
283 for (j
= i
- 1; j
>= 0; j
--)
284 fprintf(out
, ":%x", END(bits
[j
], conv
));
287 static void output_input_bits_64(FILE *out
, unsigned long long *bits
, int size
,
292 size
/= sizeof(*bits
);
293 for (i
= size
- 1; i
>= 0; i
--)
294 if (END(bits
[i
], conv
))
298 fprintf(out
, "%llx", END(bits
[i
], conv
));
299 for (j
= i
- 1; j
>= 0; j
--)
300 fprintf(out
, ":%llx", END(bits
[j
], conv
));
303 /* Formats are too different to */
304 static int output_input_entry_32(struct input_device_id_32
*input
,
305 char *name
, FILE *out
, int conv
)
307 if (!input
->match_flags
&& !input
->driver_info
)
310 fprintf(out
, "%-20s0x%x", name
, END(input
->match_flags
, conv
));
312 PRINT_SCALAR(bustype
);
313 PRINT_SCALAR(vendor
);
314 PRINT_SCALAR(product
);
315 PRINT_SCALAR(version
);
317 PRINT_ARRAY32(evbit
);
318 PRINT_ARRAY32(keybit
);
319 PRINT_ARRAY32(relbit
);
320 PRINT_ARRAY32(absbit
);
321 PRINT_ARRAY32(mscbit
);
322 PRINT_ARRAY32(ledbit
);
323 PRINT_ARRAY32(sndbit
);
324 PRINT_ARRAY32(ffbit
);
325 PRINT_ARRAY32(swbit
);
327 fprintf(out
, " 0x%x\n", END(input
->driver_info
, conv
));
331 static int output_input_entry_32_old(struct input_device_id_old_32
*input
,
332 char *name
, FILE *out
, int conv
)
334 if (!input
->match_flags
&& !input
->driver_info
)
337 fprintf(out
, "%-20s0x%x", name
, END(input
->match_flags
, conv
));
339 PRINT_SCALAR(bustype
);
340 PRINT_SCALAR(vendor
);
341 PRINT_SCALAR(product
);
342 PRINT_SCALAR(version
);
344 PRINT_ARRAY32(evbit
);
345 PRINT_ARRAY32(keybit
);
346 PRINT_ARRAY32(relbit
);
347 PRINT_ARRAY32(absbit
);
348 PRINT_ARRAY32(mscbit
);
349 PRINT_ARRAY32(ledbit
);
350 PRINT_ARRAY32(sndbit
);
351 PRINT_ARRAY32(ffbit
);
353 fprintf(out
, " 0x%x\n", END(input
->driver_info
, conv
));
357 static int output_input_entry_64(struct input_device_id_64
*input
,
358 char *name
, FILE *out
, int conv
)
360 if (!input
->match_flags
&& !input
->driver_info
)
363 fprintf(out
, "%-20s0x%llx", name
, END(input
->match_flags
, conv
));
365 PRINT_SCALAR(bustype
);
366 PRINT_SCALAR(vendor
);
367 PRINT_SCALAR(product
);
368 PRINT_SCALAR(version
);
370 PRINT_ARRAY64(evbit
);
371 PRINT_ARRAY64(keybit
);
372 PRINT_ARRAY64(relbit
);
373 PRINT_ARRAY64(absbit
);
374 PRINT_ARRAY64(mscbit
);
375 PRINT_ARRAY64(ledbit
);
376 PRINT_ARRAY64(sndbit
);
377 PRINT_ARRAY64(ffbit
);
378 PRINT_ARRAY64(swbit
);
380 fprintf(out
, " 0x%llx\n", END(input
->driver_info
, conv
));
384 static int output_input_entry_64_old(struct input_device_id_old_64
*input
,
385 char *name
, FILE *out
, int conv
)
387 if (!input
->match_flags
&& !input
->driver_info
)
390 fprintf(out
, "%-20s0x%llx", name
, END(input
->match_flags
, conv
));
392 PRINT_SCALAR(bustype
);
393 PRINT_SCALAR(vendor
);
394 PRINT_SCALAR(product
);
395 PRINT_SCALAR(version
);
397 PRINT_ARRAY64(evbit
);
398 PRINT_ARRAY64(keybit
);
399 PRINT_ARRAY64(relbit
);
400 PRINT_ARRAY64(absbit
);
401 PRINT_ARRAY64(mscbit
);
402 PRINT_ARRAY64(ledbit
);
403 PRINT_ARRAY64(sndbit
);
404 PRINT_ARRAY64(ffbit
);
406 fprintf(out
, " 0x%llx\n", END(input
->driver_info
, conv
));
410 void output_input_table(struct module
*modules
, FILE *out
, char *dirname
)
414 fprintf(out
, "# module matchBits");
415 fprintf(out
, " bustype vendor product version evBits keyBits relBits");
416 fprintf(out
, " absBits mscBits ledBits sndBits ffBits [swBits] driver_info\n");
418 for (i
= modules
; i
; i
= i
->next
) {
420 char shortname
[strlen(i
->pathname
) + 1];
426 make_shortname(shortname
, i
->pathname
);
427 /* Guess what size it really is, based on size of
428 * whole table. Table changed in 2.6.14. This is a hack. */
429 if (i
->input_size
== sizeof(struct input_device_id_old_64
)) {
430 if ((i
->input_table_size
% i
->input_size
) != 0) {
432 = sizeof(struct input_device_id_64
);
435 if ((i
->input_table_size
% i
->input_size
) != 0) {
437 = sizeof(struct input_device_id_32
);
441 for (p
= i
->input_table
; !done
; p
+= i
->input_size
) {
442 switch (i
->input_size
) {
443 case sizeof(struct input_device_id_old_64
):
444 done
= output_input_entry_64_old(p
,
449 case sizeof(struct input_device_id_64
):
450 done
= output_input_entry_64(p
, shortname
,
453 case sizeof(struct input_device_id_old_32
):
454 done
= output_input_entry_32_old(p
,
459 case sizeof(struct input_device_id_32
):
460 done
= output_input_entry_32(p
, shortname
,
468 static void output_serio_entry(struct serio_device_id
*serio
, char *name
, FILE *out
)
471 "%-20s 0x%02x 0x%02x 0x%02x 0x%02x\n",
480 void output_serio_table(struct module
*modules
, FILE *out
, char *dirname
)
484 fprintf(out
, "# serio module type extra id proto\n");
486 for (i
= modules
; i
; i
= i
->next
) {
487 struct serio_device_id
*e
;
488 char shortname
[strlen(i
->pathname
) + 1];
493 make_shortname(shortname
, i
->pathname
);
494 for (e
= i
->serio_table
; e
->type
|| e
->proto
; e
= (void *)e
+ i
->serio_size
)
495 output_serio_entry(e
, shortname
, out
);
501 strip_whitespace (char *str
, char chr
)
506 for (i
= strlen (str
); i
>= 0; --i
)
511 /* We set driver_data to zero */
512 static void output_of_entry(struct of_device_id
*dev
, char *name
, FILE *out
)
514 char *ofname
= NULL
, *type
= NULL
, *compatible
= NULL
;
516 ofname
= strdup (dev
->name
);
517 strip_whitespace (ofname
, '_');
521 type
= strdup (dev
->type
);
522 strip_whitespace (type
, '_');
525 if (dev
->compatible
[0]) {
526 compatible
= strdup (dev
->compatible
);
527 strip_whitespace (compatible
, '_');
530 fprintf (out
, "%-20s %-20s %-20s %s\n",
531 name
, ofname
? ofname
: "*", type
? type
: "*",
532 compatible
? compatible
: "*");
539 void output_of_table(struct module
*modules
, FILE *out
, char *dirname
)
543 fprintf (out
, "# of module name type compatible\n");
544 for (i
= modules
; i
; i
= i
->next
) {
545 struct of_device_id
*e
;
546 char shortname
[strlen(i
->pathname
) + 1];
551 make_shortname(shortname
, i
->pathname
);
552 for (e
= i
->of_table
; e
->name
[0]|e
->type
[0]|e
->compatible
[0];
553 e
= (void *)e
+ i
->of_size
)
554 output_of_entry(e
, shortname
, out
);