diff options
Diffstat (limited to 'drivers/hwmon/adm9240.c')
-rw-r--r-- | drivers/hwmon/adm9240.c | 70 |
1 files changed, 26 insertions, 44 deletions
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 2444b15f2e9d..0727ad250793 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c | |||
@@ -55,8 +55,7 @@ | |||
55 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, | 55 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, |
56 | I2C_CLIENT_END }; | 56 | I2C_CLIENT_END }; |
57 | 57 | ||
58 | /* Insmod parameters */ | 58 | enum chips { adm9240, ds1780, lm81 }; |
59 | I2C_CLIENT_INSMOD_3(adm9240, ds1780, lm81); | ||
60 | 59 | ||
61 | /* ADM9240 registers */ | 60 | /* ADM9240 registers */ |
62 | #define ADM9240_REG_MAN_ID 0x3e | 61 | #define ADM9240_REG_MAN_ID 0x3e |
@@ -132,7 +131,7 @@ static inline unsigned int AOUT_FROM_REG(u8 reg) | |||
132 | 131 | ||
133 | static int adm9240_probe(struct i2c_client *client, | 132 | static int adm9240_probe(struct i2c_client *client, |
134 | const struct i2c_device_id *id); | 133 | const struct i2c_device_id *id); |
135 | static int adm9240_detect(struct i2c_client *client, int kind, | 134 | static int adm9240_detect(struct i2c_client *client, |
136 | struct i2c_board_info *info); | 135 | struct i2c_board_info *info); |
137 | static void adm9240_init_client(struct i2c_client *client); | 136 | static void adm9240_init_client(struct i2c_client *client); |
138 | static int adm9240_remove(struct i2c_client *client); | 137 | static int adm9240_remove(struct i2c_client *client); |
@@ -156,7 +155,7 @@ static struct i2c_driver adm9240_driver = { | |||
156 | .remove = adm9240_remove, | 155 | .remove = adm9240_remove, |
157 | .id_table = adm9240_id, | 156 | .id_table = adm9240_id, |
158 | .detect = adm9240_detect, | 157 | .detect = adm9240_detect, |
159 | .address_data = &addr_data, | 158 | .address_list = normal_i2c, |
160 | }; | 159 | }; |
161 | 160 | ||
162 | /* per client data */ | 161 | /* per client data */ |
@@ -545,7 +544,7 @@ static const struct attribute_group adm9240_group = { | |||
545 | /*** sensor chip detect and driver install ***/ | 544 | /*** sensor chip detect and driver install ***/ |
546 | 545 | ||
547 | /* Return 0 if detection is successful, -ENODEV otherwise */ | 546 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
548 | static int adm9240_detect(struct i2c_client *new_client, int kind, | 547 | static int adm9240_detect(struct i2c_client *new_client, |
549 | struct i2c_board_info *info) | 548 | struct i2c_board_info *info) |
550 | { | 549 | { |
551 | struct i2c_adapter *adapter = new_client->adapter; | 550 | struct i2c_adapter *adapter = new_client->adapter; |
@@ -556,51 +555,34 @@ static int adm9240_detect(struct i2c_client *new_client, int kind, | |||
556 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 555 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
557 | return -ENODEV; | 556 | return -ENODEV; |
558 | 557 | ||
559 | if (kind == 0) { | 558 | /* verify chip: reg address should match i2c address */ |
560 | kind = adm9240; | 559 | if (i2c_smbus_read_byte_data(new_client, ADM9240_REG_I2C_ADDR) |
561 | } | 560 | != address) { |
562 | 561 | dev_err(&adapter->dev, "detect fail: address match, 0x%02x\n", | |
563 | if (kind < 0) { | 562 | address); |
564 | 563 | return -ENODEV; | |
565 | /* verify chip: reg address should match i2c address */ | ||
566 | if (i2c_smbus_read_byte_data(new_client, ADM9240_REG_I2C_ADDR) | ||
567 | != address) { | ||
568 | dev_err(&adapter->dev, "detect fail: address match, " | ||
569 | "0x%02x\n", address); | ||
570 | return -ENODEV; | ||
571 | } | ||
572 | |||
573 | /* check known chip manufacturer */ | ||
574 | man_id = i2c_smbus_read_byte_data(new_client, | ||
575 | ADM9240_REG_MAN_ID); | ||
576 | if (man_id == 0x23) { | ||
577 | kind = adm9240; | ||
578 | } else if (man_id == 0xda) { | ||
579 | kind = ds1780; | ||
580 | } else if (man_id == 0x01) { | ||
581 | kind = lm81; | ||
582 | } else { | ||
583 | dev_err(&adapter->dev, "detect fail: unknown manuf, " | ||
584 | "0x%02x\n", man_id); | ||
585 | return -ENODEV; | ||
586 | } | ||
587 | |||
588 | /* successful detect, print chip info */ | ||
589 | die_rev = i2c_smbus_read_byte_data(new_client, | ||
590 | ADM9240_REG_DIE_REV); | ||
591 | dev_info(&adapter->dev, "found %s revision %u\n", | ||
592 | man_id == 0x23 ? "ADM9240" : | ||
593 | man_id == 0xda ? "DS1780" : "LM81", die_rev); | ||
594 | } | 564 | } |
595 | 565 | ||
596 | /* either forced or detected chip kind */ | 566 | /* check known chip manufacturer */ |
597 | if (kind == adm9240) { | 567 | man_id = i2c_smbus_read_byte_data(new_client, ADM9240_REG_MAN_ID); |
568 | if (man_id == 0x23) { | ||
598 | name = "adm9240"; | 569 | name = "adm9240"; |
599 | } else if (kind == ds1780) { | 570 | } else if (man_id == 0xda) { |
600 | name = "ds1780"; | 571 | name = "ds1780"; |
601 | } else if (kind == lm81) { | 572 | } else if (man_id == 0x01) { |
602 | name = "lm81"; | 573 | name = "lm81"; |
574 | } else { | ||
575 | dev_err(&adapter->dev, "detect fail: unknown manuf, 0x%02x\n", | ||
576 | man_id); | ||
577 | return -ENODEV; | ||
603 | } | 578 | } |
579 | |||
580 | /* successful detect, print chip info */ | ||
581 | die_rev = i2c_smbus_read_byte_data(new_client, ADM9240_REG_DIE_REV); | ||
582 | dev_info(&adapter->dev, "found %s revision %u\n", | ||
583 | man_id == 0x23 ? "ADM9240" : | ||
584 | man_id == 0xda ? "DS1780" : "LM81", die_rev); | ||
585 | |||
604 | strlcpy(info->type, name, I2C_NAME_SIZE); | 586 | strlcpy(info->type, name, I2C_NAME_SIZE); |
605 | 587 | ||
606 | return 0; | 588 | return 0; |