powerpc: Create pci_controller_ops.enable_device_hook and shim
authorDaniel Axtens <dja@axtens.net>
Tue, 31 Mar 2015 05:00:45 +0000 (16:00 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 11 Apr 2015 10:49:13 +0000 (20:49 +1000)
Add pci_controller_ops.enable_device_hook,
shadowing ppc_md.pcibios_enable_device_hook.
Add a shim, and changes the callsites to use the shim.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/pci-bridge.h
arch/powerpc/kernel/pci-common.c

index 278f48978badbb0ac6d6f1e6f5fbf89f57525d23..9d02ea6255ffe705a4ecfebf783b2d2b18650bef 100644 (file)
@@ -27,6 +27,10 @@ struct pci_controller_ops {
        void            (*dma_bus_setup)(struct pci_bus *bus);
 
        int             (*probe_mode)(struct pci_bus *);
+
+       /* Called when pci_enable_device() is called. Returns true to
+        * allow assignment/enabling of the device. */
+       bool            (*enable_device_hook)(struct pci_dev *);
 };
 
 /*
@@ -310,5 +314,16 @@ static inline int pci_probe_mode(struct pci_bus *bus)
        return PCI_PROBE_NORMAL;
 }
 
+static inline bool pcibios_enable_device_hook(struct pci_dev *dev)
+{
+       struct pci_controller *phb = pci_bus_to_host(dev->bus);
+
+       if (phb->controller_ops.enable_device_hook)
+               return phb->controller_ops.enable_device_hook(dev);
+       if (ppc_md.pcibios_enable_device_hook)
+               return ppc_md.pcibios_enable_device_hook(dev);
+       return true;
+}
+
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_PCI_BRIDGE_H */
index b0de23c89ca58b98d1b189b4bf4ea0adbe38e68d..8639e9cd65d5b39226a24ecfbc86ab025138b455 100644 (file)
@@ -1448,9 +1448,8 @@ EXPORT_SYMBOL_GPL(pcibios_finish_adding_to_bus);
 
 int pcibios_enable_device(struct pci_dev *dev, int mask)
 {
-       if (ppc_md.pcibios_enable_device_hook)
-               if (!ppc_md.pcibios_enable_device_hook(dev))
-                       return -EINVAL;
+       if (!pcibios_enable_device_hook(dev))
+               return -EINVAL;
 
        return pci_enable_resources(dev, mask);
 }