diff mbox series

[RFC,03/17] bcma: Drop uses of pci_read_config_*() return value

Message ID 20200801112446.149549-4-refactormyself@gmail.com
State New
Delegated to: Bjorn Helgaas
Headers show
Series Drop uses of pci_read_config_*() return value | expand

Commit Message

Saheed Olayemi Bolarinwa Aug. 1, 2020, 11:24 a.m. UTC
The return value of pci_read_config_*() may not indicate a device error.
However, the value read by these functions is more likely to indicate
this kind of error. This presents two overlapping ways of reporting
errors and complicates error checking.

It is possible to move to one single way of checking for error if the
dependency on the return value of these functions is removed, then it
can later be made to return void.

Remove all uses of the return value of pci_read_config_*().
Check the actual value read for ~0. In this case, ~0 is an invalid
value thus it indicates some kind of error.

Suggested-by: Bjorn Helgaas <bjorn@helgaas.com>
Signed-off-by: Saheed O. Bolarinwa <refactormyself@gmail.com>
 drivers/bcma/host_pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series


diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
index 69c10a7b7c61..912d5311a444 100644
--- a/drivers/bcma/host_pci.c
+++ b/drivers/bcma/host_pci.c
@@ -372,9 +372,11 @@  int bcma_host_pci_irq_ctl(struct bcma_bus *bus, struct bcma_device *core,
 	pdev = bus->host_pci;
-	err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp);
-	if (err)
+	pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp);
+	if (tmp == (u32)~0) {
+		err = -ENODEV;
 		goto out;
+	}
 	coremask = BIT(core->core_index) << 8;
 	if (enable)