mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
PCI: cpqphp: Fix PCIBIOS_* return value confusion
[ Upstream commit e2226dbc4a4919d9c8bd9293299b532090bdf020 ]
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: 1da177e4c3 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
60f5d361ae
commit
4e9d6942d1
@@ -135,11 +135,13 @@ int cpqhp_unconfigure_device(struct pci_func *func)
|
|||||||
static int PCI_RefinedAccessConfig(struct pci_bus *bus, unsigned int devfn, u8 offset, u32 *value)
|
static int PCI_RefinedAccessConfig(struct pci_bus *bus, unsigned int devfn, u8 offset, u32 *value)
|
||||||
{
|
{
|
||||||
u32 vendID = 0;
|
u32 vendID = 0;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &vendID) == -1)
|
ret = pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &vendID);
|
||||||
return -1;
|
if (ret != PCIBIOS_SUCCESSFUL)
|
||||||
|
return PCIBIOS_DEVICE_NOT_FOUND;
|
||||||
if (PCI_POSSIBLE_ERROR(vendID))
|
if (PCI_POSSIBLE_ERROR(vendID))
|
||||||
return -1;
|
return PCIBIOS_DEVICE_NOT_FOUND;
|
||||||
return pci_bus_read_config_dword(bus, devfn, offset, value);
|
return pci_bus_read_config_dword(bus, devfn, offset, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,13 +204,15 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_
|
|||||||
{
|
{
|
||||||
u16 tdevice;
|
u16 tdevice;
|
||||||
u32 work;
|
u32 work;
|
||||||
|
int ret;
|
||||||
u8 tbus;
|
u8 tbus;
|
||||||
|
|
||||||
ctrl->pci_bus->number = bus_num;
|
ctrl->pci_bus->number = bus_num;
|
||||||
|
|
||||||
for (tdevice = 0; tdevice < 0xFF; tdevice++) {
|
for (tdevice = 0; tdevice < 0xFF; tdevice++) {
|
||||||
/* Scan for access first */
|
/* Scan for access first */
|
||||||
if (PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work) == -1)
|
ret = PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work);
|
||||||
|
if (ret)
|
||||||
continue;
|
continue;
|
||||||
dbg("Looking for nonbridge bus_num %d dev_num %d\n", bus_num, tdevice);
|
dbg("Looking for nonbridge bus_num %d dev_num %d\n", bus_num, tdevice);
|
||||||
/* Yep we got one. Not a bridge ? */
|
/* Yep we got one. Not a bridge ? */
|
||||||
@@ -220,7 +224,8 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_
|
|||||||
}
|
}
|
||||||
for (tdevice = 0; tdevice < 0xFF; tdevice++) {
|
for (tdevice = 0; tdevice < 0xFF; tdevice++) {
|
||||||
/* Scan for access first */
|
/* Scan for access first */
|
||||||
if (PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work) == -1)
|
ret = PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work);
|
||||||
|
if (ret)
|
||||||
continue;
|
continue;
|
||||||
dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice);
|
dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice);
|
||||||
/* Yep we got one. bridge ? */
|
/* Yep we got one. bridge ? */
|
||||||
|
|||||||
Reference in New Issue
Block a user