Skip to content

Commit d8a872c

Browse files
committed
ACPI: PCI: PM: Rework root bus notification setup
Since pci_acpi_add_bus_pm_notifier() is only suitable for adding ACPI PM notifiers to root buses, rename it to pci_acpi_add_root_pm_notifier() and modify it to take an additional "root" argument, which is then used for passing a PCI root bridge device pointer to acpi_add_pm_notifier(). That function uses it to populate the "dev" field in the context structure attached to the ACPI device object that will receive the ACPI "wake" notifications on behalf of the given PCI root bus. The context structure in question is passed to pci_acpi_wake_bus(), so the latter can be simplified quite a bit now because the target PCI host bridge structure address can be derived from "dev". No intentional functional impact. This change will also facilitate a subsequent update related to the registration of wakeup sources. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Armin Wolf <W_Armin@gmx.de> [ rjw: Kerneldoc comment fixup ] Link: https://patch.msgid.link/2395263.ElGaqSPkdT@rafael.j.wysocki Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 8f0b4cc commit d8a872c

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

drivers/acpi/pci_root.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
738738
if (no_aspm)
739739
pcie_no_aspm();
740740

741-
pci_acpi_add_bus_pm_notifier(device);
741+
pci_acpi_add_root_pm_notifier(device, root);
742742
device_set_wakeup_capable(root->bus->bridge, device->wakeup.flags.valid);
743743

744744
if (hotadd) {

drivers/pci/pci-acpi.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -847,12 +847,7 @@ bool shpchp_is_native(struct pci_dev *bridge)
847847
*/
848848
static void pci_acpi_wake_bus(struct acpi_device_wakeup_context *context)
849849
{
850-
struct acpi_device *adev;
851-
struct acpi_pci_root *root;
852-
853-
adev = container_of(context, struct acpi_device, wakeup.context);
854-
root = acpi_driver_data(adev);
855-
pci_pme_wakeup_bus(root->bus);
850+
pci_pme_wakeup_bus(to_pci_host_bridge(context->dev)->bus);
856851
}
857852

858853
/**
@@ -885,12 +880,14 @@ static void pci_acpi_wake_dev(struct acpi_device_wakeup_context *context)
885880
}
886881

887882
/**
888-
* pci_acpi_add_bus_pm_notifier - Register PM notifier for root PCI bus.
883+
* pci_acpi_add_root_pm_notifier - Register PM notifier for root PCI bus.
889884
* @dev: PCI root bridge ACPI device.
885+
* @root: PCI root corresponding to @dev.
890886
*/
891-
acpi_status pci_acpi_add_bus_pm_notifier(struct acpi_device *dev)
887+
acpi_status pci_acpi_add_root_pm_notifier(struct acpi_device *dev,
888+
struct acpi_pci_root *root)
892889
{
893-
return acpi_add_pm_notifier(dev, NULL, pci_acpi_wake_bus);
890+
return acpi_add_pm_notifier(dev, root->bus->bridge, pci_acpi_wake_bus);
894891
}
895892

896893
/**

include/linux/pci-acpi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#include <linux/acpi.h>
1313

1414
#ifdef CONFIG_ACPI
15-
extern acpi_status pci_acpi_add_bus_pm_notifier(struct acpi_device *dev);
15+
extern acpi_status pci_acpi_add_root_pm_notifier(struct acpi_device *dev,
16+
struct acpi_pci_root *pci_root);
1617
static inline acpi_status pci_acpi_remove_bus_pm_notifier(struct acpi_device *dev)
1718
{
1819
return acpi_remove_pm_notifier(dev);

0 commit comments

Comments
 (0)