Skip to content

Commit

Permalink
powerpc: Create pci_controller_ops.enable_device_hook and shim
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Axtens authored and Michael Ellerman committed Apr 11, 2015
1 parent ff9df8c commit b31e79f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 15 additions & 0 deletions arch/powerpc/include/asm/pci-bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
};

/*
Expand Down Expand Up @@ -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 */
5 changes: 2 additions & 3 deletions arch/powerpc/kernel/pci-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit b31e79f

Please sign in to comment.