aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm87.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm87.c')
-rw-r--r--drivers/hwmon/lm87.c53
1 files changed, 22 insertions, 31 deletions
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
index 2e4a3cea95f7..f1e6e7512ffa 100644
--- a/drivers/hwmon/lm87.c
+++ b/drivers/hwmon/lm87.c
@@ -74,11 +74,7 @@
74 74
75static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; 75static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
76 76
77/* 77enum chips { lm87, adm1024 };
78 * Insmod parameters
79 */
80
81I2C_CLIENT_INSMOD_2(lm87, adm1024);
82 78
83/* 79/*
84 * The LM87 registers 80 * The LM87 registers
@@ -158,7 +154,7 @@ static u8 LM87_REG_TEMP_LOW[3] = { 0x3A, 0x38, 0x2C };
158 154
159static int lm87_probe(struct i2c_client *client, 155static int lm87_probe(struct i2c_client *client,
160 const struct i2c_device_id *id); 156 const struct i2c_device_id *id);
161static int lm87_detect(struct i2c_client *new_client, int kind, 157static int lm87_detect(struct i2c_client *new_client,
162 struct i2c_board_info *info); 158 struct i2c_board_info *info);
163static void lm87_init_client(struct i2c_client *client); 159static void lm87_init_client(struct i2c_client *client);
164static int lm87_remove(struct i2c_client *client); 160static int lm87_remove(struct i2c_client *client);
@@ -184,7 +180,7 @@ static struct i2c_driver lm87_driver = {
184 .remove = lm87_remove, 180 .remove = lm87_remove,
185 .id_table = lm87_id, 181 .id_table = lm87_id,
186 .detect = lm87_detect, 182 .detect = lm87_detect,
187 .address_data = &addr_data, 183 .address_list = normal_i2c,
188}; 184};
189 185
190/* 186/*
@@ -662,41 +658,36 @@ static const struct attribute_group lm87_group_opt = {
662}; 658};
663 659
664/* Return 0 if detection is successful, -ENODEV otherwise */ 660/* Return 0 if detection is successful, -ENODEV otherwise */
665static int lm87_detect(struct i2c_client *new_client, int kind, 661static int lm87_detect(struct i2c_client *new_client,
666 struct i2c_board_info *info) 662 struct i2c_board_info *info)
667{ 663{
668 struct i2c_adapter *adapter = new_client->adapter; 664 struct i2c_adapter *adapter = new_client->adapter;
669 static const char *names[] = { "lm87", "adm1024" }; 665 const char *name;
666 u8 cid, rev;
670 667
671 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 668 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
672 return -ENODEV; 669 return -ENODEV;
673 670
674 /* Default to an LM87 if forced */ 671 if (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80)
675 if (kind == 0) 672 return -ENODEV;
676 kind = lm87;
677 673
678 /* Now, we do the remaining detection. */ 674 /* Now, we do the remaining detection. */
679 if (kind < 0) { 675 cid = lm87_read_value(new_client, LM87_REG_COMPANY_ID);
680 u8 cid = lm87_read_value(new_client, LM87_REG_COMPANY_ID); 676 rev = lm87_read_value(new_client, LM87_REG_REVISION);
681 u8 rev = lm87_read_value(new_client, LM87_REG_REVISION); 677
682 678 if (cid == 0x02 /* National Semiconductor */
683 if (cid == 0x02 /* National Semiconductor */ 679 && (rev >= 0x01 && rev <= 0x08))
684 && (rev >= 0x01 && rev <= 0x08)) 680 name = "lm87";
685 kind = lm87; 681 else if (cid == 0x41 /* Analog Devices */
686 else if (cid == 0x41 /* Analog Devices */ 682 && (rev & 0xf0) == 0x10)
687 && (rev & 0xf0) == 0x10) 683 name = "adm1024";
688 kind = adm1024; 684 else {
689 685 dev_dbg(&adapter->dev, "LM87 detection failed at 0x%02x\n",
690 if (kind < 0 686 new_client->addr);
691 || (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80)) { 687 return -ENODEV;
692 dev_dbg(&adapter->dev,
693 "LM87 detection failed at 0x%02x.\n",
694 new_client->addr);
695 return -ENODEV;
696 }
697 } 688 }
698 689
699 strlcpy(info->type, names[kind - 1], I2C_NAME_SIZE); 690 strlcpy(info->type, name, I2C_NAME_SIZE);
700 691
701 return 0; 692 return 0;
702} 693}