Skip to content

Commit 752430d

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: cpqphp: Use pci_bus_read_dev_vendor_id() to detect presence
The intent of the first part in PCI_RefinedAccessConfig() is to read Vendor ID register and detect presence of the device that way. Remove PCI_RefinedAccessConfig() (which was not named very helpfully to begin with) and replace the call with pci_bus_read_dev_vendor_id() + read config because it makes the logic more obvious at the caller side. Link: https://lore.kernel.org/r/20241022091140.3504-3-ilpo.jarvinen@linux.intel.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent e2226db commit 752430d

1 file changed

Lines changed: 6 additions & 16 deletions

File tree

drivers/pci/hotplug/cpqphp_pci.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,6 @@ int cpqhp_unconfigure_device(struct pci_func *func)
132132
return 0;
133133
}
134134

135-
static int PCI_RefinedAccessConfig(struct pci_bus *bus, unsigned int devfn, u8 offset, u32 *value)
136-
{
137-
u32 vendID = 0;
138-
int ret;
139-
140-
ret = pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &vendID);
141-
if (ret != PCIBIOS_SUCCESSFUL)
142-
return PCIBIOS_DEVICE_NOT_FOUND;
143-
if (PCI_POSSIBLE_ERROR(vendID))
144-
return PCIBIOS_DEVICE_NOT_FOUND;
145-
return pci_bus_read_config_dword(bus, devfn, offset, value);
146-
}
147-
148-
149135
/*
150136
* cpqhp_set_irq
151137
*
@@ -211,7 +197,9 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_
211197

212198
for (tdevice = 0; tdevice < 0xFF; tdevice++) {
213199
/* Scan for access first */
214-
ret = PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work);
200+
if (!pci_bus_read_dev_vendor_id(ctrl->pci_bus, tdevice, &work, 0))
201+
continue;
202+
ret = pci_bus_read_config_dword(ctrl->pci_bus, tdevice, 0x08, &work);
215203
if (ret)
216204
continue;
217205
dbg("Looking for nonbridge bus_num %d dev_num %d\n", bus_num, tdevice);
@@ -224,7 +212,9 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_
224212
}
225213
for (tdevice = 0; tdevice < 0xFF; tdevice++) {
226214
/* Scan for access first */
227-
ret = PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work);
215+
if (!pci_bus_read_dev_vendor_id(ctrl->pci_bus, tdevice, &work, 0))
216+
continue;
217+
ret = pci_bus_read_config_dword(ctrl->pci_bus, tdevice, 0x08, &work);
228218
if (ret)
229219
continue;
230220
dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice);

0 commit comments

Comments
 (0)