git: 931baeb62b03 - main - acpi_pci: Use pci_has_pm and pci_clear_pme

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 27 Mar 2025 20:59:51 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=931baeb62b03029cb57459736851c4e8141e672e

commit 931baeb62b03029cb57459736851c4e8141e672e
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-03-27 20:56:08 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-03-27 20:56:08 +0000

    acpi_pci: Use pci_has_pm and pci_clear_pme
    
    Differential Revision:  https://reviews.freebsd.org/D49266
---
 sys/dev/acpica/acpi_pci.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/sys/dev/acpica/acpi_pci.c b/sys/dev/acpica/acpi_pci.c
index b7a2bf70b4e0..646295f9eecc 100644
--- a/sys/dev/acpica/acpi_pci.c
+++ b/sys/dev/acpica/acpi_pci.c
@@ -391,8 +391,6 @@ acpi_pci_device_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context)
 {
 	device_t child, dev;
 	ACPI_STATUS status;
-	int pmc;
-	uint16_t pmstat;
 	int error;
 
 	dev = context;
@@ -419,12 +417,8 @@ acpi_pci_device_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context)
 			return;
 		}
 		if ((acpi_quirks & ACPI_Q_CLEAR_PME_ON_DETACH) &&
-		    (pci_find_cap(child, PCIY_PMG, &pmc) == 0)) {
-			pmstat = pci_read_config(child, pmc + PCIR_POWER_STATUS, 2);
-			pmstat &= ~PCIM_PSTAT_PMEENABLE;
-			pmstat |= PCIM_PSTAT_PME;
-			pci_write_config(child, pmc + PCIR_POWER_STATUS, pmstat, 2);
-		}
+		    pci_has_pm(child))
+			pci_clear_pme(child);
 		status = acpi_SetInteger(h, "_EJ0", 1);
 		if (ACPI_FAILURE(status)) {
 			bus_topo_unlock();