PCI: Cleanup control flow
Return errors immediately so the straightline path is the normal, no-error path. No functional change. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
parent
a0c8a4d9f9
commit
9e808eb6a7
|
@ -155,17 +155,13 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_ANY_ID, rc_pci_fixup);
|
||||||
static struct pci_bus __init *
|
static struct pci_bus __init *
|
||||||
dove_pcie_scan_bus(int nr, struct pci_sys_data *sys)
|
dove_pcie_scan_bus(int nr, struct pci_sys_data *sys)
|
||||||
{
|
{
|
||||||
struct pci_bus *bus;
|
if (nr >= num_pcie_ports) {
|
||||||
|
|
||||||
if (nr < num_pcie_ports) {
|
|
||||||
bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
|
|
||||||
&sys->resources);
|
|
||||||
} else {
|
|
||||||
bus = NULL;
|
|
||||||
BUG();
|
BUG();
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bus;
|
return pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
|
||||||
|
&sys->resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init dove_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
|
static int __init dove_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
|
||||||
|
|
|
@ -197,17 +197,13 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_ANY_ID, rc_pci_fixup);
|
||||||
static struct pci_bus __init *
|
static struct pci_bus __init *
|
||||||
mv78xx0_pcie_scan_bus(int nr, struct pci_sys_data *sys)
|
mv78xx0_pcie_scan_bus(int nr, struct pci_sys_data *sys)
|
||||||
{
|
{
|
||||||
struct pci_bus *bus;
|
if (nr >= num_pcie_ports) {
|
||||||
|
|
||||||
if (nr < num_pcie_ports) {
|
|
||||||
bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
|
|
||||||
&sys->resources);
|
|
||||||
} else {
|
|
||||||
bus = NULL;
|
|
||||||
BUG();
|
BUG();
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bus;
|
return pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
|
||||||
|
&sys->resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init mv78xx0_pcie_map_irq(const struct pci_dev *dev, u8 slot,
|
static int __init mv78xx0_pcie_map_irq(const struct pci_dev *dev, u8 slot,
|
||||||
|
|
|
@ -540,37 +540,33 @@ void __init orion5x_pci_set_cardbus_mode(void)
|
||||||
|
|
||||||
int __init orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys)
|
int __init orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
vga_base = ORION5X_PCIE_MEM_PHYS_BASE;
|
vga_base = ORION5X_PCIE_MEM_PHYS_BASE;
|
||||||
|
|
||||||
if (nr == 0) {
|
if (nr == 0) {
|
||||||
orion_pcie_set_local_bus_nr(PCIE_BASE, sys->busnr);
|
orion_pcie_set_local_bus_nr(PCIE_BASE, sys->busnr);
|
||||||
ret = pcie_setup(sys);
|
return pcie_setup(sys);
|
||||||
} else if (nr == 1 && !orion5x_pci_disabled) {
|
|
||||||
orion5x_pci_set_bus_nr(sys->busnr);
|
|
||||||
ret = pci_setup(sys);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
if (nr == 1 && !orion5x_pci_disabled) {
|
||||||
|
orion5x_pci_set_bus_nr(sys->busnr);
|
||||||
|
return pci_setup(sys);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pci_bus __init *orion5x_pci_sys_scan_bus(int nr, struct pci_sys_data *sys)
|
struct pci_bus __init *orion5x_pci_sys_scan_bus(int nr, struct pci_sys_data *sys)
|
||||||
{
|
{
|
||||||
struct pci_bus *bus;
|
if (nr == 0)
|
||||||
|
return pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
|
||||||
|
&sys->resources);
|
||||||
|
|
||||||
if (nr == 0) {
|
if (nr == 1 && !orion5x_pci_disabled)
|
||||||
bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
|
return pci_scan_root_bus(NULL, sys->busnr, &pci_ops, sys,
|
||||||
&sys->resources);
|
&sys->resources);
|
||||||
} else if (nr == 1 && !orion5x_pci_disabled) {
|
|
||||||
bus = pci_scan_root_bus(NULL, sys->busnr, &pci_ops, sys,
|
|
||||||
&sys->resources);
|
|
||||||
} else {
|
|
||||||
bus = NULL;
|
|
||||||
BUG();
|
BUG();
|
||||||
}
|
return NULL;
|
||||||
|
|
||||||
return bus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int __init orion5x_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
|
int __init orion5x_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
|
||||||
|
|
|
@ -94,14 +94,16 @@ static void pcibios_scanbus(struct pci_controller *hose)
|
||||||
pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
|
pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
|
||||||
bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
|
bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
|
||||||
&resources);
|
&resources);
|
||||||
if (!bus)
|
|
||||||
pci_free_resource_list(&resources);
|
|
||||||
|
|
||||||
hose->bus = bus;
|
hose->bus = bus;
|
||||||
|
|
||||||
need_domain_info = need_domain_info || hose->index;
|
need_domain_info = need_domain_info || hose->index;
|
||||||
hose->need_domain_info = need_domain_info;
|
hose->need_domain_info = need_domain_info;
|
||||||
if (bus) {
|
|
||||||
|
if (!bus) {
|
||||||
|
pci_free_resource_list(&resources);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
next_busno = bus->busn_res.end + 1;
|
next_busno = bus->busn_res.end + 1;
|
||||||
/* Don't allow 8-bit bus number overflow inside the hose -
|
/* Don't allow 8-bit bus number overflow inside the hose -
|
||||||
reserve some space for bridges. */
|
reserve some space for bridges. */
|
||||||
|
@ -115,7 +117,6 @@ static void pcibios_scanbus(struct pci_controller *hose)
|
||||||
pci_bus_assign_resources(bus);
|
pci_bus_assign_resources(bus);
|
||||||
}
|
}
|
||||||
pci_bus_add_devices(bus);
|
pci_bus_add_devices(bus);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_OF
|
#ifdef CONFIG_OF
|
||||||
|
|
|
@ -58,7 +58,12 @@ static void pcibios_scanbus(struct pci_channel *hose)
|
||||||
|
|
||||||
need_domain_info = need_domain_info || hose->index;
|
need_domain_info = need_domain_info || hose->index;
|
||||||
hose->need_domain_info = need_domain_info;
|
hose->need_domain_info = need_domain_info;
|
||||||
if (bus) {
|
|
||||||
|
if (!bus) {
|
||||||
|
pci_free_resource_list(&resources);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
next_busno = bus->busn_res.end + 1;
|
next_busno = bus->busn_res.end + 1;
|
||||||
/* Don't allow 8-bit bus number overflow inside the hose -
|
/* Don't allow 8-bit bus number overflow inside the hose -
|
||||||
reserve some space for bridges. */
|
reserve some space for bridges. */
|
||||||
|
@ -70,9 +75,6 @@ static void pcibios_scanbus(struct pci_channel *hose)
|
||||||
pci_bus_size_bridges(bus);
|
pci_bus_size_bridges(bus);
|
||||||
pci_bus_assign_resources(bus);
|
pci_bus_assign_resources(bus);
|
||||||
pci_bus_add_devices(bus);
|
pci_bus_add_devices(bus);
|
||||||
} else {
|
|
||||||
pci_free_resource_list(&resources);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -34,16 +34,17 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
|
||||||
|
|
||||||
root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info,
|
root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info,
|
||||||
&resources);
|
&resources);
|
||||||
if (root_bus) {
|
if (!root_bus) {
|
||||||
|
pci_free_resource_list(&resources);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Setup IRQs of all devices using custom routines */
|
/* Setup IRQs of all devices using custom routines */
|
||||||
pci_fixup_irqs(pci_common_swizzle, info->map_irq);
|
pci_fixup_irqs(pci_common_swizzle, info->map_irq);
|
||||||
|
|
||||||
/* Assign devices with resources */
|
/* Assign devices with resources */
|
||||||
pci_assign_unassigned_resources();
|
pci_assign_unassigned_resources();
|
||||||
pci_bus_add_devices(root_bus);
|
pci_bus_add_devices(root_bus);
|
||||||
} else {
|
|
||||||
pci_free_resource_list(&resources);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcibios_fixup_bus(struct pci_bus *pbus)
|
void pcibios_fixup_bus(struct pci_bus *pbus)
|
||||||
|
|
Loading…
Reference in New Issue