Skip to contentSkip to conversation

I2C: Fix i2c-sis5595 pci configuration accesses

PATCH New Jean Delvare 2 participants 2 messages May 19, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 I2C: Fix i2c-sis5595 pci configuration accesses

Hi Greg,

The i2c-sis5595 bus driver has logic errors on pci configuration accesses. It returns an error on success and vice versa. The 2.4 kernel version of the driver, as found in the lm_sensors CVS repository, is correct, so the problem was introducted when the driver was ported to the 2.6 kernel tree (in 2.6.0-test6). As odd as it sounds, the driver has been sitting here broken and unusable for 17 months and nobody ever reported, until yesterday.

Credits go to Sebastian Hesselbarth for discovering and analyzing the problem.

Here is a patch that fixes the problem, succesfully tested by Aurelien Jarno and Sebastian Hesselbarth. Please apply.

drivers/i2c/busses/i2c-sis5595.c renamed from drivers/i2c/busses/i2c-sis5595.c.orig +10 -5
@@ -181,9 +181,11 @@
 
 	if (force_addr) {
 		dev_info(&SIS5595_dev->dev, "forcing ISA address 0x%04X\n", sis5595_base);
-		if (!pci_write_config_word(SIS5595_dev, ACPI_BASE, sis5595_base))
+		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))
+		if (pci_read_config_word(SIS5595_dev, ACPI_BASE, &a)
+		    != PCIBIOS_SUCCESSFUL)
 			goto error;
 		if ((a & ~(SIS5595_EXTENT - 1)) != sis5595_base) {
 			/* doesn't work for some chips! */
@@ -192,13 +194,16 @@
 		}
 	}
 
-	if (!pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val))
+	if (pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val)
+	    != PCIBIOS_SUCCESSFUL)
 		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))
+		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))
+		if (pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val)
+		    != PCIBIOS_SUCCESSFUL)
 			goto error;
 		if ((val & 0x80) = 0) {
 			/* doesn't work for some chips? */
Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
Applied
#1 lore raw

PATCH 1/1 I2C: Fix i2c-sis5595 pci configuration accesses

Quoted 10 lines · Jean Delvare

Hi Greg,

The i2c-sis5595 bus driver has logic errors on pci configuration accesses. It returns an error on success and vice versa. The 2.4 kernel version of the driver, as found in the lm_sensors CVS repository, is correct, so the problem was introducted when the driver was ported to the 2.6 kernel tree (in 2.6.0-test6). As odd as it sounds, the driver has been sitting here broken and unusable for 17 months and nobody ever reported, until yesterday.

Quoted 7 lines

Credits go to Sebastian Hesselbarth for discovering and analyzing the problem.

Here is a patch that fixes the problem, succesfully tested by Aurelien Jarno and Sebastian Hesselbarth. Please apply.

Applied, thanks.

greg k-h