Commit ac551828993eecb8499ef9cc3c828fceb49bcf7a
Committed by
Sam Ravnborg
1 parent
afa26be86b
Exists in
master
and in
4 other branches
modpost: i2c aliases need no trailing wildcard
Not all device types need a wildcard at the end of their module aliases. In particular, for i2c module aliases, the trailing wildcard is not only unneeded, it could also cause the wrong driver to be loaded. As I2C devices have no IDs, i2c module aliases are simple, arbitrary device names. For example: $ /sbin/modinfo lm90 filename: /lib/modules/2.6.25-git18/kernel/drivers/hwmon/lm90.ko author: Jean Delvare <khali@linux-fr.org> description: LM90/ADM1032 driver license: GPL vermagic: 2.6.25-git18 mod_unload depends: hwmon alias: i2c:lm90* alias: i2c:adm1032* alias: i2c:lm99* alias: i2c:lm86* alias: i2c:max6657* alias: i2c:adt7461* alias: i2c:max6680* $ This would cause trouble if one I2C chip name matches the beginning of another I2C chip name and both chips are supported by different drivers. For example, an i2c device named lm9042 would cause the lm90 driver to be loaded, while it doesn't support that device. This case has yet to be seen in practice, but still, I'd like to fix it now. The cleanest fix is to remove the trailing wildcard from i2c module aliases. Here's a patch doing this. Not all device type aliases need a trailing wildcard, in particular the i2c aliases don't. Don't add a wildcard by default in do_table(), instead let each device type handler add it if needed. I have tested types acpi, dmi, eisa, i2c, ide, ieee1394, input, pci, pcmcia, platform, pnp, scsi, serio, ssb and usb. Other types (ccw, of, vio, parisc, sdio and virtio) are untested. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Jochen Friedrich <jochen@scram.de> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Showing 1 changed file with 26 additions and 9 deletions Side-by-side Diff
scripts/mod/file2alias.c
... | ... | @@ -51,6 +51,15 @@ |
51 | 51 | sprintf(str + strlen(str), "*"); \ |
52 | 52 | } while(0) |
53 | 53 | |
54 | +/* Always end in a wildcard, for future extension */ | |
55 | +static inline void add_wildcard(char *str) | |
56 | +{ | |
57 | + int len = strlen(str); | |
58 | + | |
59 | + if (str[len - 1] != '*') | |
60 | + strcat(str + len, "*"); | |
61 | +} | |
62 | + | |
54 | 63 | unsigned int cross_build = 0; |
55 | 64 | /** |
56 | 65 | * Check that sizeof(device_id type) are consistent with size of section |
... | ... | @@ -133,9 +142,7 @@ |
133 | 142 | id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL, |
134 | 143 | id->bInterfaceProtocol); |
135 | 144 | |
136 | - /* Always end in a wildcard, for future extension */ | |
137 | - if (alias[strlen(alias)-1] != '*') | |
138 | - strcat(alias, "*"); | |
145 | + add_wildcard(alias); | |
139 | 146 | buf_printf(&mod->dev_table_buf, |
140 | 147 | "MODULE_ALIAS(\"%s\");\n", alias); |
141 | 148 | } |
... | ... | @@ -219,6 +226,7 @@ |
219 | 226 | ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION, |
220 | 227 | id->version); |
221 | 228 | |
229 | + add_wildcard(alias); | |
222 | 230 | return 1; |
223 | 231 | } |
224 | 232 | |
... | ... | @@ -261,6 +269,7 @@ |
261 | 269 | ADD(alias, "bc", baseclass_mask == 0xFF, baseclass); |
262 | 270 | ADD(alias, "sc", subclass_mask == 0xFF, subclass); |
263 | 271 | ADD(alias, "i", interface_mask == 0xFF, interface); |
272 | + add_wildcard(alias); | |
264 | 273 | return 1; |
265 | 274 | } |
266 | 275 | |
... | ... | @@ -283,6 +292,7 @@ |
283 | 292 | id->dev_type); |
284 | 293 | ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL, |
285 | 294 | id->dev_model); |
295 | + add_wildcard(alias); | |
286 | 296 | return 1; |
287 | 297 | } |
288 | 298 | |
... | ... | @@ -290,7 +300,7 @@ |
290 | 300 | static int do_ap_entry(const char *filename, |
291 | 301 | struct ap_device_id *id, char *alias) |
292 | 302 | { |
293 | - sprintf(alias, "ap:t%02X", id->dev_type); | |
303 | + sprintf(alias, "ap:t%02X*", id->dev_type); | |
294 | 304 | return 1; |
295 | 305 | } |
296 | 306 | |
... | ... | @@ -309,6 +319,7 @@ |
309 | 319 | ADD(alias, "id", id->id != SERIO_ANY, id->id); |
310 | 320 | ADD(alias, "ex", id->extra != SERIO_ANY, id->extra); |
311 | 321 | |
322 | + add_wildcard(alias); | |
312 | 323 | return 1; |
313 | 324 | } |
314 | 325 | |
... | ... | @@ -316,7 +327,7 @@ |
316 | 327 | static int do_acpi_entry(const char *filename, |
317 | 328 | struct acpi_device_id *id, char *alias) |
318 | 329 | { |
319 | - sprintf(alias, "acpi*:%s:", id->id); | |
330 | + sprintf(alias, "acpi*:%s:*", id->id); | |
320 | 331 | return 1; |
321 | 332 | } |
322 | 333 | |
... | ... | @@ -324,7 +335,7 @@ |
324 | 335 | static int do_pnp_entry(const char *filename, |
325 | 336 | struct pnp_device_id *id, char *alias) |
326 | 337 | { |
327 | - sprintf(alias, "pnp:d%s", id->id); | |
338 | + sprintf(alias, "pnp:d%s*", id->id); | |
328 | 339 | return 1; |
329 | 340 | } |
330 | 341 | |
... | ... | @@ -409,6 +420,7 @@ |
409 | 420 | ADD(alias, "pc", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, id->prod_id_hash[2]); |
410 | 421 | ADD(alias, "pd", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, id->prod_id_hash[3]); |
411 | 422 | |
423 | + add_wildcard(alias); | |
412 | 424 | return 1; |
413 | 425 | } |
414 | 426 | |
... | ... | @@ -432,6 +444,7 @@ |
432 | 444 | if (isspace (*tmp)) |
433 | 445 | *tmp = '_'; |
434 | 446 | |
447 | + add_wildcard(alias); | |
435 | 448 | return 1; |
436 | 449 | } |
437 | 450 | |
... | ... | @@ -448,6 +461,7 @@ |
448 | 461 | if (isspace (*tmp)) |
449 | 462 | *tmp = '_'; |
450 | 463 | |
464 | + add_wildcard(alias); | |
451 | 465 | return 1; |
452 | 466 | } |
453 | 467 | |
... | ... | @@ -511,6 +525,8 @@ |
511 | 525 | { |
512 | 526 | if (eisa->sig[0]) |
513 | 527 | sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", eisa->sig); |
528 | + else | |
529 | + strcat(alias, "*"); | |
514 | 530 | return 1; |
515 | 531 | } |
516 | 532 | |
... | ... | @@ -529,6 +545,7 @@ |
529 | 545 | ADD(alias, "rev", id->hversion_rev != PA_HVERSION_REV_ANY_ID, id->hversion_rev); |
530 | 546 | ADD(alias, "sv", id->sversion != PA_SVERSION_ANY_ID, id->sversion); |
531 | 547 | |
548 | + add_wildcard(alias); | |
532 | 549 | return 1; |
533 | 550 | } |
534 | 551 | |
... | ... | @@ -544,6 +561,7 @@ |
544 | 561 | ADD(alias, "c", id->class != (__u8)SDIO_ANY_ID, id->class); |
545 | 562 | ADD(alias, "v", id->vendor != (__u16)SDIO_ANY_ID, id->vendor); |
546 | 563 | ADD(alias, "d", id->device != (__u16)SDIO_ANY_ID, id->device); |
564 | + add_wildcard(alias); | |
547 | 565 | return 1; |
548 | 566 | } |
549 | 567 | |
... | ... | @@ -559,6 +577,7 @@ |
559 | 577 | ADD(alias, "v", id->vendor != SSB_ANY_VENDOR, id->vendor); |
560 | 578 | ADD(alias, "id", id->coreid != SSB_ANY_ID, id->coreid); |
561 | 579 | ADD(alias, "rev", id->revision != SSB_ANY_REV, id->revision); |
580 | + add_wildcard(alias); | |
562 | 581 | return 1; |
563 | 582 | } |
564 | 583 | |
... | ... | @@ -573,6 +592,7 @@ |
573 | 592 | ADD(alias, "d", 1, id->device); |
574 | 593 | ADD(alias, "v", id->vendor != VIRTIO_DEV_ANY_ID, id->vendor); |
575 | 594 | |
595 | + add_wildcard(alias); | |
576 | 596 | return 1; |
577 | 597 | } |
578 | 598 | |
... | ... | @@ -612,9 +632,6 @@ |
612 | 632 | |
613 | 633 | for (i = 0; i < size; i += id_size) { |
614 | 634 | if (do_entry(mod->name, symval+i, alias)) { |
615 | - /* Always end in a wildcard, for future extension */ | |
616 | - if (alias[strlen(alias)-1] != '*') | |
617 | - strcat(alias, "*"); | |
618 | 635 | buf_printf(&mod->dev_table_buf, |
619 | 636 | "MODULE_ALIAS(\"%s\");\n", alias); |
620 | 637 | } |