@@ -171,9 +171,11 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
SMBBA,
ali15x3_smba))
goto error;
- if (PCIBIOS_SUCCESSFUL != pci_read_config_word(ALI15X3_dev,
- SMBBA, &a))
+
+ pci_read_config_word(ALI15X3_dev, SMBBA, &a);
+ if (a == (u16)~0)
goto error;
+
if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) {
/* make sure it works */
dev_err(&ALI15X3_dev->dev,
@@ -207,7 +207,8 @@ static int elektor_match(struct device *dev, unsigned int id)
if (cy693_dev) {
unsigned char config;
/* yeap, we've found cypress, let's check config */
- if (!pci_read_config_byte(cy693_dev, 0x47, &config)) {
+ pci_read_config_byte(cy693_dev, 0x47, &config);
+ if (config != (u8)~0) {
dev_dbg(dev, "found cy82c693, config "
"register 0x47 = 0x%02x\n", config);
@@ -327,8 +327,8 @@ static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg,
/* Older incarnations of the device used non-standard BARs */
u16 iobase;
- if (pci_read_config_word(dev, alt_reg, &iobase)
- != PCIBIOS_SUCCESSFUL) {
+ pci_read_config_word(dev, alt_reg, &iobase);
+ if (iobase == (u16)~0) {
dev_err(&dev->dev, "Error reading PCI config for %s\n",
name);
return -EIO;
@@ -178,9 +178,11 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev)
if (pci_write_config_word(SIS5595_dev, ACPI_BASE, sis5595_base)
!= PCIBIOS_SUCCESSFUL)
goto error;
- if (pci_read_config_word(SIS5595_dev, ACPI_BASE, &a)
- != PCIBIOS_SUCCESSFUL)
+
+ pci_read_config_word(SIS5595_dev, ACPI_BASE, &a);
+ if (a == (u16)~0)
goto error;
+
if ((a & ~(SIS5595_EXTENT - 1)) != sis5595_base) {
/* doesn't work for some chips! */
dev_err(&SIS5595_dev->dev, "force address failed - not supported?\n");
@@ -188,17 +190,20 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev)
}
}
- if (pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val)
- != PCIBIOS_SUCCESSFUL)
+ pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val);
+ if (val == (u8)~0)
goto error;
+
if ((val & 0x80) == 0) {
dev_info(&SIS5595_dev->dev, "enabling ACPI\n");
if (pci_write_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, val | 0x80)
!= PCIBIOS_SUCCESSFUL)
goto error;
- if (pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val)
- != PCIBIOS_SUCCESSFUL)
+
+ pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val);
+ if (val == (u8)~0)
goto error;
+
if ((val & 0x80) == 0) {
/* doesn't work for some chips? */
dev_err(&SIS5595_dev->dev, "ACPI enable failed - not supported?\n");
@@ -430,7 +430,8 @@ static int sis630_setup(struct pci_dev *sis630_dev)
Enable ACPI first , so we can accsess reg 74-75
in acpi io space and read acpi base addr
*/
- if (pci_read_config_byte(sis630_dev, SIS630_BIOS_CTL_REG, &b)) {
+ pci_read_config_byte(sis630_dev, SIS630_BIOS_CTL_REG, &b);
+ if (b == (u8)~0) {
dev_err(&sis630_dev->dev, "Error: Can't read bios ctl reg\n");
retval = -ENODEV;
goto exit;
@@ -444,8 +445,8 @@ static int sis630_setup(struct pci_dev *sis630_dev)
}
/* Determine the ACPI base address */
- if (pci_read_config_word(sis630_dev,
- SIS630_ACPI_BASE_REG, &acpi_base)) {
+ pci_read_config_word(sis630_dev, SIS630_ACPI_BASE_REG, &acpi_base);
+ if (acpi_base == (u16)~0) {
dev_err(&sis630_dev->dev,
"Error: Can't determine ACPI base address\n");
retval = -ENODEV;
@@ -321,12 +321,13 @@ static int vt596_probe(struct pci_dev *pdev,
goto found;
}
- if ((pci_read_config_word(pdev, id->driver_data, &vt596_smba)) ||
- !(vt596_smba & 0x0001)) {
+ pci_read_config_word(pdev, id->driver_data, &vt596_smba);
+ if ((vt596_smba == (u16)~0) || !(vt596_smba & 0x0001)) {
/* try 2nd address and config reg. for 596 */
- if (id->device == PCI_DEVICE_ID_VIA_82C596_3 &&
- !pci_read_config_word(pdev, SMBBA2, &vt596_smba) &&
- (vt596_smba & 0x0001)) {
+ pci_read_config_word(pdev, SMBBA2, &vt596_smba);
+ if ((id->device == PCI_DEVICE_ID_VIA_82C596_3) &&
+ (vt596_smba != (u16)~0) &&
+ (vt596_smba & 0x0001)) {
SMBHSTCFG = 0x84;
} else {
/* no matches at all */
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/i2c/busses/i2c-ali15x3.c | 6 ++++-- drivers/i2c/busses/i2c-elektor.c | 3 ++- drivers/i2c/busses/i2c-nforce2.c | 4 ++-- drivers/i2c/busses/i2c-sis5595.c | 17 +++++++++++------ drivers/i2c/busses/i2c-sis630.c | 7 ++++--- drivers/i2c/busses/i2c-viapro.c | 11 ++++++----- 6 files changed, 29 insertions(+), 19 deletions(-)