Skip to contentSkip to conversation

ACPI: bus: allow _UID matching for integer zero

PATCH In review Raag Jadav 3 participants 4 messages Mar 28, 2024 – Apr 10, 2024

Subsystems (2)
lore
Share & tools
lore

Raag Jadav

author
#0 lore raw

PATCH 1/1 ACPI: bus: allow _UID matching for integer zero

Commit b2b32a173881 ("ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types") added _UID matching support for both integer and string types, which satisfies NULL @uid2 argument for string types using inversion, but this logic prevents _UID comparision in case the argument is integer 0, which may result in false positives.

Fix this using _Generic(), which will allow NULL @uid2 argument for string types as well as _UID matching for all possible integer values.

Fixes b2b32a173881 ("ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types")
---
 include/acpi/acpi_bus.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
include/acpi/acpi_bus.h +5 -3
index 5de954e2b18a..683458de5a81 100644
@@ -911,17 +911,19 @@ static inline bool acpi_int_uid_match(struct acpi_device *adev, u64 uid2)
  * acpi_dev_hid_uid_match - Match device by supplied HID and UID
  * @adev: ACPI device to match.
  * @hid2: Hardware ID of the device.
- * @uid2: Unique ID of the device, pass 0 or NULL to not check _UID.
+ * @uid2: Unique ID of the device, pass NULL to not check _UID.
  *
  * Matches HID and UID in @adev with given @hid2 and @uid2. Absence of @uid2
  * will be treated as a match. If user wants to validate @uid2, it should be
  * done before calling this function.
  *
- * Returns: %true if matches or @uid2 is 0 or NULL, %false otherwise.
+ * Returns: %true if matches or @uid2 is NULL, %false otherwise.
  */
 #define acpi_dev_hid_uid_match(adev, hid2, uid2)			\
 	(acpi_dev_hid_match(adev, hid2) &&				\
-		(!(uid2) || acpi_dev_uid_match(adev, uid2)))
+		/* Differentiate integer 0 from NULL @uid2 */		\
+		(_Generic(uid2,	ACPI_STR_TYPES(!(uid2)), default: 0) ||	\
+		acpi_dev_uid_match(adev, uid2)))
 
 void acpi_dev_clear_dependencies(struct acpi_device *supplier);
 bool acpi_dev_ready_for_enumeration(const struct acpi_device *device);
Signature · 1 line
2.35.3
author
#1 lore raw
Quoted 11 lines · Raag Jadav

Commit b2b32a173881 ("ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types") added _UID matching support for both integer and string types, which satisfies NULL @uid2 argument for string types using inversion, but this logic prevents _UID comparision in case the argument is integer 0, which may result in false positives.

Fix this using _Generic(), which will allow NULL @uid2 argument for string types as well as _UID matching for all possible integer values.

Fixes b2b32a173881 ("ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types")

Bump.

Anything I can do to move this forward?

Raag

#2 lore raw
Quoted 11 lines · Raag Jadav
Quoted 9 lines · Raag Jadav

Commit b2b32a173881 ("ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types") added _UID matching support for both integer and string types, which satisfies NULL @uid2 argument for string types using inversion, but this logic prevents _UID comparision in case the argument is integer 0, which may result in false positives.

Fix this using _Generic(), which will allow NULL @uid2 argument for string types as well as _UID matching for all possible integer values.

Quoted 6 lines
Quoted 2 lines
Fixes b2b32a173881 ("ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types")

Bump.

Anything I can do to move this forward?

Should be there in linux-next already, isn't it?

Maybe I forgot to send an "applied" message.

Reviewed-by on v1 1/1
#3 lore raw
In reply to Raag Jadav
Quoted 4 lines · Raag Jadav

Commit b2b32a173881 ("ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types") added _UID matching support for both integer and string types, which satisfies NULL @uid2 argument for string types using inversion, but this logic prevents _UID comparision in case the

                                                ^^^^^^^^^^^

Typo: comparison

Quoted 7 lines

argument is integer 0, which may result in false positives.

Fix this using _Generic(), which will allow NULL @uid2 argument for string types as well as _UID matching for all possible integer values.

Fixes b2b32a173881 ("ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types")