summaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2021-09-18 14:53:44 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2021-09-27 17:00:21 +0200
commit4795448117824cc4900d696f17d1516c56371045 (patch)
tree3f3ba72dcc26da0a017860c6782cf1523994671a /drivers/acpi
parentLinux 5.15-rc3 (diff)
downloadlinux-4795448117824cc4900d696f17d1516c56371045.tar.xz
linux-4795448117824cc4900d696f17d1516c56371045.zip
PCI: ACPI: Drop acpi_pci_bus
The acpi_pci_bus structure was used primarily for running acpi_pci_find_companion() during PCI device objects registration, but after commit 375553a93201 ("PCI: Setup ACPI fwnode early and at the same time with OF") that function is called by pci_setup_device() via pci_set_acpi_fwnode(), which happens before calling pci_device_add() on the new PCI device object, so its ACPI companion has been set already when acpi_device_notify() runs and it will never call ->find_companion() from acpi_pci_bus. For this reason, modify acpi_device_notify() and acpi_device_notify_remove() to call pci_acpi_setup() and pci_acpi_cleanup(), respectively, directly on PCI device objects and drop acpi_pci_bus altogether. While at it, notice that pci_acpi_setup() and pci_acpi_cleanup() can obtain the ACPI companion pointer, which is guaranteed to not be NULL, from their callers and modify them to work that way so as to reduce the number of redundant checks somewhat. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Ferry Toth <fntoth@gmail.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/glue.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 7a33a6d985f8..68768d6c8a47 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -17,6 +17,8 @@
#include <linux/rwsem.h>
#include <linux/acpi.h>
#include <linux/dma-mapping.h>
+#include <linux/pci.h>
+#include <linux/pci-acpi.h>
#include <linux/platform_device.h>
#include "internal.h"
@@ -307,13 +309,17 @@ void acpi_device_notify(struct device *dev)
}
adev = ACPI_COMPANION(dev);
- if (dev_is_platform(dev))
- acpi_configure_pmsi_domain(dev);
+ if (dev_is_pci(dev)) {
+ pci_acpi_setup(dev, adev);
+ } else {
+ if (dev_is_platform(dev))
+ acpi_configure_pmsi_domain(dev);
- if (type && type->setup)
- type->setup(dev);
- else if (adev->handler && adev->handler->bind)
- adev->handler->bind(dev);
+ if (type && type->setup)
+ type->setup(dev);
+ else if (adev->handler && adev->handler->bind)
+ adev->handler->bind(dev);
+ }
acpi_handle_debug(ACPI_HANDLE(dev), "Bound to device %s\n",
dev_name(dev));
@@ -327,16 +333,20 @@ err:
void acpi_device_notify_remove(struct device *dev)
{
struct acpi_device *adev = ACPI_COMPANION(dev);
- struct acpi_bus_type *type;
if (!adev)
return;
- type = acpi_get_bus_type(dev);
- if (type && type->cleanup)
- type->cleanup(dev);
- else if (adev->handler && adev->handler->unbind)
- adev->handler->unbind(dev);
+ if (dev_is_pci(dev)) {
+ pci_acpi_cleanup(dev, adev);
+ } else {
+ struct acpi_bus_type *type = acpi_get_bus_type(dev);
+
+ if (type && type->cleanup)
+ type->cleanup(dev);
+ else if (adev->handler && adev->handler->unbind)
+ adev->handler->unbind(dev);
+ }
acpi_unbind_one(dev);
}