Return error values in detect.

git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2431 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2004-04-10 14:09:50 +00:00
1 parent 2104a15719
commit 342b8a2c04
1 file changed
+26 -31
+26 -31
View File
@@ -465,39 +465,32 @@ int it87_detect(struct i2c_adapter *adapter, int address,
int is_isa = i2c_is_isa_adapter(adapter); int is_isa = i2c_is_isa_adapter(adapter);
if (!is_isa if (!is_isa
&& !i2c_check_functionality(adapter, && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
I2C_FUNC_SMBUS_BYTE_DATA)) goto return 0;
ERROR0;
if (is_isa) { if (is_isa
if (check_region(address, IT87_EXTENT)) && check_region(address, IT87_EXTENT))
goto ERROR0; return 0;
}
/* Probe whether there is anything available on this address. Already /* Probe whether there is anything available on this address. Already
done for SMBus clients */ done for SMBus clients */
if (kind < 0) { if (is_isa && kind < 0) {
if (is_isa) {
#define REALLY_SLOW_IO #define REALLY_SLOW_IO
/* We need the timeouts for at least some IT87-like chips. But only /* We need the timeouts for at least some IT87-like chips.
if we read 'undefined' registers. */ But only if we read 'undefined' registers. */
i = inb_p(address + 1); i = inb_p(address + 1);
if (inb_p(address + 2) != i) if (inb_p(address + 2) != i
goto ERROR0; || inb_p(address + 3) != i
if (inb_p(address + 3) != i) || inb_p(address + 7) != i)
goto ERROR0; return -ENODEV;
if (inb_p(address + 7) != i)
goto ERROR0;
#undef REALLY_SLOW_IO #undef REALLY_SLOW_IO
/* Let's just hope nothing breaks here */ /* Let's just hope nothing breaks here */
i = inb_p(address + 5) & 0x7f; i = inb_p(address + 5) & 0x7f;
outb_p(~i & 0x7f, address + 5); outb_p(~i & 0x7f, address + 5);
if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) { if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) {
outb_p(i, address + 5); outb_p(i, address + 5);
return 0; return -ENODEV;
}
} }
} }
@@ -524,11 +517,12 @@ int it87_detect(struct i2c_adapter *adapter, int address,
/* Now, we do the remaining detection. */ /* Now, we do the remaining detection. */
if (kind < 0) { if (kind < 0) {
if (it87_read_value(new_client, IT87_REG_CONFIG) & 0x80) if ((it87_read_value(new_client, IT87_REG_CONFIG) & 0x80)
goto ERROR1; || (!is_isa
if (!is_isa && it87_read_value(new_client, IT87_REG_I2C_ADDR) != address)) {
&& (it87_read_value(new_client, IT87_REG_I2C_ADDR) != err = -ENODEV;
address)) goto ERROR1; goto ERROR1;
}
} }
/* Determine the chip type. */ /* Determine the chip type. */
@@ -543,6 +537,7 @@ int it87_detect(struct i2c_adapter *adapter, int address,
("it87.o: Ignoring 'force' parameter for unknown chip at " ("it87.o: Ignoring 'force' parameter for unknown chip at "
"adapter %d, address 0x%02x\n", "adapter %d, address 0x%02x\n",
i2c_adapter_id(adapter), address); i2c_adapter_id(adapter), address);
err = -ENODEV;
goto ERROR1; goto ERROR1;
} }
} }