Skip to content

Commit b2b32a1

Browse files
raagjadavrafaeljw
authored andcommitted
ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types
Now that we have _UID matching support for both integer and string types, we can support them into acpi_dev_hid_uid_match() helper as well. Signed-off-by: Raag Jadav <raag.jadav@intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 57b8543 commit b2b32a1

3 files changed

Lines changed: 24 additions & 36 deletions

File tree

drivers/acpi/utils.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -824,35 +824,6 @@ bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs)
824824
}
825825
EXPORT_SYMBOL(acpi_check_dsm);
826826

827-
/**
828-
* acpi_dev_hid_uid_match - Match device by supplied HID and UID
829-
* @adev: ACPI device to match.
830-
* @hid2: Hardware ID of the device.
831-
* @uid2: Unique ID of the device, pass NULL to not check _UID.
832-
*
833-
* Matches HID and UID in @adev with given @hid2 and @uid2. Absence of @uid2
834-
* will be treated as a match. If user wants to validate @uid2, it should be
835-
* done before calling this function.
836-
*
837-
* Returns:
838-
* - %true if matches or @uid2 is NULL.
839-
* - %false otherwise.
840-
*/
841-
bool acpi_dev_hid_uid_match(struct acpi_device *adev,
842-
const char *hid2, const char *uid2)
843-
{
844-
const char *hid1 = acpi_device_hid(adev);
845-
846-
if (strcmp(hid1, hid2))
847-
return false;
848-
849-
if (!uid2)
850-
return true;
851-
852-
return acpi_dev_uid_match(adev, uid2);
853-
}
854-
EXPORT_SYMBOL(acpi_dev_hid_uid_match);
855-
856827
/**
857828
* acpi_dev_uid_to_integer - treat ACPI device _UID as integer
858829
* @adev: ACPI device to get _UID from

include/acpi/acpi_bus.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,9 +764,15 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
764764
adev->power.states[ACPI_STATE_D3_HOT].flags.explicit_set);
765765
}
766766

767-
bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2);
768767
int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer);
769768

769+
static inline bool acpi_dev_hid_match(struct acpi_device *adev, const char *hid2)
770+
{
771+
const char *hid1 = acpi_device_hid(adev);
772+
773+
return hid1 && hid2 && !strcmp(hid1, hid2);
774+
}
775+
770776
static inline bool acpi_str_uid_match(struct acpi_device *adev, const char *uid2)
771777
{
772778
const char *uid1 = acpi_device_uid(adev);
@@ -807,6 +813,22 @@ static inline bool acpi_int_uid_match(struct acpi_device *adev, u64 uid2)
807813
/* Treat as an integer otherwise */ \
808814
default: acpi_int_uid_match)(adev, uid2)
809815

816+
/**
817+
* acpi_dev_hid_uid_match - Match device by supplied HID and UID
818+
* @adev: ACPI device to match.
819+
* @hid2: Hardware ID of the device.
820+
* @uid2: Unique ID of the device, pass 0 or NULL to not check _UID.
821+
*
822+
* Matches HID and UID in @adev with given @hid2 and @uid2. Absence of @uid2
823+
* will be treated as a match. If user wants to validate @uid2, it should be
824+
* done before calling this function.
825+
*
826+
* Returns: %true if matches or @uid2 is 0 or NULL, %false otherwise.
827+
*/
828+
#define acpi_dev_hid_uid_match(adev, hid2, uid2) \
829+
(acpi_dev_hid_match(adev, hid2) && \
830+
(!(uid2) || acpi_dev_uid_match(adev, uid2)))
831+
810832
void acpi_dev_clear_dependencies(struct acpi_device *supplier);
811833
bool acpi_dev_ready_for_enumeration(const struct acpi_device *device);
812834
struct acpi_device *acpi_dev_get_next_consumer_dev(struct acpi_device *supplier,

include/linux/acpi.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ const char *acpi_get_subsystem_id(acpi_handle handle);
758758

759759
/* Get rid of the -Wunused-variable for adev */
760760
#define acpi_dev_uid_match(adev, uid2) (adev && false)
761+
#define acpi_dev_hid_uid_match(adev, hid2, uid2) (adev && false)
761762

762763
#include <acpi/acpi_numa.h>
763764

@@ -775,12 +776,6 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
775776

776777
struct acpi_device;
777778

778-
static inline bool
779-
acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2)
780-
{
781-
return false;
782-
}
783-
784779
static inline int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer)
785780
{
786781
return -ENODEV;

0 commit comments

Comments
 (0)