aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/gl518sm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/gl518sm.c')
-rw-r--r--drivers/hwmon/gl518sm.c40
1 files changed, 11 insertions, 29 deletions
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c
index 7820df45d77a..e7ae5743e181 100644
--- a/drivers/hwmon/gl518sm.c
+++ b/drivers/hwmon/gl518sm.c
@@ -46,8 +46,7 @@
46/* Addresses to scan */ 46/* Addresses to scan */
47static const unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; 47static const unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
48 48
49/* Insmod parameters */ 49enum chips { gl518sm_r00, gl518sm_r80 };
50I2C_CLIENT_INSMOD_2(gl518sm_r00, gl518sm_r80);
51 50
52/* Many GL518 constants specified below */ 51/* Many GL518 constants specified below */
53 52
@@ -139,8 +138,7 @@ struct gl518_data {
139 138
140static int gl518_probe(struct i2c_client *client, 139static int gl518_probe(struct i2c_client *client,
141 const struct i2c_device_id *id); 140 const struct i2c_device_id *id);
142static int gl518_detect(struct i2c_client *client, int kind, 141static int gl518_detect(struct i2c_client *client, struct i2c_board_info *info);
143 struct i2c_board_info *info);
144static void gl518_init_client(struct i2c_client *client); 142static void gl518_init_client(struct i2c_client *client);
145static int gl518_remove(struct i2c_client *client); 143static int gl518_remove(struct i2c_client *client);
146static int gl518_read_value(struct i2c_client *client, u8 reg); 144static int gl518_read_value(struct i2c_client *client, u8 reg);
@@ -163,7 +161,7 @@ static struct i2c_driver gl518_driver = {
163 .remove = gl518_remove, 161 .remove = gl518_remove,
164 .id_table = gl518_id, 162 .id_table = gl518_id,
165 .detect = gl518_detect, 163 .detect = gl518_detect,
166 .address_data = &addr_data, 164 .address_list = normal_i2c,
167}; 165};
168 166
169/* 167/*
@@ -484,40 +482,24 @@ static const struct attribute_group gl518_group_r80 = {
484 */ 482 */
485 483
486/* Return 0 if detection is successful, -ENODEV otherwise */ 484/* Return 0 if detection is successful, -ENODEV otherwise */
487static int gl518_detect(struct i2c_client *client, int kind, 485static int gl518_detect(struct i2c_client *client, struct i2c_board_info *info)
488 struct i2c_board_info *info)
489{ 486{
490 struct i2c_adapter *adapter = client->adapter; 487 struct i2c_adapter *adapter = client->adapter;
491 int i; 488 int rev;
492 489
493 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | 490 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
494 I2C_FUNC_SMBUS_WORD_DATA)) 491 I2C_FUNC_SMBUS_WORD_DATA))
495 return -ENODEV; 492 return -ENODEV;
496 493
497 /* Now, we do the remaining detection. */ 494 /* Now, we do the remaining detection. */
498 495 if ((gl518_read_value(client, GL518_REG_CHIP_ID) != 0x80)
499 if (kind < 0) { 496 || (gl518_read_value(client, GL518_REG_CONF) & 0x80))
500 if ((gl518_read_value(client, GL518_REG_CHIP_ID) != 0x80) 497 return -ENODEV;
501 || (gl518_read_value(client, GL518_REG_CONF) & 0x80))
502 return -ENODEV;
503 }
504 498
505 /* Determine the chip type. */ 499 /* Determine the chip type. */
506 if (kind <= 0) { 500 rev = gl518_read_value(client, GL518_REG_REVISION);
507 i = gl518_read_value(client, GL518_REG_REVISION); 501 if (rev != 0x00 && rev != 0x80)
508 if (i == 0x00) { 502 return -ENODEV;
509 kind = gl518sm_r00;
510 } else if (i == 0x80) {
511 kind = gl518sm_r80;
512 } else {
513 if (kind <= 0)
514 dev_info(&adapter->dev,
515 "Ignoring 'force' parameter for unknown "
516 "chip at adapter %d, address 0x%02x\n",
517 i2c_adapter_id(adapter), client->addr);
518 return -ENODEV;
519 }
520 }
521 503
522 strlcpy(info->type, "gl518sm", I2C_NAME_SIZE); 504 strlcpy(info->type, "gl518sm", I2C_NAME_SIZE);
523 505