Skip to content

Commit c37f836

Browse files
elkablogregkh
authored andcommitted
PCI: aardvark: Deduplicate code in advk_pcie_rd_conf()
commit 67cb2a4 upstream. Avoid code repetition in advk_pcie_rd_conf() by handling errors with goto jump, as is customary in kernel. Link: https://lore.kernel.org/r/20211005180952.6812-9-kabel@kernel.org Fixes: 43f5c77 ("PCI: aardvark: Fix reporting CRS value") Signed-off-by: Marek Behún <kabel@kernel.org> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a0a7875 commit c37f836

1 file changed

Lines changed: 20 additions & 28 deletions

File tree

drivers/pci/controller/pci-aardvark.c

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,18 +1090,8 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
10901090
(le16_to_cpu(pcie->bridge.pcie_conf.rootctl) &
10911091
PCI_EXP_RTCTL_CRSSVE);
10921092

1093-
if (advk_pcie_pio_is_running(pcie)) {
1094-
/*
1095-
* If it is possible return Completion Retry Status so caller
1096-
* tries to issue the request again instead of failing.
1097-
*/
1098-
if (allow_crs) {
1099-
*val = CFG_RD_CRS_VAL;
1100-
return PCIBIOS_SUCCESSFUL;
1101-
}
1102-
*val = 0xffffffff;
1103-
return PCIBIOS_SET_FAILED;
1104-
}
1093+
if (advk_pcie_pio_is_running(pcie))
1094+
goto try_crs;
11051095

11061096
/* Program the control register */
11071097
reg = advk_readl(pcie, PIO_CTRL);
@@ -1125,32 +1115,34 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
11251115
advk_writel(pcie, 1, PIO_START);
11261116

11271117
ret = advk_pcie_wait_pio(pcie);
1128-
if (ret < 0) {
1129-
/*
1130-
* If it is possible return Completion Retry Status so caller
1131-
* tries to issue the request again instead of failing.
1132-
*/
1133-
if (allow_crs) {
1134-
*val = CFG_RD_CRS_VAL;
1135-
return PCIBIOS_SUCCESSFUL;
1136-
}
1137-
*val = 0xffffffff;
1138-
return PCIBIOS_SET_FAILED;
1139-
}
1118+
if (ret < 0)
1119+
goto try_crs;
11401120

11411121
/* Check PIO status and get the read result */
11421122
ret = advk_pcie_check_pio_status(pcie, allow_crs, val);
1143-
if (ret < 0) {
1144-
*val = 0xffffffff;
1145-
return PCIBIOS_SET_FAILED;
1146-
}
1123+
if (ret < 0)
1124+
goto fail;
11471125

11481126
if (size == 1)
11491127
*val = (*val >> (8 * (where & 3))) & 0xff;
11501128
else if (size == 2)
11511129
*val = (*val >> (8 * (where & 3))) & 0xffff;
11521130

11531131
return PCIBIOS_SUCCESSFUL;
1132+
1133+
try_crs:
1134+
/*
1135+
* If it is possible, return Completion Retry Status so that caller
1136+
* tries to issue the request again instead of failing.
1137+
*/
1138+
if (allow_crs) {
1139+
*val = CFG_RD_CRS_VAL;
1140+
return PCIBIOS_SUCCESSFUL;
1141+
}
1142+
1143+
fail:
1144+
*val = 0xffffffff;
1145+
return PCIBIOS_SET_FAILED;
11541146
}
11551147

11561148
static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,

0 commit comments

Comments
 (0)