aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2015-12-07 19:21:10 -0500
committerBjorn Helgaas <bhelgaas@google.com>2015-12-10 20:38:07 -0500
commit8e5a395a040a7c72ec283f844eca679b924f5f01 (patch)
treecab93b4848466444e76c339fca8f8cab82e4741a
parent9f33a2ae59f24452c1076749deb615bccd435ca9 (diff)
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: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r--drivers/pci/probe.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index edb1984201e9..0d86c82b8880 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1107,14 +1107,11 @@ static int pci_cfg_space_size_ext(struct pci_dev *dev)
1107 int pos = PCI_CFG_SPACE_SIZE; 1107 int pos = PCI_CFG_SPACE_SIZE;
1108 1108
1109 if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL) 1109 if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL)
1110 goto fail; 1110 return PCI_CFG_SPACE_SIZE;
1111 if (status == 0xffffffff || pci_ext_cfg_is_aliased(dev)) 1111 if (status == 0xffffffff || pci_ext_cfg_is_aliased(dev))
1112 goto fail; 1112 return PCI_CFG_SPACE_SIZE;
1113 1113
1114 return PCI_CFG_SPACE_EXP_SIZE; 1114 return PCI_CFG_SPACE_EXP_SIZE;
1115
1116 fail:
1117 return PCI_CFG_SPACE_SIZE;
1118} 1115}
1119 1116
1120int pci_cfg_space_size(struct pci_dev *dev) 1117int pci_cfg_space_size(struct pci_dev *dev)
@@ -1127,19 +1124,17 @@ int pci_cfg_space_size(struct pci_dev *dev)
1127 if (class == PCI_CLASS_BRIDGE_HOST) 1124 if (class == PCI_CLASS_BRIDGE_HOST)
1128 return pci_cfg_space_size_ext(dev); 1125 return pci_cfg_space_size_ext(dev);
1129 1126
1130 if (!pci_is_pcie(dev)) { 1127 if (pci_is_pcie(dev))
1131 pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); 1128 return pci_cfg_space_size_ext(dev);
1132 if (!pos)
1133 goto fail;
1134 1129
1135 pci_read_config_dword(dev, pos + PCI_X_STATUS, &status); 1130 pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
1136 if (!(status & (PCI_X_STATUS_266MHZ | PCI_X_STATUS_533MHZ))) 1131 if (!pos)
1137 goto fail; 1132 return PCI_CFG_SPACE_SIZE;
1138 }
1139 1133
1140 return pci_cfg_space_size_ext(dev); 1134 pci_read_config_dword(dev, pos + PCI_X_STATUS, &status);
1135 if (status & (PCI_X_STATUS_266MHZ | PCI_X_STATUS_533MHZ))
1136 return pci_cfg_space_size_ext(dev);
1141 1137
1142 fail:
1143 return PCI_CFG_SPACE_SIZE; 1138 return PCI_CFG_SPACE_SIZE;
1144} 1139}
1145 1140