[PATCH] firewire: core: mask previous entry's type bits when looking for leaf
Brought to you by:
aeb,
bencollins
From: Adam G. <ad...@po...> - 2024-01-25 12:15:26
|
When searching a configuration ROM directory for a leaf corresponding to a specific key_ID, disregard the type bits of the directory entry. The configuration ROM of FireWire devices can contain textual descriptor leafs (strings) for vendor name and model name. We use these to populate the vendor_name and model_name entries in sysfs. Each descriptor leaf has a descriptor directory entry pointing to it. The identity of the descriptor leaf is indicated by the key_ID of the directory entry immediately before the descriptor leaf's directory entry. The key_ID is the low 6 bits of the high byte of the directory entry, and the type is the high 2 bits. In most cases, the directory entry before a descriptor directory entry will be an immediate value (type=0). However, it is also valid for it to be a directory (type=3). Thus, when looking for a specific leaf, we must mask off the type bits and compare only the key_ID. One affected device is the Sony DVMC-DA1, which is missing the vendor_name sysfs entry without this change. The recent commit 141d9c6e003b806d8faeddeec7053ee2691ea61a fixed missing model and model_name entries for the DVMC-DA1, but those were caused by a different issue. Signed-Off-By: Adam Goldman <ad...@po...> --- --- linux-6.8-rc1.orig/drivers/firewire/core-device.c 2024-01-21 14:11:32.000000000 -0800 +++ linux-6.8-rc1/drivers/firewire/core-device.c 2024-01-24 03:56:56.000000000 -0800 @@ -72,7 +72,7 @@ fw_csr_iterator_init(&ci, directory); while (fw_csr_iterator_next(&ci, &key, &value)) { - if (last_key == search_key && + if ((last_key & 0x3f) == search_key && key == (CSR_DESCRIPTOR | CSR_LEAF)) return ci.p - 1 + value; |