Skip to content

Commit e8c3c7f

Browse files
committed
Merge branches 'acpi-ec', 'acpi-sysfs', 'acpi-misc' and 'acpi-uid'
Merge ACPI EC driver updates, ACPI sysfs interface updates, misc updates related to ACPI and changes related to ACPI _UID handling for 6.7-rc1: - Add EC GPE detection quirk for HP 250 G7 Notebook PC (Jonathan Denose). - Fix and clean up create_pnp_modalias() and create_of_modalias() (Christophe JAILLET). - Modify 2 pieces of code to use acpi_evaluate_dsm_typed() (Andy Shevchenko). - Define acpi_dev_uid_match() for matching _UID and use it in several places (Raag Jadav). - Use acpi_device_uid() for fetching _UID in 2 places (Raag Jadav). * acpi-ec: ACPI: EC: Add quirk for HP 250 G7 Notebook PC * acpi-sysfs: ACPI: sysfs: Clean up create_pnp_modalias() and create_of_modalias() ACPI: sysfs: Fix create_pnp_modalias() and create_of_modalias() * acpi-misc: ACPI: x86: s2idle: Switch to use acpi_evaluate_dsm_typed() ACPI: PCI: Switch to use acpi_evaluate_dsm_typed() * acpi-uid: perf: arm_cspmu: use acpi_dev_hid_uid_match() for matching _HID and _UID ACPI: x86: use acpi_dev_uid_match() for matching _UID ACPI: utils: use acpi_dev_uid_match() for matching _UID pinctrl: intel: use acpi_dev_uid_match() for matching _UID ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID perf: qcom: use acpi_device_uid() for fetching _UID ACPI: sysfs: use acpi_device_uid() for fetching _UID
5 parents f3c0d6a + 891ddc0 + bc8f7ab + 5539218 + 6fdba3d commit e8c3c7f

File tree

11 files changed

+67
-35
lines changed

11 files changed

+67
-35
lines changed

drivers/acpi/device_sysfs.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ static int create_pnp_modalias(const struct acpi_device *acpi_dev, char *modalia
158158
return 0;
159159

160160
len = snprintf(modalias, size, "acpi:");
161-
if (len <= 0)
162-
return len;
161+
if (len >= size)
162+
return -ENOMEM;
163163

164164
size -= len;
165165

@@ -168,16 +168,14 @@ static int create_pnp_modalias(const struct acpi_device *acpi_dev, char *modalia
168168
continue;
169169

170170
count = snprintf(&modalias[len], size, "%s:", id->id);
171-
if (count < 0)
172-
return -EINVAL;
173171

174172
if (count >= size)
175173
return -ENOMEM;
176174

177175
len += count;
178176
size -= count;
179177
}
180-
modalias[len] = '\0';
178+
181179
return len;
182180
}
183181

@@ -212,8 +210,10 @@ static int create_of_modalias(const struct acpi_device *acpi_dev, char *modalias
212210
len = snprintf(modalias, size, "of:N%sT", (char *)buf.pointer);
213211
ACPI_FREE(buf.pointer);
214212

215-
if (len <= 0)
216-
return len;
213+
if (len >= size)
214+
return -ENOMEM;
215+
216+
size -= len;
217217

218218
of_compatible = acpi_dev->data.of_compatible;
219219
if (of_compatible->type == ACPI_TYPE_PACKAGE) {
@@ -226,16 +226,14 @@ static int create_of_modalias(const struct acpi_device *acpi_dev, char *modalias
226226
for (i = 0; i < nval; i++, obj++) {
227227
count = snprintf(&modalias[len], size, "C%s",
228228
obj->string.pointer);
229-
if (count < 0)
230-
return -EINVAL;
231229

232230
if (count >= size)
233231
return -ENOMEM;
234232

235233
len += count;
236234
size -= count;
237235
}
238-
modalias[len] = '\0';
236+
239237
return len;
240238
}
241239

@@ -410,7 +408,7 @@ static ssize_t uid_show(struct device *dev,
410408
{
411409
struct acpi_device *acpi_dev = to_acpi_device(dev);
412410

413-
return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id);
411+
return sprintf(buf, "%s\n", acpi_device_uid(acpi_dev));
414412
}
415413
static DEVICE_ATTR_RO(uid);
416414

@@ -554,7 +552,7 @@ int acpi_device_setup_files(struct acpi_device *dev)
554552

555553
if (dev->pnp.type.bus_address)
556554
result = device_create_file(&dev->dev, &dev_attr_adr);
557-
if (dev->pnp.unique_id)
555+
if (acpi_device_uid(dev))
558556
result = device_create_file(&dev->dev, &dev_attr_uid);
559557

560558
if (acpi_has_method(dev->handle, "_SUN")) {
@@ -635,7 +633,7 @@ void acpi_device_remove_files(struct acpi_device *dev)
635633
if (acpi_has_method(dev->handle, "_HRV"))
636634
device_remove_file(&dev->dev, &dev_attr_hrv);
637635

638-
if (dev->pnp.unique_id)
636+
if (acpi_device_uid(dev))
639637
device_remove_file(&dev->dev, &dev_attr_uid);
640638
if (dev->pnp.type.bus_address)
641639
device_remove_file(&dev->dev, &dev_attr_adr);

drivers/acpi/ec.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,16 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = {
19241924
DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Gaming Laptop 15-dk1xxx"),
19251925
},
19261926
},
1927+
{
1928+
/*
1929+
* HP 250 G7 Notebook PC
1930+
*/
1931+
.callback = ec_honor_dsdt_gpe,
1932+
.matches = {
1933+
DMI_MATCH(DMI_SYS_VENDOR, "HP"),
1934+
DMI_MATCH(DMI_PRODUCT_NAME, "HP 250 G7 Notebook PC"),
1935+
},
1936+
},
19271937
{
19281938
/*
19291939
* Samsung hardware

drivers/acpi/pci_root.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,9 +1055,9 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
10551055
* exists and returns 0, we must preserve any PCI resource
10561056
* assignments made by firmware for this host bridge.
10571057
*/
1058-
obj = acpi_evaluate_dsm(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, 1,
1059-
DSM_PCI_PRESERVE_BOOT_CONFIG, NULL);
1060-
if (obj && obj->type == ACPI_TYPE_INTEGER && obj->integer.value == 0)
1058+
obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, 1,
1059+
DSM_PCI_PRESERVE_BOOT_CONFIG, NULL, ACPI_TYPE_INTEGER);
1060+
if (obj && obj->integer.value == 0)
10611061
host_bridge->preserve_config = 1;
10621062
ACPI_FREE(obj);
10631063

drivers/acpi/utils.c

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -824,28 +824,51 @@ 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+
827846
/**
828847
* acpi_dev_hid_uid_match - Match device by supplied HID and UID
829848
* @adev: ACPI device to match.
830849
* @hid2: Hardware ID of the device.
831850
* @uid2: Unique ID of the device, pass NULL to not check _UID.
832851
*
833-
* Matches HID and UID in @adev with given @hid2 and @uid2.
834-
* Returns true if matches.
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.
835859
*/
836860
bool acpi_dev_hid_uid_match(struct acpi_device *adev,
837861
const char *hid2, const char *uid2)
838862
{
839863
const char *hid1 = acpi_device_hid(adev);
840-
const char *uid1 = acpi_device_uid(adev);
841864

842865
if (strcmp(hid1, hid2))
843866
return false;
844867

845868
if (!uid2)
846869
return true;
847870

848-
return uid1 && !strcmp(uid1, uid2);
871+
return acpi_dev_uid_match(adev, uid2);
849872
}
850873
EXPORT_SYMBOL(acpi_dev_hid_uid_match);
851874

@@ -919,8 +942,7 @@ static int acpi_dev_match_cb(struct device *dev, const void *data)
919942
if (acpi_match_device_ids(adev, match->hid))
920943
return 0;
921944

922-
if (match->uid && (!adev->pnp.unique_id ||
923-
strcmp(adev->pnp.unique_id, match->uid)))
945+
if (match->uid && !acpi_dev_uid_match(adev, match->uid))
924946
return 0;
925947

926948
if (match->hrv == -1)

drivers/acpi/x86/s2idle.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,10 @@ static int validate_dsm(acpi_handle handle, const char *uuid, int rev, guid_t *d
417417
int ret = -EINVAL;
418418

419419
guid_parse(uuid, dsm_guid);
420-
obj = acpi_evaluate_dsm(handle, dsm_guid, rev, 0, NULL);
421420

422421
/* Check if the _DSM is present and as expected. */
423-
if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length == 0 ||
424-
obj->buffer.length > sizeof(u32)) {
422+
obj = acpi_evaluate_dsm_typed(handle, dsm_guid, rev, 0, NULL, ACPI_TYPE_BUFFER);
423+
if (!obj || obj->buffer.length == 0 || obj->buffer.length > sizeof(u32)) {
425424
acpi_handle_debug(handle,
426425
"_DSM UUID %s rev %d function 0 evaluation failed\n", uuid, rev);
427426
goto out;

drivers/acpi/x86/utils.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ bool acpi_device_override_status(struct acpi_device *adev, unsigned long long *s
184184
if (acpi_match_device_ids(adev, override_status_ids[i].hid))
185185
continue;
186186

187-
if (!adev->pnp.unique_id ||
188-
strcmp(adev->pnp.unique_id, override_status_ids[i].uid))
187+
if (!acpi_dev_uid_match(adev, override_status_ids[i].uid))
189188
continue;
190189
}
191190

drivers/perf/arm_cspmu/arm_cspmu.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ static int arm_cspmu_request_irq(struct arm_cspmu *cspmu)
10611061

10621062
static inline int arm_cspmu_find_cpu_container(int cpu, u32 container_uid)
10631063
{
1064-
u32 acpi_uid;
1064+
u64 acpi_uid;
10651065
struct device *cpu_dev;
10661066
struct acpi_device *acpi_dev;
10671067

@@ -1071,10 +1071,8 @@ static inline int arm_cspmu_find_cpu_container(int cpu, u32 container_uid)
10711071

10721072
acpi_dev = ACPI_COMPANION(cpu_dev);
10731073
while (acpi_dev) {
1074-
if (!strcmp(acpi_device_hid(acpi_dev),
1075-
ACPI_PROCESSOR_CONTAINER_HID) &&
1076-
!kstrtouint(acpi_device_uid(acpi_dev), 0, &acpi_uid) &&
1077-
acpi_uid == container_uid)
1074+
if (acpi_dev_hid_uid_match(acpi_dev, ACPI_PROCESSOR_CONTAINER_HID, NULL) &&
1075+
!acpi_dev_uid_to_integer(acpi_dev, &acpi_uid) && acpi_uid == container_uid)
10781076
return 0;
10791077

10801078
acpi_dev = acpi_dev_parent(acpi_dev);

drivers/perf/qcom_l3_pmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,8 @@ static int qcom_l3_cache_pmu_probe(struct platform_device *pdev)
742742

743743
l3pmu = devm_kzalloc(&pdev->dev, sizeof(*l3pmu), GFP_KERNEL);
744744
name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "l3cache_%s_%s",
745-
acpi_dev_parent(acpi_dev)->pnp.unique_id,
746-
acpi_dev->pnp.unique_id);
745+
acpi_device_uid(acpi_dev_parent(acpi_dev)),
746+
acpi_device_uid(acpi_dev));
747747
if (!l3pmu || !name)
748748
return -ENOMEM;
749749

drivers/pinctrl/intel/pinctrl-intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_
16941694
unsigned int i;
16951695

16961696
for (i = 0; table[i]; i++) {
1697-
if (!strcmp(adev->pnp.unique_id, table[i]->uid)) {
1697+
if (acpi_dev_uid_match(adev, table[i]->uid)) {
16981698
data = table[i];
16991699
break;
17001700
}

include/acpi/acpi_bus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
763763
adev->power.states[ACPI_STATE_D3_HOT].flags.explicit_set);
764764
}
765765

766+
bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2);
766767
bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2);
767768
int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer);
768769

0 commit comments

Comments
 (0)