diff options
Diffstat (limited to 'drivers/hwmon/ds1621.c')
-rw-r--r-- | drivers/hwmon/ds1621.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 53f88f511816..e11363467a8d 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c | |||
@@ -38,7 +38,6 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, | |||
38 | 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; | 38 | 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; |
39 | 39 | ||
40 | /* Insmod parameters */ | 40 | /* Insmod parameters */ |
41 | I2C_CLIENT_INSMOD_1(ds1621); | ||
42 | static int polarity = -1; | 41 | static int polarity = -1; |
43 | module_param(polarity, int, 0); | 42 | module_param(polarity, int, 0); |
44 | MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low"); | 43 | MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low"); |
@@ -224,7 +223,7 @@ static const struct attribute_group ds1621_group = { | |||
224 | 223 | ||
225 | 224 | ||
226 | /* Return 0 if detection is successful, -ENODEV otherwise */ | 225 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
227 | static int ds1621_detect(struct i2c_client *client, int kind, | 226 | static int ds1621_detect(struct i2c_client *client, |
228 | struct i2c_board_info *info) | 227 | struct i2c_board_info *info) |
229 | { | 228 | { |
230 | struct i2c_adapter *adapter = client->adapter; | 229 | struct i2c_adapter *adapter = client->adapter; |
@@ -237,20 +236,16 @@ static int ds1621_detect(struct i2c_client *client, int kind, | |||
237 | return -ENODEV; | 236 | return -ENODEV; |
238 | 237 | ||
239 | /* Now, we do the remaining detection. It is lousy. */ | 238 | /* Now, we do the remaining detection. It is lousy. */ |
240 | if (kind < 0) { | 239 | /* The NVB bit should be low if no EEPROM write has been requested |
241 | /* The NVB bit should be low if no EEPROM write has been | 240 | during the latest 10ms, which is highly improbable in our case. */ |
242 | requested during the latest 10ms, which is highly | 241 | conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF); |
243 | improbable in our case. */ | 242 | if (conf < 0 || conf & DS1621_REG_CONFIG_NVB) |
244 | conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF); | 243 | return -ENODEV; |
245 | if (conf < 0 || conf & DS1621_REG_CONFIG_NVB) | 244 | /* The 7 lowest bits of a temperature should always be 0. */ |
245 | for (i = 0; i < ARRAY_SIZE(DS1621_REG_TEMP); i++) { | ||
246 | temp = i2c_smbus_read_word_data(client, DS1621_REG_TEMP[i]); | ||
247 | if (temp < 0 || (temp & 0x7f00)) | ||
246 | return -ENODEV; | 248 | return -ENODEV; |
247 | /* The 7 lowest bits of a temperature should always be 0. */ | ||
248 | for (i = 0; i < ARRAY_SIZE(DS1621_REG_TEMP); i++) { | ||
249 | temp = i2c_smbus_read_word_data(client, | ||
250 | DS1621_REG_TEMP[i]); | ||
251 | if (temp < 0 || (temp & 0x7f00)) | ||
252 | return -ENODEV; | ||
253 | } | ||
254 | } | 249 | } |
255 | 250 | ||
256 | strlcpy(info->type, "ds1621", I2C_NAME_SIZE); | 251 | strlcpy(info->type, "ds1621", I2C_NAME_SIZE); |
@@ -309,8 +304,8 @@ static int ds1621_remove(struct i2c_client *client) | |||
309 | } | 304 | } |
310 | 305 | ||
311 | static const struct i2c_device_id ds1621_id[] = { | 306 | static const struct i2c_device_id ds1621_id[] = { |
312 | { "ds1621", ds1621 }, | 307 | { "ds1621", 0 }, |
313 | { "ds1625", ds1621 }, | 308 | { "ds1625", 0 }, |
314 | { } | 309 | { } |
315 | }; | 310 | }; |
316 | MODULE_DEVICE_TABLE(i2c, ds1621_id); | 311 | MODULE_DEVICE_TABLE(i2c, ds1621_id); |
@@ -325,7 +320,7 @@ static struct i2c_driver ds1621_driver = { | |||
325 | .remove = ds1621_remove, | 320 | .remove = ds1621_remove, |
326 | .id_table = ds1621_id, | 321 | .id_table = ds1621_id, |
327 | .detect = ds1621_detect, | 322 | .detect = ds1621_detect, |
328 | .address_data = &addr_data, | 323 | .address_list = normal_i2c, |
329 | }; | 324 | }; |
330 | 325 | ||
331 | static int __init ds1621_init(void) | 326 | static int __init ds1621_init(void) |