Commit 4eb0799f authored by Gavin Shan's avatar Gavin Shan Committed by Michael Ellerman

powerpc/eeh: Reworked eeh_pe_bus_get()

The original implementation is ugly: unnecessary if statements and
"out" tag. This reworks the function to avoid above weaknesses. No
functional changes introduced.
Signed-off-by: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
Reviewed-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent ee3b93eb
...@@ -920,25 +920,21 @@ const char *eeh_pe_loc_get(struct eeh_pe *pe) ...@@ -920,25 +920,21 @@ const char *eeh_pe_loc_get(struct eeh_pe *pe)
*/ */
struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe) struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe)
{ {
struct pci_bus *bus = NULL;
struct eeh_dev *edev; struct eeh_dev *edev;
struct pci_dev *pdev; struct pci_dev *pdev;
if (pe->type & EEH_PE_PHB) { if (pe->type & EEH_PE_PHB)
bus = pe->phb->bus; return pe->phb->bus;
} else if (pe->type & EEH_PE_BUS ||
pe->type & EEH_PE_DEVICE) {
if (pe->state & EEH_PE_PRI_BUS) {
bus = pe->bus;
goto out;
}
edev = list_first_entry(&pe->edevs, struct eeh_dev, list); /* The primary bus might be cached during probe time */
pdev = eeh_dev_to_pci_dev(edev); if (pe->state & EEH_PE_PRI_BUS)
if (pdev) return pe->bus;
bus = pdev->bus;
} /* Retrieve the parent PCI bus of first (top) PCI device */
edev = list_first_entry_or_null(&pe->edevs, struct eeh_dev, list);
pdev = eeh_dev_to_pci_dev(edev);
if (pdev)
return pdev->bus;
out: return NULL;
return bus;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment