diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index fd4c025a3f70..0547253d16fe 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -153,8 +153,25 @@ static void get_ids(const u32 *directory, int *id) static void get_modalias_ids(const struct fw_unit *unit, int *id) { - get_ids(&fw_parent_device(unit)->config_rom[ROOT_DIR_OFFSET], id); - get_ids(unit->directory, id); + const u32 *root_directory = &fw_parent_device(unit)->config_rom[ROOT_DIR_OFFSET]; + const u32 *directories[] = {NULL, NULL, NULL}; + const u32 *vendor_directory; + int i; + + directories[0] = root_directory; + + // Legacy layout of configuration ROM described in Annex 1 of 'Configuration ROM for AV/C + // Devices 1.0 (December 12, 2000, 1394 Trading Association, TA Document 1999027)'. + vendor_directory = search_directory(root_directory, CSR_VENDOR); + if (!vendor_directory) { + directories[1] = unit->directory; + } else { + directories[1] = vendor_directory; + directories[2] = unit->directory; + } + + for (i = 0; i < ARRAY_SIZE(directories) && !!directories[i]; ++i) + get_ids(directories[i], id); } static bool match_ids(const struct ieee1394_device_id *id_table, int *id) diff --git a/drivers/firewire/device-attribute-test.c b/drivers/firewire/device-attribute-test.c index da2a4a09bf84..2f123c6b0a16 100644 --- a/drivers/firewire/device-attribute-test.c +++ b/drivers/firewire/device-attribute-test.c @@ -178,7 +178,7 @@ static void device_attr_legacy_avc(struct kunit *test) }; struct device *node_dev = (struct device *)&node.device; struct device *unit0_dev = (struct device *)&unit0.device; - static const int unit0_expected_ids[] = {0x00012345, 0x00000000, 0x00abcdef, 0x00543210}; + static const int unit0_expected_ids[] = {0x00012345, 0x00fedcba, 0x00abcdef, 0x00543210}; char *buf = kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL); int ids[4] = {0, 0, 0, 0};