Commit 8e5a395a authored by Bjorn Helgaas's avatar Bjorn Helgaas

PCI: Simplify config space size computation

Restructure the logic so we return the config space size as soon as we know
it.  This reduces indentation, removes negations, and removes gotos.

No functional change.
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 9f33a2ae
...@@ -1107,14 +1107,11 @@ static int pci_cfg_space_size_ext(struct pci_dev *dev) ...@@ -1107,14 +1107,11 @@ static int pci_cfg_space_size_ext(struct pci_dev *dev)
int pos = PCI_CFG_SPACE_SIZE; int pos = PCI_CFG_SPACE_SIZE;
if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL) if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL)
goto fail; return PCI_CFG_SPACE_SIZE;
if (status == 0xffffffff || pci_ext_cfg_is_aliased(dev)) if (status == 0xffffffff || pci_ext_cfg_is_aliased(dev))
goto fail; return PCI_CFG_SPACE_SIZE;
return PCI_CFG_SPACE_EXP_SIZE; return PCI_CFG_SPACE_EXP_SIZE;
fail:
return PCI_CFG_SPACE_SIZE;
} }
int pci_cfg_space_size(struct pci_dev *dev) int pci_cfg_space_size(struct pci_dev *dev)
...@@ -1127,19 +1124,17 @@ int pci_cfg_space_size(struct pci_dev *dev) ...@@ -1127,19 +1124,17 @@ int pci_cfg_space_size(struct pci_dev *dev)
if (class == PCI_CLASS_BRIDGE_HOST) if (class == PCI_CLASS_BRIDGE_HOST)
return pci_cfg_space_size_ext(dev); return pci_cfg_space_size_ext(dev);
if (!pci_is_pcie(dev)) { if (pci_is_pcie(dev))
return pci_cfg_space_size_ext(dev);
pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
if (!pos) if (!pos)
goto fail; return PCI_CFG_SPACE_SIZE;
pci_read_config_dword(dev, pos + PCI_X_STATUS, &status); pci_read_config_dword(dev, pos + PCI_X_STATUS, &status);
if (!(status & (PCI_X_STATUS_266MHZ | PCI_X_STATUS_533MHZ))) if (status & (PCI_X_STATUS_266MHZ | PCI_X_STATUS_533MHZ))
goto fail;
}
return pci_cfg_space_size_ext(dev); return pci_cfg_space_size_ext(dev);
fail:
return PCI_CFG_SPACE_SIZE; return PCI_CFG_SPACE_SIZE;
} }
......
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