Skip to content

Commit 5ae7351

Browse files
author
Stefan Richter
committed
firewire: core: fix Model_ID in modalias
The modalias string of devices that represent units on a FireWire node did not show Module_ID entries within unit directories. This was because firewire-core searched only the root directory of the configuration ROM for a Model_ID entry. We now search first the root directory, then the unit directory. IOW honor a unit directory's Model_ID if present, otherwise fall back to the root directory's model ID (if present). Furthermore, apply the same change to Vendor_ID. This had the same issue but it was less apparent because most devices provide Vendor_ID only in the root directory. And finally, also use this strategy for the remaining two IDs in the modalias, Specifier_ID and Version. It does not actually make sense to look for them elsewhere than in the unit directory because they are mandatory there. However, a uniform search order simplifies the implementation and has no adverse affect in practice. Side notes: - The older counterpart of this, nodemgr.c of ieee1394, looked for Vendor_ID first in the root directory, then in the unit directory, and for Model_ID only in the unit directory. - There is a single mainline driver which requires Vendor_ID and Model_ID --- the firedtv driver. This one worked because FireDTVs provide Vendor_ID in the root directory and Model_ID identically in root directory and unit directory. - Apart from firedtv, there are currently no drivers known to me (including userspace drivers) that look at the Vendor_ID or Model_ID of the modalias. Reported-by: Maciej Żenczykowski <zenczykowski@gmail.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
1 parent 8301b91 commit 5ae7351

1 file changed

Lines changed: 14 additions & 26 deletions

File tree

‎drivers/firewire/core-device.c‎

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -180,44 +180,32 @@ static int fw_unit_match(struct device *dev, struct device_driver *drv)
180180
return 0;
181181
}
182182

183-
static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size)
183+
static void get_modalias_ids(const u32 *directory, int *id)
184184
{
185-
struct fw_device *device = fw_parent_device(unit);
186185
struct fw_csr_iterator ci;
187-
188186
int key, value;
189-
int vendor = 0;
190-
int model = 0;
191-
int specifier_id = 0;
192-
int version = 0;
193187

194-
fw_csr_iterator_init(&ci, &device->config_rom[5]);
188+
fw_csr_iterator_init(&ci, directory);
195189
while (fw_csr_iterator_next(&ci, &key, &value)) {
196190
switch (key) {
197-
case CSR_VENDOR:
198-
vendor = value;
199-
break;
200-
case CSR_MODEL:
201-
model = value;
202-
break;
191+
case CSR_VENDOR: id[0] = value; break;
192+
case CSR_MODEL: id[1] = value; break;
193+
case CSR_SPECIFIER_ID: id[2] = value; break;
194+
case CSR_VERSION: id[3] = value; break;
203195
}
204196
}
197+
}
205198

206-
fw_csr_iterator_init(&ci, unit->directory);
207-
while (fw_csr_iterator_next(&ci, &key, &value)) {
208-
switch (key) {
209-
case CSR_SPECIFIER_ID:
210-
specifier_id = value;
211-
break;
212-
case CSR_VERSION:
213-
version = value;
214-
break;
215-
}
216-
}
199+
static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size)
200+
{
201+
int id[] = {0, 0, 0, 0};
202+
203+
get_modalias_ids(&fw_parent_device(unit)->config_rom[5], id);
204+
get_modalias_ids(unit->directory, id);
217205

218206
return snprintf(buffer, buffer_size,
219207
"ieee1394:ven%08Xmo%08Xsp%08Xver%08X",
220-
vendor, model, specifier_id, version);
208+
id[0], id[1], id[2], id[3]);
221209
}
222210

223211
static int fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env)

0 commit comments

Comments
 (0)