Skip to content

Commit 3814876

Browse files
committed
Merge back earlier acpi-utils material for v6.8.
2 parents 8f0b960 + 38dd7b7 commit 3814876

File tree

6 files changed

+74
-81
lines changed

6 files changed

+74
-81
lines changed

drivers/acpi/acpi_lpss.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,9 @@ static struct pwm_lookup byt_pwm_lookup[] = {
167167

168168
static void byt_pwm_setup(struct lpss_private_data *pdata)
169169
{
170-
u64 uid;
171-
172170
/* Only call pwm_add_table for the first PWM controller */
173-
if (acpi_dev_uid_to_integer(pdata->adev, &uid) || uid != 1)
174-
return;
175-
176-
pwm_add_table(byt_pwm_lookup, ARRAY_SIZE(byt_pwm_lookup));
171+
if (acpi_dev_uid_match(pdata->adev, 1))
172+
pwm_add_table(byt_pwm_lookup, ARRAY_SIZE(byt_pwm_lookup));
177173
}
178174

179175
#define LPSS_I2C_ENABLE 0x6c
@@ -218,13 +214,9 @@ static struct pwm_lookup bsw_pwm_lookup[] = {
218214

219215
static void bsw_pwm_setup(struct lpss_private_data *pdata)
220216
{
221-
u64 uid;
222-
223217
/* Only call pwm_add_table for the first PWM controller */
224-
if (acpi_dev_uid_to_integer(pdata->adev, &uid) || uid != 1)
225-
return;
226-
227-
pwm_add_table(bsw_pwm_lookup, ARRAY_SIZE(bsw_pwm_lookup));
218+
if (acpi_dev_uid_match(pdata->adev, 1))
219+
pwm_add_table(bsw_pwm_lookup, ARRAY_SIZE(bsw_pwm_lookup));
228220
}
229221

230222
static const struct property_entry lpt_spi_properties[] = {

drivers/acpi/utils.c

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -824,54 +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_uid_match - Match device by supplied UID
829-
* @adev: ACPI device to match.
830-
* @uid2: Unique ID of the device.
831-
*
832-
* Matches UID in @adev with given @uid2.
833-
*
834-
* Returns:
835-
* - %true if matches.
836-
* - %false otherwise.
837-
*/
838-
bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2)
839-
{
840-
const char *uid1 = acpi_device_uid(adev);
841-
842-
return uid1 && uid2 && !strcmp(uid1, uid2);
843-
}
844-
EXPORT_SYMBOL_GPL(acpi_dev_uid_match);
845-
846-
/**
847-
* acpi_dev_hid_uid_match - Match device by supplied HID and UID
848-
* @adev: ACPI device to match.
849-
* @hid2: Hardware ID of the device.
850-
* @uid2: Unique ID of the device, pass NULL to not check _UID.
851-
*
852-
* Matches HID and UID in @adev with given @hid2 and @uid2. Absence of @uid2
853-
* will be treated as a match. If user wants to validate @uid2, it should be
854-
* done before calling this function.
855-
*
856-
* Returns:
857-
* - %true if matches or @uid2 is NULL.
858-
* - %false otherwise.
859-
*/
860-
bool acpi_dev_hid_uid_match(struct acpi_device *adev,
861-
const char *hid2, const char *uid2)
862-
{
863-
const char *hid1 = acpi_device_hid(adev);
864-
865-
if (strcmp(hid1, hid2))
866-
return false;
867-
868-
if (!uid2)
869-
return true;
870-
871-
return acpi_dev_uid_match(adev, uid2);
872-
}
873-
EXPORT_SYMBOL(acpi_dev_hid_uid_match);
874-
875827
/**
876828
* acpi_dev_uid_to_integer - treat ACPI device _UID as integer
877829
* @adev: ACPI device to get _UID from

drivers/firmware/efi/dev-path-parser.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ static long __init parse_acpi_path(const struct efi_dev_path *node,
1818
struct acpi_device *adev;
1919
struct device *phys_dev;
2020
char hid[ACPI_ID_LEN];
21-
u64 uid;
22-
int ret;
2321

2422
if (node->header.length != 12)
2523
return -EINVAL;
@@ -31,10 +29,9 @@ static long __init parse_acpi_path(const struct efi_dev_path *node,
3129
node->acpi.hid >> 16);
3230

3331
for_each_acpi_dev_match(adev, hid, NULL, -1) {
34-
ret = acpi_dev_uid_to_integer(adev, &uid);
35-
if (ret == 0 && node->acpi.uid == uid)
32+
if (acpi_dev_uid_match(adev, node->acpi.uid))
3633
break;
37-
if (ret == -ENODATA && node->acpi.uid == 0)
34+
if (!acpi_device_uid(adev) && node->acpi.uid == 0)
3835
break;
3936
}
4037
if (!adev)

drivers/perf/arm_cspmu/arm_cspmu.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,6 @@ static int arm_cspmu_request_irq(struct arm_cspmu *cspmu)
11081108

11091109
static inline int arm_cspmu_find_cpu_container(int cpu, u32 container_uid)
11101110
{
1111-
u64 acpi_uid;
11121111
struct device *cpu_dev;
11131112
struct acpi_device *acpi_dev;
11141113

@@ -1118,8 +1117,7 @@ static inline int arm_cspmu_find_cpu_container(int cpu, u32 container_uid)
11181117

11191118
acpi_dev = ACPI_COMPANION(cpu_dev);
11201119
while (acpi_dev) {
1121-
if (acpi_dev_hid_uid_match(acpi_dev, ACPI_PROCESSOR_CONTAINER_HID, NULL) &&
1122-
!acpi_dev_uid_to_integer(acpi_dev, &acpi_uid) && acpi_uid == container_uid)
1120+
if (acpi_dev_hid_uid_match(acpi_dev, ACPI_PROCESSOR_CONTAINER_HID, container_uid))
11231121
return 0;
11241122

11251123
acpi_dev = acpi_dev_parent(acpi_dev);

include/acpi/acpi_bus.h

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,10 +764,71 @@ 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_uid_match(struct acpi_device *adev, const char *uid2);
768-
bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2);
769767
int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer);
770768

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+
776+
static inline bool acpi_str_uid_match(struct acpi_device *adev, const char *uid2)
777+
{
778+
const char *uid1 = acpi_device_uid(adev);
779+
780+
return uid1 && uid2 && !strcmp(uid1, uid2);
781+
}
782+
783+
static inline bool acpi_int_uid_match(struct acpi_device *adev, u64 uid2)
784+
{
785+
u64 uid1;
786+
787+
return !acpi_dev_uid_to_integer(adev, &uid1) && uid1 == uid2;
788+
}
789+
790+
#define TYPE_ENTRY(type, x) \
791+
const type: x, \
792+
type: x
793+
794+
#define ACPI_STR_TYPES(match) \
795+
TYPE_ENTRY(unsigned char *, match), \
796+
TYPE_ENTRY(signed char *, match), \
797+
TYPE_ENTRY(char *, match), \
798+
TYPE_ENTRY(void *, match)
799+
800+
/**
801+
* acpi_dev_uid_match - Match device by supplied UID
802+
* @adev: ACPI device to match.
803+
* @uid2: Unique ID of the device.
804+
*
805+
* Matches UID in @adev with given @uid2.
806+
*
807+
* Returns: %true if matches, %false otherwise.
808+
*/
809+
#define acpi_dev_uid_match(adev, uid2) \
810+
_Generic(uid2, \
811+
/* Treat @uid2 as a string for acpi string types */ \
812+
ACPI_STR_TYPES(acpi_str_uid_match), \
813+
/* Treat as an integer otherwise */ \
814+
default: acpi_int_uid_match)(adev, uid2)
815+
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+
771832
void acpi_dev_clear_dependencies(struct acpi_device *supplier);
772833
bool acpi_dev_ready_for_enumeration(const struct acpi_device *device);
773834
struct acpi_device *acpi_dev_get_next_consumer_dev(struct acpi_device *supplier,

include/linux/acpi.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,10 @@ const char *acpi_get_subsystem_id(acpi_handle handle);
756756
#define ACPI_HANDLE(dev) (NULL)
757757
#define ACPI_HANDLE_FWNODE(fwnode) (NULL)
758758

759+
/* Get rid of the -Wunused-variable for adev */
760+
#define acpi_dev_uid_match(adev, uid2) (adev && false)
761+
#define acpi_dev_hid_uid_match(adev, hid2, uid2) (adev && false)
762+
759763
#include <acpi/acpi_numa.h>
760764

761765
struct fwnode_handle;
@@ -772,17 +776,6 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
772776

773777
struct acpi_device;
774778

775-
static inline bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2)
776-
{
777-
return false;
778-
}
779-
780-
static inline bool
781-
acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2)
782-
{
783-
return false;
784-
}
785-
786779
static inline int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer)
787780
{
788781
return -ENODEV;

0 commit comments

Comments
 (0)