aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/w83l786ng.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/w83l786ng.c')
-rw-r--r--drivers/hwmon/w83l786ng.c56
1 files changed, 17 insertions, 39 deletions
diff --git a/drivers/hwmon/w83l786ng.c b/drivers/hwmon/w83l786ng.c
index badca769f350..27da7d2b15fb 100644
--- a/drivers/hwmon/w83l786ng.c
+++ b/drivers/hwmon/w83l786ng.c
@@ -590,53 +590,31 @@ w83l786ng_detect(struct i2c_client *client, int kind,
590 struct i2c_board_info *info) 590 struct i2c_board_info *info)
591{ 591{
592 struct i2c_adapter *adapter = client->adapter; 592 struct i2c_adapter *adapter = client->adapter;
593 u16 man_id;
594 u8 chip_id;
593 595
594 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { 596 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
595 return -ENODEV; 597 return -ENODEV;
596 } 598 }
597 599
598 /* 600 /* Detection */
599 * Now we do the remaining detection. A negative kind means that 601 if ((w83l786ng_read_value(client, W83L786NG_REG_CONFIG) & 0x80)) {
600 * the driver was loaded with no force parameter (default), so we 602 dev_dbg(&adapter->dev, "W83L786NG detection failed at 0x%02x\n",
601 * must both detect and identify the chip (actually there is only 603 client->addr);
602 * one possible kind of chip for now, W83L786NG). A zero kind means 604 return -ENODEV;
603 * that the driver was loaded with the force parameter, the detection
604 * step shall be skipped. A positive kind means that the driver
605 * was loaded with the force parameter and a given kind of chip is
606 * requested, so both the detection and the identification steps
607 * are skipped.
608 */
609 if (kind < 0) { /* detection */
610 if (((w83l786ng_read_value(client,
611 W83L786NG_REG_CONFIG) & 0x80) != 0x00)) {
612 dev_dbg(&adapter->dev,
613 "W83L786NG detection failed at 0x%02x.\n",
614 client->addr);
615 return -ENODEV;
616 }
617 } 605 }
618 606
619 if (kind <= 0) { /* identification */ 607 /* Identification */
620 u16 man_id; 608 man_id = (w83l786ng_read_value(client, W83L786NG_REG_MAN_ID1) << 8) +
621 u8 chip_id; 609 w83l786ng_read_value(client, W83L786NG_REG_MAN_ID2);
622 610 chip_id = w83l786ng_read_value(client, W83L786NG_REG_CHIP_ID);
623 man_id = (w83l786ng_read_value(client,
624 W83L786NG_REG_MAN_ID1) << 8) +
625 w83l786ng_read_value(client, W83L786NG_REG_MAN_ID2);
626 chip_id = w83l786ng_read_value(client, W83L786NG_REG_CHIP_ID);
627
628 if (man_id == 0x5CA3) { /* Winbond */
629 if (chip_id == 0x80) { /* W83L786NG */
630 kind = w83l786ng;
631 }
632 }
633 611
634 if (kind <= 0) { /* identification failed */ 612 if (man_id != 0x5CA3 || /* Winbond */
635 dev_info(&adapter->dev, 613 chip_id != 0x80) { /* W83L786NG */
636 "Unsupported chip (man_id=0x%04X, " 614 dev_dbg(&adapter->dev,
637 "chip_id=0x%02X).\n", man_id, chip_id); 615 "Unsupported chip (man_id=0x%04X, chip_id=0x%02X)\n",
638 return -ENODEV; 616 man_id, chip_id);
639 } 617 return -ENODEV;
640 } 618 }
641 619
642 strlcpy(info->type, "w83l786ng", I2C_NAME_SIZE); 620 strlcpy(info->type, "w83l786ng", I2C_NAME_SIZE);