Skip to contentSkip to conversation

ACPI / PNP: compare the string length in the matching_id

PATCH Applied Hui Wang 2 participants 2 messages Dec 11, 2020 – Dec 15, 2020 ACPI

lore
Share & tools
lore

Hui Wang

author
#0 lore raw

PATCH v4 1/1 ACPI / PNP: compare the string length in the matching_id

Recently we met a touchscreen problem on some Thinkpad machines, the touchscreen driver (i2c-hid) is not loaded and the touchscreen can't work.

An i2c ACPI device with the name WACF2200 is defined in the BIOS, with the current rule in matching_id(), this device will be regarded as a PNP device since there is WACFXXX in the acpi_pnp_device_ids[] and this PNP device is attached to the acpi device as the 1st physical_node, this will make the i2c bus match fail when i2c bus calls acpi_companion_match() to match the acpi_id_table in the i2c-hid driver.

WACF2200 is an i2c device instead of a PNP device, after adding the string length comparing, the matching_id() will return false when matching WACF2200 and WACFXXX, and it is reasonable to compare the string length when matching two ids.

---
Sorry, the v3 patch has mis-spelling word in the commit header, so fix it and send the v4 patch.

 drivers/acpi/acpi_pnp.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/acpi/acpi_pnp.c +3 -0
index 4ed755a963aa..8f2dc176bb41 100644
@@ -319,6 +319,9 @@ static bool matching_id(const char *idstr, const char *list_id)
 {
 	int i;
 
+	if (strlen(idstr) != strlen(list_id))
+		return false;
+
 	if (memcmp(idstr, list_id, 3))
 		return false;
 
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 32 lines · Hui Wang

Recently we met a touchscreen problem on some Thinkpad machines, the touchscreen driver (i2c-hid) is not loaded and the touchscreen can't work.

An i2c ACPI device with the name WACF2200 is defined in the BIOS, with the current rule in matching_id(), this device will be regarded as a PNP device since there is WACFXXX in the acpi_pnp_device_ids[] and this PNP device is attached to the acpi device as the 1st physical_node, this will make the i2c bus match fail when i2c bus calls acpi_companion_match() to match the acpi_id_table in the i2c-hid driver.

WACF2200 is an i2c device instead of a PNP device, after adding the string length comparing, the matching_id() will return false when matching WACF2200 and WACFXXX, and it is reasonable to compare the string length when matching two ids.

---
Sorry, the v3 patch has mis-spelling word in the commit header, so fix it and send the v4 patch.

 drivers/acpi/acpi_pnp.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/acpi/acpi_pnp.c +0 -0
index 4ed755a963aa..8f2dc176bb41 100644

drivers/acpi/acpi_pnp.c static bool matching_id(const char *idstr, const char *list_id)

Quoted 10 lines
drivers/acpi/acpi_pnp.c +3 -1
@@ -319,6 +319,9 @@ static bool matching_id(const char *idstr, const char *list_id)
 {
        int i;
 
+       if (strlen(idstr) != strlen(list_id))
+               return false;
+
        if (memcmp(idstr, list_id, 3))
                return false;
 
--

Applied as 5.11-rc material, thanks!