IB/uverbs: reject invalid or unknown opcodes
[firefly-linux-kernel-4.4.55.git] / drivers / pci / pci-acpi.c
index 5147c210df52999c5ebe9d00e08b357c24dfd4c6..0eab3a3c51c58f41a3d6292f7fb7cfde7df67797 100644 (file)
@@ -47,6 +47,9 @@ static void pci_acpi_wake_dev(acpi_handle handle, u32 event, void *context)
        if (event != ACPI_NOTIFY_DEVICE_WAKE || !pci_dev)
                return;
 
+       if (pci_dev->pme_poll)
+               pci_dev->pme_poll = false;
+
        if (pci_dev->current_state == PCI_D3cold) {
                pci_wakeup_event(pci_dev);
                pm_runtime_resume(&pci_dev->dev);
@@ -57,9 +60,6 @@ static void pci_acpi_wake_dev(acpi_handle handle, u32 event, void *context)
        if (pci_dev->pme_support)
                pci_check_pme_status(pci_dev);
 
-       if (pci_dev->pme_poll)
-               pci_dev->pme_poll = false;
-
        pci_wakeup_event(pci_dev);
        pm_runtime_resume(&pci_dev->dev);
 
@@ -288,16 +288,49 @@ static struct pci_platform_pm_ops acpi_pci_platform_pm = {
        .run_wake = acpi_pci_run_wake,
 };
 
+void acpi_pci_add_bus(struct pci_bus *bus)
+{
+       acpi_handle handle = NULL;
+
+       if (bus->bridge)
+               handle = ACPI_HANDLE(bus->bridge);
+       if (acpi_pci_disabled || handle == NULL)
+               return;
+
+       acpi_pci_slot_enumerate(bus, handle);
+       acpiphp_enumerate_slots(bus, handle);
+}
+
+void acpi_pci_remove_bus(struct pci_bus *bus)
+{
+       /*
+        * bus->bridge->acpi_node.handle has already been reset to NULL
+        * when acpi_pci_remove_bus() is called, so don't check ACPI handle.
+        */
+       if (acpi_pci_disabled)
+               return;
+
+       acpiphp_remove_slots(bus);
+       acpi_pci_slot_remove(bus);
+}
+
 /* ACPI bus type */
 static int acpi_pci_find_device(struct device *dev, acpi_handle *handle)
 {
-       struct pci_dev * pci_dev;
-       u64     addr;
+       struct pci_dev *pci_dev = to_pci_dev(dev);
+       bool is_bridge;
+       u64 addr;
 
-       pci_dev = to_pci_dev(dev);
+       /*
+        * pci_is_bridge() is not suitable here, because pci_dev->subordinate
+        * is set only after acpi_pci_find_device() has been called for the
+        * given device.
+        */
+       is_bridge = pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE
+                       || pci_dev->hdr_type == PCI_HEADER_TYPE_CARDBUS;
        /* Please ref to ACPI spec for the syntax of _ADR */
        addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
-       *handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev->parent), addr);
+       *handle = acpi_find_child(ACPI_HANDLE(dev->parent), addr, is_bridge);
        if (!*handle)
                return -ENODEV;
        return 0;
@@ -362,7 +395,11 @@ static int __init acpi_pci_init(void)
        ret = register_acpi_bus_type(&acpi_pci_bus);
        if (ret)
                return 0;
+
        pci_set_platform_pm(&acpi_pci_platform_pm);
+       acpi_pci_slot_init();
+       acpiphp_init();
+
        return 0;
 }
 arch_initcall(acpi_pci_init);