Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: cpqphp: Fix PCIBIOS_* return value confusion

Code in and related to PCI_RefinedAccessConfig() has three types of return
type confusion:

- PCI_RefinedAccessConfig() tests pci_bus_read_config_dword() return value
against -1.

- PCI_RefinedAccessConfig() returns both -1 and PCIBIOS_* return codes.

- Callers of PCI_RefinedAccessConfig() only test for -1.

Make PCI_RefinedAccessConfig() return PCIBIOS_* codes consistently and
adapt callers accordingly.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Link: https://lore.kernel.org/r/20241022091140.3504-2-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Ilpo Järvinen and committed by
Bjorn Helgaas
e2226dbc 91a62967

+10 -5
+10 -5
drivers/pci/hotplug/cpqphp_pci.c
··· 135 135 static int PCI_RefinedAccessConfig(struct pci_bus *bus, unsigned int devfn, u8 offset, u32 *value) 136 136 { 137 137 u32 vendID = 0; 138 + int ret; 138 139 139 - if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &vendID) == -1) 140 - return -1; 140 + ret = pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &vendID); 141 + if (ret != PCIBIOS_SUCCESSFUL) 142 + return PCIBIOS_DEVICE_NOT_FOUND; 141 143 if (PCI_POSSIBLE_ERROR(vendID)) 142 - return -1; 144 + return PCIBIOS_DEVICE_NOT_FOUND; 143 145 return pci_bus_read_config_dword(bus, devfn, offset, value); 144 146 } 145 147 ··· 204 202 { 205 203 u16 tdevice; 206 204 u32 work; 205 + int ret; 207 206 u8 tbus; 208 207 209 208 ctrl->pci_bus->number = bus_num; 210 209 211 210 for (tdevice = 0; tdevice < 0xFF; tdevice++) { 212 211 /* Scan for access first */ 213 - if (PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work) == -1) 212 + ret = PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work); 213 + if (ret) 214 214 continue; 215 215 dbg("Looking for nonbridge bus_num %d dev_num %d\n", bus_num, tdevice); 216 216 /* Yep we got one. Not a bridge ? */ ··· 224 220 } 225 221 for (tdevice = 0; tdevice < 0xFF; tdevice++) { 226 222 /* Scan for access first */ 227 - if (PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work) == -1) 223 + ret = PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work); 224 + if (ret) 228 225 continue; 229 226 dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice); 230 227 /* Yep we got one. bridge ? */