powerpc/pci: Export pci_add_device_node_info()

This renames update_dn_pci_info() to pci_add_device_node_info()
with corresponding adjustment on the parameter type and exports it.
The function is used to create pdn (struct pci_dn) for the indicated
device node. Another function add_pdn(), almost wrapper of
pci_add_device_node_info(), to be used in traverse_pci_devices(). No
logical changes introduced.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
Gavin Shan 2016-05-03 15:41:40 +10:00 committed by Michael Ellerman
parent 6384d97780
commit d8f66f411e
3 changed files with 22 additions and 13 deletions

View File

@ -235,7 +235,8 @@ extern struct pci_dn *pci_get_pdn_by_devfn(struct pci_bus *bus,
extern struct pci_dn *pci_get_pdn(struct pci_dev *pdev); extern struct pci_dn *pci_get_pdn(struct pci_dev *pdev);
extern struct pci_dn *add_dev_pci_data(struct pci_dev *pdev); extern struct pci_dn *add_dev_pci_data(struct pci_dev *pdev);
extern void remove_dev_pci_data(struct pci_dev *pdev); extern void remove_dev_pci_data(struct pci_dev *pdev);
extern void *update_dn_pci_info(struct device_node *dn, void *data); extern struct pci_dn *pci_add_device_node_info(struct pci_controller *hose,
struct device_node *dn);
static inline int pci_device_from_OF_node(struct device_node *np, static inline int pci_device_from_OF_node(struct device_node *np,
u8 *bus, u8 *devfn) u8 *bus, u8 *devfn)

View File

@ -282,13 +282,9 @@ void remove_dev_pci_data(struct pci_dev *pdev)
#endif /* CONFIG_PCI_IOV */ #endif /* CONFIG_PCI_IOV */
} }
/* struct pci_dn *pci_add_device_node_info(struct pci_controller *hose,
* Traverse_func that inits the PCI fields of the device node. struct device_node *dn)
* NOTE: this *must* be done before read/write config to the device.
*/
void *update_dn_pci_info(struct device_node *dn, void *data)
{ {
struct pci_controller *phb = data;
const __be32 *type = of_get_property(dn, "ibm,pci-config-space-type", NULL); const __be32 *type = of_get_property(dn, "ibm,pci-config-space-type", NULL);
const __be32 *regs; const __be32 *regs;
struct device_node *parent; struct device_node *parent;
@ -299,7 +295,7 @@ void *update_dn_pci_info(struct device_node *dn, void *data)
return NULL; return NULL;
dn->data = pdn; dn->data = pdn;
pdn->node = dn; pdn->node = dn;
pdn->phb = phb; pdn->phb = hose;
#ifdef CONFIG_PPC_POWERNV #ifdef CONFIG_PPC_POWERNV
pdn->pe_number = IODA_INVALID_PE; pdn->pe_number = IODA_INVALID_PE;
#endif #endif
@ -331,8 +327,9 @@ void *update_dn_pci_info(struct device_node *dn, void *data)
if (pdn->parent) if (pdn->parent)
list_add_tail(&pdn->list, &pdn->parent->child_list); list_add_tail(&pdn->list, &pdn->parent->child_list);
return NULL; return pdn;
} }
EXPORT_SYMBOL_GPL(pci_add_device_node_info);
/* /*
* Traverse a device tree stopping each PCI device in the tree. * Traverse a device tree stopping each PCI device in the tree.
@ -432,6 +429,18 @@ void *traverse_pci_dn(struct pci_dn *root,
return NULL; return NULL;
} }
static void *add_pdn(struct device_node *dn, void *data)
{
struct pci_controller *hose = data;
struct pci_dn *pdn;
pdn = pci_add_device_node_info(hose, dn);
if (!pdn)
return ERR_PTR(-ENOMEM);
return NULL;
}
/** /**
* pci_devs_phb_init_dynamic - setup pci devices under this PHB * pci_devs_phb_init_dynamic - setup pci devices under this PHB
* phb: pci-to-host bridge (top-level bridge connecting to cpu) * phb: pci-to-host bridge (top-level bridge connecting to cpu)
@ -446,8 +455,7 @@ void pci_devs_phb_init_dynamic(struct pci_controller *phb)
struct pci_dn *pdn; struct pci_dn *pdn;
/* PHB nodes themselves must not match */ /* PHB nodes themselves must not match */
update_dn_pci_info(dn, phb); pdn = pci_add_device_node_info(phb, dn);
pdn = dn->data;
if (pdn) { if (pdn) {
pdn->devfn = pdn->busno = -1; pdn->devfn = pdn->busno = -1;
pdn->vendor_id = pdn->device_id = pdn->class_code = 0; pdn->vendor_id = pdn->device_id = pdn->class_code = 0;
@ -456,7 +464,7 @@ void pci_devs_phb_init_dynamic(struct pci_controller *phb)
} }
/* Update dn->phb ptrs for new phb and children devices */ /* Update dn->phb ptrs for new phb and children devices */
traverse_pci_devices(dn, update_dn_pci_info, phb); traverse_pci_devices(dn, add_pdn, phb);
} }
/** /**

View File

@ -267,7 +267,7 @@ static int pci_dn_reconfig_notifier(struct notifier_block *nb, unsigned long act
pdn = parent ? PCI_DN(parent) : NULL; pdn = parent ? PCI_DN(parent) : NULL;
if (pdn) { if (pdn) {
/* Create pdn and EEH device */ /* Create pdn and EEH device */
update_dn_pci_info(np, pdn->phb); pci_add_device_node_info(pdn->phb, np);
eeh_dev_init(PCI_DN(np), pdn->phb); eeh_dev_init(PCI_DN(np), pdn->phb);
} }