Skip to content

Commit 986c20b

Browse files
committed
firewire: core: fill model field in modalias of unit device for legacy layout of configuration ROM
As the last part of support for legacy layout of configuration ROM, this commit traverses vendor directory as well as root directory when constructing modalias for unit device. The change brings loss of backward compatibility since it can fill model field ('mo') which is 0 at current implementation in the case. However, we can be optimistic against regression for unit drivers in kernel, due to some points: 1. ALSA drivers for audio and music units use the model fields to match device, however all of supported devices does not have such legacy layout. 2. the other unit drivers (e.g. sbp2) does not use the model field to match device. The rest of concern is user space application. The most of applications just take care of node device and does not use the modalias of unit device, thus the change does not affect to them. But systemd project is known to get affects from the change since it includes hwdb to take udev to configure fw character device conveniently. I have a plan to work for systemd so that the access permission of character device could be kept across the change. Suggested-by: Adam Goldman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Sakamoto <[email protected]>
1 parent 2eab8bc commit 986c20b

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

drivers/firewire/core-device.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,25 @@ static void get_ids(const u32 *directory, int *id)
153153

154154
static void get_modalias_ids(const struct fw_unit *unit, int *id)
155155
{
156-
get_ids(&fw_parent_device(unit)->config_rom[ROOT_DIR_OFFSET], id);
157-
get_ids(unit->directory, id);
156+
const u32 *root_directory = &fw_parent_device(unit)->config_rom[ROOT_DIR_OFFSET];
157+
const u32 *directories[] = {NULL, NULL, NULL};
158+
const u32 *vendor_directory;
159+
int i;
160+
161+
directories[0] = root_directory;
162+
163+
// Legacy layout of configuration ROM described in Annex 1 of 'Configuration ROM for AV/C
164+
// Devices 1.0 (December 12, 2000, 1394 Trading Association, TA Document 1999027)'.
165+
vendor_directory = search_directory(root_directory, CSR_VENDOR);
166+
if (!vendor_directory) {
167+
directories[1] = unit->directory;
168+
} else {
169+
directories[1] = vendor_directory;
170+
directories[2] = unit->directory;
171+
}
172+
173+
for (i = 0; i < ARRAY_SIZE(directories) && !!directories[i]; ++i)
174+
get_ids(directories[i], id);
158175
}
159176

160177
static bool match_ids(const struct ieee1394_device_id *id_table, int *id)

drivers/firewire/device-attribute-test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static void device_attr_legacy_avc(struct kunit *test)
178178
};
179179
struct device *node_dev = (struct device *)&node.device;
180180
struct device *unit0_dev = (struct device *)&unit0.device;
181-
static const int unit0_expected_ids[] = {0x00012345, 0x00000000, 0x00abcdef, 0x00543210};
181+
static const int unit0_expected_ids[] = {0x00012345, 0x00fedcba, 0x00abcdef, 0x00543210};
182182
char *buf = kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL);
183183
int ids[4] = {0, 0, 0, 0};
184184

0 commit comments

Comments
 (0)