2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-30 22:05:11 +00:00

Backport misdetection prevention patch from 2.6:

* Use unused bits of two more registers (configuration and conversion
rate) to reduce misdetections.

* Return with -ENODEV if the detection fails.

* Change the order in which we try to identify the chips. We better
finish with the LM84 and the MAX1617, in this order, because they are
harder to identify and are more likely to result in false positives.

* Refine LM84 detection. The LM84 has less features than the other chips
(chip cannot be stopped, conversion rate cannot be set, no low limits)
so it has extra unused bits.

* Do not intialize the chip if it was detected as an LM84. This one
cannot be stopped so why would we try to start it again? And as said
right before, conversion rate isn't changeable either.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2395 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2004-03-27 16:12:20 +00:00
parent 1022db4ca3
commit 835d3937dd

View File

@@ -228,10 +228,12 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address,
/* Now, we do the remaining detection. */
if (kind < 0) {
if (
(adm1021_read_value(new_client, ADM1021_REG_STATUS) &
0x03) != 0x00)
goto error1;
if ((adm1021_read_value(new_client, ADM1021_REG_STATUS) & 0x03) != 0x00
|| (adm1021_read_value(new_client, ADM1021_REG_CONFIG_R) & 0x3F) != 0x00
|| (adm1021_read_value(new_client, ADM1021_REG_CONV_RATE_R) & 0xF8) != 0x00) {
err = -ENODEV;
goto error1;
}
}
/* Determine the chip type. */
@@ -239,7 +241,7 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address,
if (kind <= 0) {
i = adm1021_read_value(new_client, ADM1021_REG_MAN_ID);
if (i == 0x41)
if ((adm1021_read_value (new_client, ADM1021_REG_DEV_ID) & 0x0F0) == 0x030)
if ((adm1021_read_value (new_client, ADM1021_REG_DEV_ID) & 0xF0) == 0x30)
kind = adm1023;
else
kind = adm1021;
@@ -251,13 +253,14 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address,
(adm1021_read_value
(new_client, ADM1021_REG_DEV_ID) == 0x01))
kind = max1617a;
/* LM84 Mfr ID in a different place */
else
if (adm1021_read_value
(new_client, ADM1021_REG_CONV_RATE_R) == 0x00)
kind = lm84;
else if (i == 0x54)
kind = mc1066;
/* LM84 Mfr ID in a different place, and it has more unused bits */
else if (adm1021_read_value(new_client, ADM1021_REG_CONV_RATE_R) == 0x00
&& (kind == 0 /* skip extra detection */
|| ((adm1021_read_value(new_client, ADM1021_REG_CONFIG_R) & 0x7F) == 0x00
&& (adm1021_read_value(new_client, ADM1021_REG_STATUS) & 0xAB) == 0x00)))
kind = lm84;
else
kind = max1617;
}
@@ -286,12 +289,6 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address,
} else if (kind == mc1066) {
type_name = "mc1066";
client_name = "MC1066 chip";
} else {
#ifdef DEBUG
printk("adm1021.o: Internal error: unknown kind (%d)?!?",
kind);
#endif
goto error1;
}
/* Fill in the remaining client fields and put it into the global list */
@@ -316,7 +313,8 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address,
data->sysctl_id = i;
/* Initialize the ADM1021 chip */
adm1021_init_client(new_client);
if (kind != lm84)
adm1021_init_client(new_client);
return 0;
error4: