diff options
author | Jean Delvare <khali@linux-fr.org> | 2012-01-12 14:32:03 -0500 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2012-01-12 14:32:03 -0500 |
commit | 7c1f59c9d5caf3a84f35549b5d58f3c055a68da5 (patch) | |
tree | ff3ff814f1c2cbf7e5cd6244d9c5e4ddd5b4e2bd /drivers/i2c | |
parent | a429638cac1e5c656818a45aaff78df7b743004e (diff) |
i2c: Fix error value returned by several bus drivers
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: Jean Delvare <khali@linux-fr.org>
Cc: stable@kernel.org
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-ali1535.c | 11 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-nforce2.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-sis5595.c | 4 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-sis630.c | 6 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-viapro.c | 7 |
5 files changed, 20 insertions, 10 deletions
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index b6807db7b36f..5b667e53a813 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
@@ -140,7 +140,7 @@ static unsigned short ali1535_smba; | |||
140 | defined to make the transition easier. */ | 140 | defined to make the transition easier. */ |
141 | static int __devinit ali1535_setup(struct pci_dev *dev) | 141 | static int __devinit ali1535_setup(struct pci_dev *dev) |
142 | { | 142 | { |
143 | int retval = -ENODEV; | 143 | int retval; |
144 | unsigned char temp; | 144 | unsigned char temp; |
145 | 145 | ||
146 | /* Check the following things: | 146 | /* Check the following things: |
@@ -155,6 +155,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev) | |||
155 | if (ali1535_smba == 0) { | 155 | if (ali1535_smba == 0) { |
156 | dev_warn(&dev->dev, | 156 | dev_warn(&dev->dev, |
157 | "ALI1535_smb region uninitialized - upgrade BIOS?\n"); | 157 | "ALI1535_smb region uninitialized - upgrade BIOS?\n"); |
158 | retval = -ENODEV; | ||
158 | goto exit; | 159 | goto exit; |
159 | } | 160 | } |
160 | 161 | ||
@@ -167,6 +168,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev) | |||
167 | ali1535_driver.name)) { | 168 | ali1535_driver.name)) { |
168 | dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n", | 169 | dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n", |
169 | ali1535_smba); | 170 | ali1535_smba); |
171 | retval = -EBUSY; | ||
170 | goto exit; | 172 | goto exit; |
171 | } | 173 | } |
172 | 174 | ||
@@ -174,6 +176,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev) | |||
174 | pci_read_config_byte(dev, SMBCFG, &temp); | 176 | pci_read_config_byte(dev, SMBCFG, &temp); |
175 | if ((temp & ALI1535_SMBIO_EN) == 0) { | 177 | if ((temp & ALI1535_SMBIO_EN) == 0) { |
176 | dev_err(&dev->dev, "SMB device not enabled - upgrade BIOS?\n"); | 178 | dev_err(&dev->dev, "SMB device not enabled - upgrade BIOS?\n"); |
179 | retval = -ENODEV; | ||
177 | goto exit_free; | 180 | goto exit_free; |
178 | } | 181 | } |
179 | 182 | ||
@@ -181,6 +184,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev) | |||
181 | pci_read_config_byte(dev, SMBHSTCFG, &temp); | 184 | pci_read_config_byte(dev, SMBHSTCFG, &temp); |
182 | if ((temp & 1) == 0) { | 185 | if ((temp & 1) == 0) { |
183 | dev_err(&dev->dev, "SMBus controller not enabled - upgrade BIOS?\n"); | 186 | dev_err(&dev->dev, "SMBus controller not enabled - upgrade BIOS?\n"); |
187 | retval = -ENODEV; | ||
184 | goto exit_free; | 188 | goto exit_free; |
185 | } | 189 | } |
186 | 190 | ||
@@ -198,12 +202,11 @@ static int __devinit ali1535_setup(struct pci_dev *dev) | |||
198 | dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp); | 202 | dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp); |
199 | dev_dbg(&dev->dev, "ALI1535_smba = 0x%X\n", ali1535_smba); | 203 | dev_dbg(&dev->dev, "ALI1535_smba = 0x%X\n", ali1535_smba); |
200 | 204 | ||
201 | retval = 0; | 205 | return 0; |
202 | exit: | ||
203 | return retval; | ||
204 | 206 | ||
205 | exit_free: | 207 | exit_free: |
206 | release_region(ali1535_smba, ALI1535_SMB_IOSIZE); | 208 | release_region(ali1535_smba, ALI1535_SMB_IOSIZE); |
209 | exit: | ||
207 | return retval; | 210 | return retval; |
208 | } | 211 | } |
209 | 212 | ||
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index ff1e127dfea8..4853b52a40a8 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c | |||
@@ -356,7 +356,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar, | |||
356 | error = acpi_check_region(smbus->base, smbus->size, | 356 | error = acpi_check_region(smbus->base, smbus->size, |
357 | nforce2_driver.name); | 357 | nforce2_driver.name); |
358 | if (error) | 358 | if (error) |
359 | return -1; | 359 | return error; |
360 | 360 | ||
361 | if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { | 361 | if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { |
362 | dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", | 362 | dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", |
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c index 437586611d4a..6d60284cc04b 100644 --- a/drivers/i2c/busses/i2c-sis5595.c +++ b/drivers/i2c/busses/i2c-sis5595.c | |||
@@ -147,7 +147,7 @@ static int __devinit sis5595_setup(struct pci_dev *SIS5595_dev) | |||
147 | u16 a; | 147 | u16 a; |
148 | u8 val; | 148 | u8 val; |
149 | int *i; | 149 | int *i; |
150 | int retval = -ENODEV; | 150 | int retval; |
151 | 151 | ||
152 | /* Look for imposters */ | 152 | /* Look for imposters */ |
153 | for (i = blacklist; *i != 0; i++) { | 153 | for (i = blacklist; *i != 0; i++) { |
@@ -223,7 +223,7 @@ static int __devinit sis5595_setup(struct pci_dev *SIS5595_dev) | |||
223 | 223 | ||
224 | error: | 224 | error: |
225 | release_region(sis5595_base + SMB_INDEX, 2); | 225 | release_region(sis5595_base + SMB_INDEX, 2); |
226 | return retval; | 226 | return -ENODEV; |
227 | } | 227 | } |
228 | 228 | ||
229 | static int sis5595_transaction(struct i2c_adapter *adap) | 229 | static int sis5595_transaction(struct i2c_adapter *adap) |
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c index e6f539e26f65..b617fd068ac7 100644 --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c | |||
@@ -393,7 +393,7 @@ static int __devinit sis630_setup(struct pci_dev *sis630_dev) | |||
393 | { | 393 | { |
394 | unsigned char b; | 394 | unsigned char b; |
395 | struct pci_dev *dummy = NULL; | 395 | struct pci_dev *dummy = NULL; |
396 | int retval = -ENODEV, i; | 396 | int retval, i; |
397 | 397 | ||
398 | /* check for supported SiS devices */ | 398 | /* check for supported SiS devices */ |
399 | for (i=0; supported[i] > 0 ; i++) { | 399 | for (i=0; supported[i] > 0 ; i++) { |
@@ -418,18 +418,21 @@ static int __devinit sis630_setup(struct pci_dev *sis630_dev) | |||
418 | */ | 418 | */ |
419 | if (pci_read_config_byte(sis630_dev, SIS630_BIOS_CTL_REG,&b)) { | 419 | if (pci_read_config_byte(sis630_dev, SIS630_BIOS_CTL_REG,&b)) { |
420 | dev_err(&sis630_dev->dev, "Error: Can't read bios ctl reg\n"); | 420 | dev_err(&sis630_dev->dev, "Error: Can't read bios ctl reg\n"); |
421 | retval = -ENODEV; | ||
421 | goto exit; | 422 | goto exit; |
422 | } | 423 | } |
423 | /* if ACPI already enabled , do nothing */ | 424 | /* if ACPI already enabled , do nothing */ |
424 | if (!(b & 0x80) && | 425 | if (!(b & 0x80) && |
425 | pci_write_config_byte(sis630_dev, SIS630_BIOS_CTL_REG, b | 0x80)) { | 426 | pci_write_config_byte(sis630_dev, SIS630_BIOS_CTL_REG, b | 0x80)) { |
426 | dev_err(&sis630_dev->dev, "Error: Can't enable ACPI\n"); | 427 | dev_err(&sis630_dev->dev, "Error: Can't enable ACPI\n"); |
428 | retval = -ENODEV; | ||
427 | goto exit; | 429 | goto exit; |
428 | } | 430 | } |
429 | 431 | ||
430 | /* Determine the ACPI base address */ | 432 | /* Determine the ACPI base address */ |
431 | if (pci_read_config_word(sis630_dev,SIS630_ACPI_BASE_REG,&acpi_base)) { | 433 | if (pci_read_config_word(sis630_dev,SIS630_ACPI_BASE_REG,&acpi_base)) { |
432 | dev_err(&sis630_dev->dev, "Error: Can't determine ACPI base address\n"); | 434 | dev_err(&sis630_dev->dev, "Error: Can't determine ACPI base address\n"); |
435 | retval = -ENODEV; | ||
433 | goto exit; | 436 | goto exit; |
434 | } | 437 | } |
435 | 438 | ||
@@ -445,6 +448,7 @@ static int __devinit sis630_setup(struct pci_dev *sis630_dev) | |||
445 | sis630_driver.name)) { | 448 | sis630_driver.name)) { |
446 | dev_err(&sis630_dev->dev, "SMBus registers 0x%04x-0x%04x already " | 449 | dev_err(&sis630_dev->dev, "SMBus registers 0x%04x-0x%04x already " |
447 | "in use!\n", acpi_base + SMB_STS, acpi_base + SMB_SAA); | 450 | "in use!\n", acpi_base + SMB_STS, acpi_base + SMB_SAA); |
451 | retval = -EBUSY; | ||
448 | goto exit; | 452 | goto exit; |
449 | } | 453 | } |
450 | 454 | ||
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index 0b012f1f8ac5..58261d4725b6 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c | |||
@@ -324,7 +324,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
324 | const struct pci_device_id *id) | 324 | const struct pci_device_id *id) |
325 | { | 325 | { |
326 | unsigned char temp; | 326 | unsigned char temp; |
327 | int error = -ENODEV; | 327 | int error; |
328 | 328 | ||
329 | /* Determine the address of the SMBus areas */ | 329 | /* Determine the address of the SMBus areas */ |
330 | if (force_addr) { | 330 | if (force_addr) { |
@@ -390,6 +390,7 @@ found: | |||
390 | dev_err(&pdev->dev, "SMBUS: Error: Host SMBus " | 390 | dev_err(&pdev->dev, "SMBUS: Error: Host SMBus " |
391 | "controller not enabled! - upgrade BIOS or " | 391 | "controller not enabled! - upgrade BIOS or " |
392 | "use force=1\n"); | 392 | "use force=1\n"); |
393 | error = -ENODEV; | ||
393 | goto release_region; | 394 | goto release_region; |
394 | } | 395 | } |
395 | } | 396 | } |
@@ -422,9 +423,11 @@ found: | |||
422 | "SMBus Via Pro adapter at %04x", vt596_smba); | 423 | "SMBus Via Pro adapter at %04x", vt596_smba); |
423 | 424 | ||
424 | vt596_pdev = pci_dev_get(pdev); | 425 | vt596_pdev = pci_dev_get(pdev); |
425 | if (i2c_add_adapter(&vt596_adapter)) { | 426 | error = i2c_add_adapter(&vt596_adapter); |
427 | if (error) { | ||
426 | pci_dev_put(vt596_pdev); | 428 | pci_dev_put(vt596_pdev); |
427 | vt596_pdev = NULL; | 429 | vt596_pdev = NULL; |
430 | goto release_region; | ||
428 | } | 431 | } |
429 | 432 | ||
430 | /* Always return failure here. This is to allow other drivers to bind | 433 | /* Always return failure here. This is to allow other drivers to bind |