Skip to content

Commit 2207515

Browse files
refactormyselfgroeck
authored andcommitted
hwmon: (i5k_amb, vt8231) Drop uses of pci_read_config_*() return value
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 <[email protected]> Signed-off-by: Saheed O. Bolarinwa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 2fdf8f7 commit 2207515

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

drivers/hwmon/i5k_amb.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,13 @@ static int i5k_find_amb_registers(struct i5k_amb_data *data,
427427
if (!pcidev)
428428
return -ENODEV;
429429

430-
if (pci_read_config_dword(pcidev, I5K_REG_AMB_BASE_ADDR, &val32))
430+
pci_read_config_dword(pcidev, I5K_REG_AMB_BASE_ADDR, &val32);
431+
if (val32 == (u32)~0)
431432
goto out;
432433
data->amb_base = val32;
433434

434-
if (pci_read_config_dword(pcidev, I5K_REG_AMB_LEN_ADDR, &val32))
435+
pci_read_config_dword(pcidev, I5K_REG_AMB_LEN_ADDR, &val32);
436+
if (val32 == (u32)~0)
435437
goto out;
436438
data->amb_len = val32;
437439

@@ -458,11 +460,13 @@ static int i5k_channel_probe(u16 *amb_present, unsigned long dev_id)
458460
if (!pcidev)
459461
return -ENODEV;
460462

461-
if (pci_read_config_word(pcidev, I5K_REG_CHAN0_PRESENCE_ADDR, &val16))
463+
pci_read_config_word(pcidev, I5K_REG_CHAN0_PRESENCE_ADDR, &val16);
464+
if (val16 == (u16)~0)
462465
goto out;
463466
amb_present[0] = val16;
464467

465-
if (pci_read_config_word(pcidev, I5K_REG_CHAN1_PRESENCE_ADDR, &val16))
468+
pci_read_config_word(pcidev, I5K_REG_CHAN1_PRESENCE_ADDR, &val16);
469+
if (val16 == (u16)~0)
466470
goto out;
467471
amb_present[1] = val16;
468472

drivers/hwmon/vt8231.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -992,8 +992,8 @@ static int vt8231_pci_probe(struct pci_dev *dev,
992992
return -ENODEV;
993993
}
994994

995-
if (PCIBIOS_SUCCESSFUL != pci_read_config_word(dev, VT8231_BASE_REG,
996-
&val))
995+
pci_read_config_word(dev, VT8231_BASE_REG, &val);
996+
if (val == (u16)~0)
997997
return -ENODEV;
998998

999999
address = val & ~(VT8231_EXTENT - 1);
@@ -1002,8 +1002,8 @@ static int vt8231_pci_probe(struct pci_dev *dev,
10021002
return -ENODEV;
10031003
}
10041004

1005-
if (PCIBIOS_SUCCESSFUL != pci_read_config_word(dev, VT8231_ENABLE_REG,
1006-
&val))
1005+
pci_read_config_word(dev, VT8231_ENABLE_REG, &val);
1006+
if (val == (u16)~0)
10071007
return -ENODEV;
10081008

10091009
if (!(val & 0x0001)) {

0 commit comments

Comments
 (0)