diff options
Diffstat (limited to 'drivers/hwmon/w83l786ng.c')
-rw-r--r-- | drivers/hwmon/w83l786ng.c | 66 |
1 files changed, 21 insertions, 45 deletions
diff --git a/drivers/hwmon/w83l786ng.c b/drivers/hwmon/w83l786ng.c index badca769f350..0254e181893d 100644 --- a/drivers/hwmon/w83l786ng.c +++ b/drivers/hwmon/w83l786ng.c | |||
@@ -38,7 +38,6 @@ | |||
38 | static const unsigned short normal_i2c[] = { 0x2e, 0x2f, I2C_CLIENT_END }; | 38 | static const unsigned short normal_i2c[] = { 0x2e, 0x2f, I2C_CLIENT_END }; |
39 | 39 | ||
40 | /* Insmod parameters */ | 40 | /* Insmod parameters */ |
41 | I2C_CLIENT_INSMOD_1(w83l786ng); | ||
42 | 41 | ||
43 | static int reset; | 42 | static int reset; |
44 | module_param(reset, bool, 0); | 43 | module_param(reset, bool, 0); |
@@ -147,14 +146,14 @@ struct w83l786ng_data { | |||
147 | 146 | ||
148 | static int w83l786ng_probe(struct i2c_client *client, | 147 | static int w83l786ng_probe(struct i2c_client *client, |
149 | const struct i2c_device_id *id); | 148 | const struct i2c_device_id *id); |
150 | static int w83l786ng_detect(struct i2c_client *client, int kind, | 149 | static int w83l786ng_detect(struct i2c_client *client, |
151 | struct i2c_board_info *info); | 150 | struct i2c_board_info *info); |
152 | static int w83l786ng_remove(struct i2c_client *client); | 151 | static int w83l786ng_remove(struct i2c_client *client); |
153 | static void w83l786ng_init_client(struct i2c_client *client); | 152 | static void w83l786ng_init_client(struct i2c_client *client); |
154 | static struct w83l786ng_data *w83l786ng_update_device(struct device *dev); | 153 | static struct w83l786ng_data *w83l786ng_update_device(struct device *dev); |
155 | 154 | ||
156 | static const struct i2c_device_id w83l786ng_id[] = { | 155 | static const struct i2c_device_id w83l786ng_id[] = { |
157 | { "w83l786ng", w83l786ng }, | 156 | { "w83l786ng", 0 }, |
158 | { } | 157 | { } |
159 | }; | 158 | }; |
160 | MODULE_DEVICE_TABLE(i2c, w83l786ng_id); | 159 | MODULE_DEVICE_TABLE(i2c, w83l786ng_id); |
@@ -168,7 +167,7 @@ static struct i2c_driver w83l786ng_driver = { | |||
168 | .remove = w83l786ng_remove, | 167 | .remove = w83l786ng_remove, |
169 | .id_table = w83l786ng_id, | 168 | .id_table = w83l786ng_id, |
170 | .detect = w83l786ng_detect, | 169 | .detect = w83l786ng_detect, |
171 | .address_data = &addr_data, | 170 | .address_list = normal_i2c, |
172 | }; | 171 | }; |
173 | 172 | ||
174 | static u8 | 173 | static u8 |
@@ -586,57 +585,34 @@ static const struct attribute_group w83l786ng_group = { | |||
586 | }; | 585 | }; |
587 | 586 | ||
588 | static int | 587 | static int |
589 | w83l786ng_detect(struct i2c_client *client, int kind, | 588 | w83l786ng_detect(struct i2c_client *client, struct i2c_board_info *info) |
590 | struct i2c_board_info *info) | ||
591 | { | 589 | { |
592 | struct i2c_adapter *adapter = client->adapter; | 590 | struct i2c_adapter *adapter = client->adapter; |
591 | u16 man_id; | ||
592 | u8 chip_id; | ||
593 | 593 | ||
594 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { | 594 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
595 | return -ENODEV; | 595 | return -ENODEV; |
596 | } | 596 | } |
597 | 597 | ||
598 | /* | 598 | /* Detection */ |
599 | * Now we do the remaining detection. A negative kind means that | 599 | if ((w83l786ng_read_value(client, W83L786NG_REG_CONFIG) & 0x80)) { |
600 | * the driver was loaded with no force parameter (default), so we | 600 | dev_dbg(&adapter->dev, "W83L786NG detection failed at 0x%02x\n", |
601 | * must both detect and identify the chip (actually there is only | 601 | client->addr); |
602 | * one possible kind of chip for now, W83L786NG). A zero kind means | 602 | 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 | } | 603 | } |
618 | 604 | ||
619 | if (kind <= 0) { /* identification */ | 605 | /* Identification */ |
620 | u16 man_id; | 606 | man_id = (w83l786ng_read_value(client, W83L786NG_REG_MAN_ID1) << 8) + |
621 | u8 chip_id; | 607 | w83l786ng_read_value(client, W83L786NG_REG_MAN_ID2); |
622 | 608 | 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 | 609 | ||
634 | if (kind <= 0) { /* identification failed */ | 610 | if (man_id != 0x5CA3 || /* Winbond */ |
635 | dev_info(&adapter->dev, | 611 | chip_id != 0x80) { /* W83L786NG */ |
636 | "Unsupported chip (man_id=0x%04X, " | 612 | dev_dbg(&adapter->dev, |
637 | "chip_id=0x%02X).\n", man_id, chip_id); | 613 | "Unsupported chip (man_id=0x%04X, chip_id=0x%02X)\n", |
638 | return -ENODEV; | 614 | man_id, chip_id); |
639 | } | 615 | return -ENODEV; |
640 | } | 616 | } |
641 | 617 | ||
642 | strlcpy(info->type, "w83l786ng", I2C_NAME_SIZE); | 618 | strlcpy(info->type, "w83l786ng", I2C_NAME_SIZE); |