diff options
author | Guenter Roeck <linux@roeck-us.net> | 2015-04-01 13:15:38 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2016-04-19 09:32:37 -0400 |
commit | 559313c4e9b29f5d0ba246f69d1052ef2fd9b423 (patch) | |
tree | a5bbd377520dc3780f49dec6b4fa7e909c10e002 | |
parent | cc18da79d9b7faf1ec617e2478d57d25d7b2f93a (diff) |
hwmon: (it87) Simplify reading voltage registers
Voltage registers are non-sequential. Use a register array instead
of a macro to map sensor index to register to simplify the code
and to make it easier to add additional voltage sensors.
Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | drivers/hwmon/it87.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 722d6de62d1c..aa3ec50527a3 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -232,10 +232,10 @@ static const u8 IT87_REG_TEMP_OFFSET[] = { 0x56, 0x57, 0x59 }; | |||
232 | static const u8 IT87_REG_PWM[] = { 0x15, 0x16, 0x17, 0x7f, 0xa7, 0xaf }; | 232 | static const u8 IT87_REG_PWM[] = { 0x15, 0x16, 0x17, 0x7f, 0xa7, 0xaf }; |
233 | static const u8 IT87_REG_PWM_DUTY[] = { 0x63, 0x6b, 0x73, 0x7b, 0xa3, 0xab }; | 233 | static const u8 IT87_REG_PWM_DUTY[] = { 0x63, 0x6b, 0x73, 0x7b, 0xa3, 0xab }; |
234 | 234 | ||
235 | #define IT87_REG_VIN(nr) (0x20 + (nr)) | 235 | static const u8 IT87_REG_VIN[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, |
236 | #define IT87_REG_TEMP(nr) (0x29 + (nr)) | 236 | 0x27, 0x28, 0x2f }; |
237 | 237 | ||
238 | #define IT87_REG_AVCC3 0x2f | 238 | #define IT87_REG_TEMP(nr) (0x29 + (nr)) |
239 | 239 | ||
240 | #define IT87_REG_VIN_MAX(nr) (0x30 + (nr) * 2) | 240 | #define IT87_REG_VIN_MAX(nr) (0x30 + (nr) * 2) |
241 | #define IT87_REG_VIN_MIN(nr) (0x31 + (nr) * 2) | 241 | #define IT87_REG_VIN_MIN(nr) (0x31 + (nr) * 2) |
@@ -679,18 +679,22 @@ static struct it87_data *it87_update_device(struct device *dev) | |||
679 | it87_write_value(data, IT87_REG_CONFIG, | 679 | it87_write_value(data, IT87_REG_CONFIG, |
680 | it87_read_value(data, IT87_REG_CONFIG) | 0x40); | 680 | it87_read_value(data, IT87_REG_CONFIG) | 0x40); |
681 | } | 681 | } |
682 | for (i = 0; i <= 7; i++) { | 682 | for (i = 0; i < ARRAY_SIZE(IT87_REG_VIN); i++) { |
683 | if (!(data->has_in & (1 << i))) | ||
684 | continue; | ||
685 | |||
683 | data->in[i][0] = | 686 | data->in[i][0] = |
684 | it87_read_value(data, IT87_REG_VIN(i)); | 687 | it87_read_value(data, IT87_REG_VIN[i]); |
688 | |||
689 | /* VBAT and AVCC don't have limit registers */ | ||
690 | if (i >= 8) | ||
691 | continue; | ||
692 | |||
685 | data->in[i][1] = | 693 | data->in[i][1] = |
686 | it87_read_value(data, IT87_REG_VIN_MIN(i)); | 694 | it87_read_value(data, IT87_REG_VIN_MIN(i)); |
687 | data->in[i][2] = | 695 | data->in[i][2] = |
688 | it87_read_value(data, IT87_REG_VIN_MAX(i)); | 696 | it87_read_value(data, IT87_REG_VIN_MAX(i)); |
689 | } | 697 | } |
690 | /* in8 (battery) has no limit registers */ | ||
691 | data->in[8][0] = it87_read_value(data, IT87_REG_VIN(8)); | ||
692 | if (has_avcc3(data)) | ||
693 | data->in[9][0] = it87_read_value(data, IT87_REG_AVCC3); | ||
694 | 698 | ||
695 | for (i = 0; i < 6; i++) { | 699 | for (i = 0; i < 6; i++) { |
696 | /* Skip disabled fans */ | 700 | /* Skip disabled fans */ |