Commit 69b97cf5 authored by Jean Delvare's avatar Jean Delvare Committed by Greg Kroah-Hartman

i2c: Fix error value returned by several bus drivers

commit 7c1f59c9 upstream.

When adding checks for ACPI resource conflicts to many bus drivers,
not enough attention was paid to the error paths, and for several
drivers this causes 0 to be returned on error in some cases. Fix this
by properly returning a non-zero value on every error.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 172b291a
...@@ -140,7 +140,7 @@ static unsigned short ali1535_smba; ...@@ -140,7 +140,7 @@ static unsigned short ali1535_smba;
defined to make the transition easier. */ defined to make the transition easier. */
static int __devinit ali1535_setup(struct pci_dev *dev) static int __devinit ali1535_setup(struct pci_dev *dev)
{ {
int retval = -ENODEV; int retval;
unsigned char temp; unsigned char temp;
/* Check the following things: /* Check the following things:
...@@ -155,6 +155,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev) ...@@ -155,6 +155,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev)
if (ali1535_smba == 0) { if (ali1535_smba == 0) {
dev_warn(&dev->dev, dev_warn(&dev->dev,
"ALI1535_smb region uninitialized - upgrade BIOS?\n"); "ALI1535_smb region uninitialized - upgrade BIOS?\n");
retval = -ENODEV;
goto exit; goto exit;
} }
...@@ -167,6 +168,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev) ...@@ -167,6 +168,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev)
ali1535_driver.name)) { ali1535_driver.name)) {
dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n", dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n",
ali1535_smba); ali1535_smba);
retval = -EBUSY;
goto exit; goto exit;
} }
...@@ -174,6 +176,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev) ...@@ -174,6 +176,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev)
pci_read_config_byte(dev, SMBCFG, &temp); pci_read_config_byte(dev, SMBCFG, &temp);
if ((temp & ALI1535_SMBIO_EN) == 0) { if ((temp & ALI1535_SMBIO_EN) == 0) {
dev_err(&dev->dev, "SMB device not enabled - upgrade BIOS?\n"); dev_err(&dev->dev, "SMB device not enabled - upgrade BIOS?\n");
retval = -ENODEV;
goto exit_free; goto exit_free;
} }
...@@ -181,6 +184,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev) ...@@ -181,6 +184,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev)
pci_read_config_byte(dev, SMBHSTCFG, &temp); pci_read_config_byte(dev, SMBHSTCFG, &temp);
if ((temp & 1) == 0) { if ((temp & 1) == 0) {
dev_err(&dev->dev, "SMBus controller not enabled - upgrade BIOS?\n"); dev_err(&dev->dev, "SMBus controller not enabled - upgrade BIOS?\n");
retval = -ENODEV;
goto exit_free; goto exit_free;
} }
...@@ -198,12 +202,11 @@ static int __devinit ali1535_setup(struct pci_dev *dev) ...@@ -198,12 +202,11 @@ static int __devinit ali1535_setup(struct pci_dev *dev)
dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp); dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp);
dev_dbg(&dev->dev, "ALI1535_smba = 0x%X\n", ali1535_smba); dev_dbg(&dev->dev, "ALI1535_smba = 0x%X\n", ali1535_smba);
retval = 0; return 0;
exit:
return retval;
exit_free: exit_free:
release_region(ali1535_smba, ALI1535_SMB_IOSIZE); release_region(ali1535_smba, ALI1535_SMB_IOSIZE);
exit:
return retval; return retval;
} }
......
...@@ -356,7 +356,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar, ...@@ -356,7 +356,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
error = acpi_check_region(smbus->base, smbus->size, error = acpi_check_region(smbus->base, smbus->size,
nforce2_driver.name); nforce2_driver.name);
if (error) if (error)
return -1; return error;
if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) {
dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n",
......
...@@ -147,7 +147,7 @@ static int __devinit sis5595_setup(struct pci_dev *SIS5595_dev) ...@@ -147,7 +147,7 @@ static int __devinit sis5595_setup(struct pci_dev *SIS5595_dev)
u16 a; u16 a;
u8 val; u8 val;
int *i; int *i;
int retval = -ENODEV; int retval;
/* Look for imposters */ /* Look for imposters */
for (i = blacklist; *i != 0; i++) { for (i = blacklist; *i != 0; i++) {
...@@ -223,7 +223,7 @@ static int __devinit sis5595_setup(struct pci_dev *SIS5595_dev) ...@@ -223,7 +223,7 @@ static int __devinit sis5595_setup(struct pci_dev *SIS5595_dev)
error: error:
release_region(sis5595_base + SMB_INDEX, 2); release_region(sis5595_base + SMB_INDEX, 2);
return retval; return -ENODEV;
} }
static int sis5595_transaction(struct i2c_adapter *adap) static int sis5595_transaction(struct i2c_adapter *adap)
......
...@@ -393,7 +393,7 @@ static int __devinit sis630_setup(struct pci_dev *sis630_dev) ...@@ -393,7 +393,7 @@ static int __devinit sis630_setup(struct pci_dev *sis630_dev)
{ {
unsigned char b; unsigned char b;
struct pci_dev *dummy = NULL; struct pci_dev *dummy = NULL;
int retval = -ENODEV, i; int retval, i;
/* check for supported SiS devices */ /* check for supported SiS devices */
for (i=0; supported[i] > 0 ; i++) { for (i=0; supported[i] > 0 ; i++) {
...@@ -418,18 +418,21 @@ static int __devinit sis630_setup(struct pci_dev *sis630_dev) ...@@ -418,18 +418,21 @@ static int __devinit sis630_setup(struct pci_dev *sis630_dev)
*/ */
if (pci_read_config_byte(sis630_dev, SIS630_BIOS_CTL_REG,&b)) { if (pci_read_config_byte(sis630_dev, SIS630_BIOS_CTL_REG,&b)) {
dev_err(&sis630_dev->dev, "Error: Can't read bios ctl reg\n"); dev_err(&sis630_dev->dev, "Error: Can't read bios ctl reg\n");
retval = -ENODEV;
goto exit; goto exit;
} }
/* if ACPI already enabled , do nothing */ /* if ACPI already enabled , do nothing */
if (!(b & 0x80) && if (!(b & 0x80) &&
pci_write_config_byte(sis630_dev, SIS630_BIOS_CTL_REG, b | 0x80)) { pci_write_config_byte(sis630_dev, SIS630_BIOS_CTL_REG, b | 0x80)) {
dev_err(&sis630_dev->dev, "Error: Can't enable ACPI\n"); dev_err(&sis630_dev->dev, "Error: Can't enable ACPI\n");
retval = -ENODEV;
goto exit; goto exit;
} }
/* Determine the ACPI base address */ /* Determine the ACPI base address */
if (pci_read_config_word(sis630_dev,SIS630_ACPI_BASE_REG,&acpi_base)) { if (pci_read_config_word(sis630_dev,SIS630_ACPI_BASE_REG,&acpi_base)) {
dev_err(&sis630_dev->dev, "Error: Can't determine ACPI base address\n"); dev_err(&sis630_dev->dev, "Error: Can't determine ACPI base address\n");
retval = -ENODEV;
goto exit; goto exit;
} }
...@@ -445,6 +448,7 @@ static int __devinit sis630_setup(struct pci_dev *sis630_dev) ...@@ -445,6 +448,7 @@ static int __devinit sis630_setup(struct pci_dev *sis630_dev)
sis630_driver.name)) { sis630_driver.name)) {
dev_err(&sis630_dev->dev, "SMBus registers 0x%04x-0x%04x already " dev_err(&sis630_dev->dev, "SMBus registers 0x%04x-0x%04x already "
"in use!\n", acpi_base + SMB_STS, acpi_base + SMB_SAA); "in use!\n", acpi_base + SMB_STS, acpi_base + SMB_SAA);
retval = -EBUSY;
goto exit; goto exit;
} }
......
...@@ -324,7 +324,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev, ...@@ -324,7 +324,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
const struct pci_device_id *id) const struct pci_device_id *id)
{ {
unsigned char temp; unsigned char temp;
int error = -ENODEV; int error;
/* Determine the address of the SMBus areas */ /* Determine the address of the SMBus areas */
if (force_addr) { if (force_addr) {
...@@ -390,6 +390,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev, ...@@ -390,6 +390,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
dev_err(&pdev->dev, "SMBUS: Error: Host SMBus " dev_err(&pdev->dev, "SMBUS: Error: Host SMBus "
"controller not enabled! - upgrade BIOS or " "controller not enabled! - upgrade BIOS or "
"use force=1\n"); "use force=1\n");
error = -ENODEV;
goto release_region; goto release_region;
} }
} }
...@@ -422,9 +423,11 @@ static int __devinit vt596_probe(struct pci_dev *pdev, ...@@ -422,9 +423,11 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
"SMBus Via Pro adapter at %04x", vt596_smba); "SMBus Via Pro adapter at %04x", vt596_smba);
vt596_pdev = pci_dev_get(pdev); vt596_pdev = pci_dev_get(pdev);
if (i2c_add_adapter(&vt596_adapter)) { error = i2c_add_adapter(&vt596_adapter);
if (error) {
pci_dev_put(vt596_pdev); pci_dev_put(vt596_pdev);
vt596_pdev = NULL; vt596_pdev = NULL;
goto release_region;
} }
/* Always return failure here. This is to allow other drivers to bind /* Always return failure here. This is to allow other drivers to bind
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment