Skip to content

Commit ba46e42

Browse files
jwrdegoederafaeljw
authored andcommitted
ACPI / x86: Allow specifying acpi_device_override_status() quirks by path
Not all ACPI-devices have a HID + UID, allow specifying quirks for acpi_device_override_status() by path too. Note this moves the path/HID+UID check to after the CPU + DMI checks since the path lookup is somewhat costly. This way this lookup is only done on devices where the other checks match. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 1a68b34 commit ba46e42

1 file changed

Lines changed: 32 additions & 10 deletions

File tree

drivers/acpi/x86/utils.c

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,30 @@ struct override_status_id {
3838
struct x86_cpu_id cpu_ids[2];
3939
struct dmi_system_id dmi_ids[2]; /* Optional */
4040
const char *uid;
41+
const char *path;
4142
unsigned long long status;
4243
};
4344

44-
#define ENTRY(status, hid, uid, cpu_model, dmi...) { \
45+
#define ENTRY(status, hid, uid, path, cpu_model, dmi...) { \
4546
{ { hid, }, {} }, \
4647
{ X86_MATCH_INTEL_FAM6_MODEL(cpu_model, NULL), {} }, \
4748
{ { .matches = dmi }, {} }, \
4849
uid, \
50+
path, \
4951
status, \
5052
}
5153

5254
#define PRESENT_ENTRY_HID(hid, uid, cpu_model, dmi...) \
53-
ENTRY(ACPI_STA_DEFAULT, hid, uid, cpu_model, dmi)
55+
ENTRY(ACPI_STA_DEFAULT, hid, uid, NULL, cpu_model, dmi)
5456

5557
#define NOT_PRESENT_ENTRY_HID(hid, uid, cpu_model, dmi...) \
56-
ENTRY(0, hid, uid, cpu_model, dmi)
58+
ENTRY(0, hid, uid, NULL, cpu_model, dmi)
59+
60+
#define PRESENT_ENTRY_PATH(path, cpu_model, dmi...) \
61+
ENTRY(ACPI_STA_DEFAULT, "", NULL, path, cpu_model, dmi)
62+
63+
#define NOT_PRESENT_ENTRY_PATH(path, cpu_model, dmi...) \
64+
ENTRY(0, "", NULL, path, cpu_model, dmi)
5765

5866
static const struct override_status_id override_status_ids[] = {
5967
/*
@@ -120,20 +128,34 @@ bool acpi_device_override_status(struct acpi_device *adev, unsigned long long *s
120128
unsigned int i;
121129

122130
for (i = 0; i < ARRAY_SIZE(override_status_ids); i++) {
123-
if (acpi_match_device_ids(adev, override_status_ids[i].hid))
124-
continue;
125-
126-
if (!adev->pnp.unique_id ||
127-
strcmp(adev->pnp.unique_id, override_status_ids[i].uid))
128-
continue;
129-
130131
if (!x86_match_cpu(override_status_ids[i].cpu_ids))
131132
continue;
132133

133134
if (override_status_ids[i].dmi_ids[0].matches[0].slot &&
134135
!dmi_check_system(override_status_ids[i].dmi_ids))
135136
continue;
136137

138+
if (override_status_ids[i].path) {
139+
struct acpi_buffer path = { ACPI_ALLOCATE_BUFFER, NULL };
140+
bool match;
141+
142+
if (acpi_get_name(adev->handle, ACPI_FULL_PATHNAME, &path))
143+
continue;
144+
145+
match = strcmp((char *)path.pointer, override_status_ids[i].path) == 0;
146+
kfree(path.pointer);
147+
148+
if (!match)
149+
continue;
150+
} else {
151+
if (acpi_match_device_ids(adev, override_status_ids[i].hid))
152+
continue;
153+
154+
if (!adev->pnp.unique_id ||
155+
strcmp(adev->pnp.unique_id, override_status_ids[i].uid))
156+
continue;
157+
}
158+
137159
*status = override_status_ids[i].status;
138160
ret = true;
139161
break;

0 commit comments

Comments
 (0)