aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/tmp401.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/tmp401.c')
-rw-r--r--drivers/hwmon/tmp401.c69
1 files changed, 32 insertions, 37 deletions
diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c
index 7b34f2cd08bb..d14a1af9f550 100644
--- a/drivers/hwmon/tmp401.c
+++ b/drivers/hwmon/tmp401.c
@@ -42,8 +42,7 @@
42/* Addresses to scan */ 42/* Addresses to scan */
43static const unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END }; 43static const unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END };
44 44
45/* Insmod parameters */ 45enum chips { tmp401, tmp411 };
46I2C_CLIENT_INSMOD_2(tmp401, tmp411);
47 46
48/* 47/*
49 * The TMP401 registers, note some registers have different addresses for 48 * The TMP401 registers, note some registers have different addresses for
@@ -98,7 +97,7 @@ static const u8 TMP411_TEMP_HIGHEST_LSB[2] = { 0x33, 0x37 };
98 97
99static int tmp401_probe(struct i2c_client *client, 98static int tmp401_probe(struct i2c_client *client,
100 const struct i2c_device_id *id); 99 const struct i2c_device_id *id);
101static int tmp401_detect(struct i2c_client *client, int kind, 100static int tmp401_detect(struct i2c_client *client,
102 struct i2c_board_info *info); 101 struct i2c_board_info *info);
103static int tmp401_remove(struct i2c_client *client); 102static int tmp401_remove(struct i2c_client *client);
104static struct tmp401_data *tmp401_update_device(struct device *dev); 103static struct tmp401_data *tmp401_update_device(struct device *dev);
@@ -123,7 +122,7 @@ static struct i2c_driver tmp401_driver = {
123 .remove = tmp401_remove, 122 .remove = tmp401_remove,
124 .id_table = tmp401_id, 123 .id_table = tmp401_id,
125 .detect = tmp401_detect, 124 .detect = tmp401_detect,
126 .address_data = &addr_data, 125 .address_list = normal_i2c,
127}; 126};
128 127
129/* 128/*
@@ -135,7 +134,7 @@ struct tmp401_data {
135 struct mutex update_lock; 134 struct mutex update_lock;
136 char valid; /* zero until following fields are valid */ 135 char valid; /* zero until following fields are valid */
137 unsigned long last_updated; /* in jiffies */ 136 unsigned long last_updated; /* in jiffies */
138 int kind; 137 enum chips kind;
139 138
140 /* register values */ 139 /* register values */
141 u8 status; 140 u8 status;
@@ -488,47 +487,44 @@ static void tmp401_init_client(struct i2c_client *client)
488 i2c_smbus_write_byte_data(client, TMP401_CONFIG_WRITE, config); 487 i2c_smbus_write_byte_data(client, TMP401_CONFIG_WRITE, config);
489} 488}
490 489
491static int tmp401_detect(struct i2c_client *client, int kind, 490static int tmp401_detect(struct i2c_client *client,
492 struct i2c_board_info *info) 491 struct i2c_board_info *info)
493{ 492{
493 enum chips kind;
494 struct i2c_adapter *adapter = client->adapter; 494 struct i2c_adapter *adapter = client->adapter;
495 u8 reg;
495 496
496 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 497 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
497 return -ENODEV; 498 return -ENODEV;
498 499
499 /* Detect and identify the chip */ 500 /* Detect and identify the chip */
500 if (kind <= 0) { 501 reg = i2c_smbus_read_byte_data(client, TMP401_MANUFACTURER_ID_REG);
501 u8 reg; 502 if (reg != TMP401_MANUFACTURER_ID)
502 503 return -ENODEV;
503 reg = i2c_smbus_read_byte_data(client,
504 TMP401_MANUFACTURER_ID_REG);
505 if (reg != TMP401_MANUFACTURER_ID)
506 return -ENODEV;
507
508 reg = i2c_smbus_read_byte_data(client, TMP401_DEVICE_ID_REG);
509
510 switch (reg) {
511 case TMP401_DEVICE_ID:
512 kind = tmp401;
513 break;
514 case TMP411_DEVICE_ID:
515 kind = tmp411;
516 break;
517 default:
518 return -ENODEV;
519 }
520 504
521 reg = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ); 505 reg = i2c_smbus_read_byte_data(client, TMP401_DEVICE_ID_REG);
522 if (reg & 0x1b)
523 return -ENODEV;
524 506
525 reg = i2c_smbus_read_byte_data(client, 507 switch (reg) {
526 TMP401_CONVERSION_RATE_READ); 508 case TMP401_DEVICE_ID:
527 /* Datasheet says: 0x1-0x6 */ 509 kind = tmp401;
528 if (reg > 15) 510 break;
529 return -ENODEV; 511 case TMP411_DEVICE_ID:
512 kind = tmp411;
513 break;
514 default:
515 return -ENODEV;
530 } 516 }
531 strlcpy(info->type, tmp401_id[kind - 1].name, I2C_NAME_SIZE); 517
518 reg = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ);
519 if (reg & 0x1b)
520 return -ENODEV;
521
522 reg = i2c_smbus_read_byte_data(client, TMP401_CONVERSION_RATE_READ);
523 /* Datasheet says: 0x1-0x6 */
524 if (reg > 15)
525 return -ENODEV;
526
527 strlcpy(info->type, tmp401_id[kind].name, I2C_NAME_SIZE);
532 528
533 return 0; 529 return 0;
534} 530}
@@ -576,8 +572,7 @@ static int tmp401_probe(struct i2c_client *client,
576 goto exit_remove; 572 goto exit_remove;
577 } 573 }
578 574
579 dev_info(&client->dev, "Detected TI %s chip\n", 575 dev_info(&client->dev, "Detected TI %s chip\n", names[data->kind]);
580 names[data->kind - 1]);
581 576
582 return 0; 577 return 0;
583 578