diff options
Diffstat (limited to 'drivers/hwmon/lm73.c')
-rw-r--r-- | drivers/hwmon/lm73.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/hwmon/lm73.c b/drivers/hwmon/lm73.c index 29b9030d42c3..24be17608fbb 100644 --- a/drivers/hwmon/lm73.c +++ b/drivers/hwmon/lm73.c | |||
@@ -150,17 +150,31 @@ static int lm73_detect(struct i2c_client *new_client, | |||
150 | struct i2c_board_info *info) | 150 | struct i2c_board_info *info) |
151 | { | 151 | { |
152 | struct i2c_adapter *adapter = new_client->adapter; | 152 | struct i2c_adapter *adapter = new_client->adapter; |
153 | u16 id; | 153 | int id, ctrl, conf; |
154 | u8 ctrl; | ||
155 | 154 | ||
156 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | | 155 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
157 | I2C_FUNC_SMBUS_WORD_DATA)) | 156 | I2C_FUNC_SMBUS_WORD_DATA)) |
158 | return -ENODEV; | 157 | return -ENODEV; |
159 | 158 | ||
159 | /* | ||
160 | * Do as much detection as possible with byte reads first, as word | ||
161 | * reads can confuse other devices. | ||
162 | */ | ||
163 | ctrl = i2c_smbus_read_byte_data(new_client, LM73_REG_CTRL); | ||
164 | if (ctrl < 0 || (ctrl & 0x10)) | ||
165 | return -ENODEV; | ||
166 | |||
167 | conf = i2c_smbus_read_byte_data(new_client, LM73_REG_CONF); | ||
168 | if (conf < 0 || (conf & 0x0c)) | ||
169 | return -ENODEV; | ||
170 | |||
171 | id = i2c_smbus_read_byte_data(new_client, LM73_REG_ID); | ||
172 | if (id < 0 || id != (LM73_ID & 0xff)) | ||
173 | return -ENODEV; | ||
174 | |||
160 | /* Check device ID */ | 175 | /* Check device ID */ |
161 | id = i2c_smbus_read_word_data(new_client, LM73_REG_ID); | 176 | id = i2c_smbus_read_word_data(new_client, LM73_REG_ID); |
162 | ctrl = i2c_smbus_read_byte_data(new_client, LM73_REG_CTRL); | 177 | if (id < 0 || id != LM73_ID) |
163 | if ((id != LM73_ID) || (ctrl & 0x10)) | ||
164 | return -ENODEV; | 178 | return -ENODEV; |
165 | 179 | ||
166 | strlcpy(info->type, "lm73", I2C_NAME_SIZE); | 180 | strlcpy(info->type, "lm73", I2C_NAME_SIZE); |