]> git.baikalelectronics.ru Git - kernel.git/commitdiff
PCI: Add pci_set_acpi_fwnode() to set ACPI_COMPANION
authorShanker Donthineni <sdonthineni@nvidia.com>
Tue, 17 Aug 2021 18:04:57 +0000 (23:34 +0530)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 18 Aug 2021 22:04:29 +0000 (17:04 -0500)
Move the existing logic from acpi_pci_bridge_d3() to a separate function
pci_set_acpi_fwnode() to set the ACPI fwnode.  No functional change
intended.

Link: https://lore.kernel.org/r/20210817180500.1253-7-ameynarkhede03@gmail.com
Signed-off-by: Shanker Donthineni <sdonthineni@nvidia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
drivers/pci/pci-acpi.c
drivers/pci/pci.h

index 36bc23e2175927e15d475e577a95ef4970849f75..eaddbf7017594f8db2bdf7d494ec40b8218452d0 100644 (file)
@@ -934,6 +934,13 @@ static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev)
 
 static struct acpi_device *acpi_pci_find_companion(struct device *dev);
 
+void pci_set_acpi_fwnode(struct pci_dev *dev)
+{
+       if (!ACPI_COMPANION(&dev->dev) && !pci_dev_is_added(dev))
+               ACPI_COMPANION_SET(&dev->dev,
+                                  acpi_pci_find_companion(&dev->dev));
+}
+
 static bool acpi_pci_bridge_d3(struct pci_dev *dev)
 {
        const struct fwnode_handle *fwnode;
@@ -945,11 +952,8 @@ static bool acpi_pci_bridge_d3(struct pci_dev *dev)
                return false;
 
        /* Assume D3 support if the bridge is power-manageable by ACPI. */
+       pci_set_acpi_fwnode(dev);
        adev = ACPI_COMPANION(&dev->dev);
-       if (!adev && !pci_dev_is_added(dev)) {
-               adev = acpi_pci_find_companion(&dev->dev);
-               ACPI_COMPANION_SET(&dev->dev, adev);
-       }
 
        if (adev && acpi_device_power_manageable(adev))
                return true;
index b31afd4669cc05fb577cf5df07dbd968446e0d57..232047e58b73b55efe650d4282c8bb3b33fe1115 100644 (file)
@@ -707,7 +707,9 @@ static inline int pci_aer_raw_clear_status(struct pci_dev *dev) { return -EINVAL
 #ifdef CONFIG_ACPI
 int pci_acpi_program_hp_params(struct pci_dev *dev);
 extern const struct attribute_group pci_dev_acpi_attr_group;
+void pci_set_acpi_fwnode(struct pci_dev *dev);
 #else
+static inline void pci_set_acpi_fwnode(struct pci_dev *dev) {}
 static inline int pci_acpi_program_hp_params(struct pci_dev *dev)
 {
        return -ENODEV;