aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm95241.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm95241.c')
-rw-r--r--drivers/hwmon/lm95241.c57
1 files changed, 13 insertions, 44 deletions
diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c
index e34f9e402a2c..8fc8eb8cba47 100644
--- a/drivers/hwmon/lm95241.c
+++ b/drivers/hwmon/lm95241.c
@@ -39,9 +39,6 @@
39static const unsigned short normal_i2c[] = { 39static const unsigned short normal_i2c[] = {
40 0x19, 0x2a, 0x2b, I2C_CLIENT_END}; 40 0x19, 0x2a, 0x2b, I2C_CLIENT_END};
41 41
42/* Insmod parameters */
43I2C_CLIENT_INSMOD_1(lm95241);
44
45/* LM95241 registers */ 42/* LM95241 registers */
46#define LM95241_REG_R_MAN_ID 0xFE 43#define LM95241_REG_R_MAN_ID 0xFE
47#define LM95241_REG_R_CHIP_ID 0xFF 44#define LM95241_REG_R_CHIP_ID 0xFF
@@ -310,56 +307,28 @@ static const struct attribute_group lm95241_group = {
310}; 307};
311 308
312/* Return 0 if detection is successful, -ENODEV otherwise */ 309/* Return 0 if detection is successful, -ENODEV otherwise */
313static int lm95241_detect(struct i2c_client *new_client, int kind, 310static int lm95241_detect(struct i2c_client *new_client,
314 struct i2c_board_info *info) 311 struct i2c_board_info *info)
315{ 312{
316 struct i2c_adapter *adapter = new_client->adapter; 313 struct i2c_adapter *adapter = new_client->adapter;
317 int address = new_client->addr; 314 int address = new_client->addr;
318 const char *name = ""; 315 const char *name;
319 316
320 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 317 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
321 return -ENODEV; 318 return -ENODEV;
322 319
323 /* 320 if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID)
324 * Now we do the remaining detection. A negative kind means that 321 == MANUFACTURER_ID)
325 * the driver was loaded with no force parameter (default), so we 322 && (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID)
326 * must both detect and identify the chip. A zero kind means that 323 >= DEFAULT_REVISION)) {
327 * the driver was loaded with the force parameter, the detection 324 name = "lm95241";
328 * step shall be skipped. A positive kind means that the driver 325 } else {
329 * was loaded with the force parameter and a given kind of chip is 326 dev_dbg(&adapter->dev, "LM95241 detection failed at 0x%02x\n",
330 * requested, so both the detection and the identification steps 327 address);
331 * are skipped. 328 return -ENODEV;
332 */
333 if (kind < 0) { /* detection */
334 if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID)
335 != MANUFACTURER_ID)
336 || (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID)
337 < DEFAULT_REVISION)) {
338 dev_dbg(&adapter->dev,
339 "LM95241 detection failed at 0x%02x.\n",
340 address);
341 return -ENODEV;
342 }
343 }
344
345 if (kind <= 0) { /* identification */
346 if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID)
347 == MANUFACTURER_ID)
348 && (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID)
349 >= DEFAULT_REVISION)) {
350
351 kind = lm95241;
352
353 if (kind <= 0) { /* identification failed */
354 dev_info(&adapter->dev, "Unsupported chip\n");
355 return -ENODEV;
356 }
357 }
358 } 329 }
359 330
360 /* Fill the i2c board info */ 331 /* Fill the i2c board info */
361 if (kind == lm95241)
362 name = "lm95241";
363 strlcpy(info->type, name, I2C_NAME_SIZE); 332 strlcpy(info->type, name, I2C_NAME_SIZE);
364 return 0; 333 return 0;
365} 334}
@@ -474,7 +443,7 @@ static struct lm95241_data *lm95241_update_device(struct device *dev)
474 443
475/* Driver data (common to all clients) */ 444/* Driver data (common to all clients) */
476static const struct i2c_device_id lm95241_id[] = { 445static const struct i2c_device_id lm95241_id[] = {
477 { "lm95241", lm95241 }, 446 { "lm95241", 0 },
478 { } 447 { }
479}; 448};
480MODULE_DEVICE_TABLE(i2c, lm95241_id); 449MODULE_DEVICE_TABLE(i2c, lm95241_id);
@@ -488,7 +457,7 @@ static struct i2c_driver lm95241_driver = {
488 .remove = lm95241_remove, 457 .remove = lm95241_remove,
489 .id_table = lm95241_id, 458 .id_table = lm95241_id,
490 .detect = lm95241_detect, 459 .detect = lm95241_detect,
491 .address_data = &addr_data, 460 .address_list = normal_i2c,
492}; 461};
493 462
494static int __init sensors_lm95241_init(void) 463static int __init sensors_lm95241_init(void)