diff options
author | Saheed O. Bolarinwa <refactormyself@gmail.com> | 2020-08-01 14:24:39 +0300 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2020-08-05 00:24:39 +0300 |
commit | 2207515db60a6885e11069251d4f4ca4bf3abb6b (patch) | |
tree | d0c8d76b97ee1bf5606fb94a8b72b549c2b60f92 /drivers/hwmon/i5k_amb.c | |
parent | 2fdf8f7f086712bbe296d1d4d4049ca88e7a662d (diff) | |
download | linux-2207515db60a6885e11069251d4f4ca4bf3abb6b.tar.xz |
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 <bjorn@helgaas.com>
Signed-off-by: Saheed O. Bolarinwa <refactormyself@gmail.com>
Link: https://lore.kernel.org/r/20200801112446.149549-11-refactormyself@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/i5k_amb.c')
-rw-r--r-- | drivers/hwmon/i5k_amb.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c index cd5b62905eee..783fa936e4d1 100644 --- a/drivers/hwmon/i5k_amb.c +++ b/drivers/hwmon/i5k_amb.c @@ -427,11 +427,13 @@ static int i5k_find_amb_registers(struct i5k_amb_data *data, if (!pcidev) return -ENODEV; - if (pci_read_config_dword(pcidev, I5K_REG_AMB_BASE_ADDR, &val32)) + pci_read_config_dword(pcidev, I5K_REG_AMB_BASE_ADDR, &val32); + if (val32 == (u32)~0) goto out; data->amb_base = val32; - if (pci_read_config_dword(pcidev, I5K_REG_AMB_LEN_ADDR, &val32)) + pci_read_config_dword(pcidev, I5K_REG_AMB_LEN_ADDR, &val32); + if (val32 == (u32)~0) goto out; data->amb_len = val32; @@ -458,11 +460,13 @@ static int i5k_channel_probe(u16 *amb_present, unsigned long dev_id) if (!pcidev) return -ENODEV; - if (pci_read_config_word(pcidev, I5K_REG_CHAN0_PRESENCE_ADDR, &val16)) + pci_read_config_word(pcidev, I5K_REG_CHAN0_PRESENCE_ADDR, &val16); + if (val16 == (u16)~0) goto out; amb_present[0] = val16; - if (pci_read_config_word(pcidev, I5K_REG_CHAN1_PRESENCE_ADDR, &val16)) + pci_read_config_word(pcidev, I5K_REG_CHAN1_PRESENCE_ADDR, &val16); + if (val16 == (u16)~0) goto out; amb_present[1] = val16; |