From: Stefan Richter Date: Thu, 18 Mar 2010 23:38:29 +0000 Subject: [PATCH 1/2] firewire: core: fix Model_ID in modalias Message-Id: List-Id: References: <55a4f86e1003171546m11f7a502u648622d1d61793d6@mail.gmail.com> <55a4f86e1003171631i323fe5f8w55206efe7d9a5ed6@mail.gmail.com> In-Reply-To: <55a4f86e1003171631i323fe5f8w55206efe7d9a5ed6@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: linux1394-devel@lists.sourceforge.net Cc: =?iso-8859-2?Q?Maciej_=AFenczykowski?= , linux-hotplug@vger.kernel.org, linux-kernel@vger.kernel.org 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 =AFenczykowski Signed-off-by: Stefan Richter --- drivers/firewire/core-device.c | 40 ++++++++++++--------------------- 1 file changed, 14 insertions(+), 26 deletions(-) Index: b/drivers/firewire/core-device.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D--- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -180,44 +180,32 @@ static int fw_unit_match(struct device * return 0; } =20 -static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_= size) +static void get_modalias_ids(const u32 *directory, int *id) { - struct fw_device *device =3D fw_parent_device(unit); struct fw_csr_iterator ci; - int key, value; - int vendor =3D 0; - int model =3D 0; - int specifier_id =3D 0; - int version =3D 0; =20 - fw_csr_iterator_init(&ci, &device->config_rom[5]); + fw_csr_iterator_init(&ci, directory); while (fw_csr_iterator_next(&ci, &key, &value)) { switch (key) { - case CSR_VENDOR: - vendor =3D value; - break; - case CSR_MODEL: - model =3D value; - break; + case CSR_VENDOR: id[0] =3D value; break; + case CSR_MODEL: id[1] =3D value; break; + case CSR_SPECIFIER_ID: id[2] =3D value; break; + case CSR_VERSION: id[3] =3D value; break; } } +} =20 - fw_csr_iterator_init(&ci, unit->directory); - while (fw_csr_iterator_next(&ci, &key, &value)) { - switch (key) { - case CSR_SPECIFIER_ID: - specifier_id =3D value; - break; - case CSR_VERSION: - version =3D value; - break; - } - } +static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_= size) +{ + int id[] =3D {0, 0, 0, 0}; + + get_modalias_ids(&fw_parent_device(unit)->config_rom[5], id); + get_modalias_ids(unit->directory, id); =20 return snprintf(buffer, buffer_size, "ieee1394:ven%08Xmo%08Xsp%08Xver%08X", - vendor, model, specifier_id, version); + id[0], id[1], id[2], id[3]); } =20 static int fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env) --=20 Stefan Richter -=3D=3D=3D-=3D-=3D- --=3D =3D--=3D http://arcgraph.de/sr/