diff options
author | Jean Delvare <khali@linux-fr.org> | 2011-11-04 07:00:47 -0400 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2011-11-04 07:00:47 -0400 |
commit | 6ba71de5f81bbf639b5dcea2bc2c33cdb87ed782 (patch) | |
tree | 3c982ed45c7f7e51da0b2e735407b9ad3952e843 /drivers/hwmon/w83627ehf.c | |
parent | 2265cef2751b3441df91f85e0107f9f549e5b711 (diff) |
hwmon: (w83627ehf) Clean up probe function
The probe function has grown pretty large, I think it's time for some
cleanups, starting with these two simple ones:
* Move temp3/in6 check for the W83667HG later in the function, where
it is done for all other chip types.
* Move temperature register setting to a separate function, to avoid
code duplication.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon/w83627ehf.c')
-rw-r--r-- | drivers/hwmon/w83627ehf.c | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 9354f9541313..81534cbd0aff 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c | |||
@@ -1853,6 +1853,19 @@ static void w82627ehf_swap_tempreg(struct w83627ehf_data *data, | |||
1853 | } | 1853 | } |
1854 | 1854 | ||
1855 | static void __devinit | 1855 | static void __devinit |
1856 | w83627ehf_set_temp_reg_ehf(struct w83627ehf_data *data, int n_temp) | ||
1857 | { | ||
1858 | int i; | ||
1859 | |||
1860 | for (i = 0; i < n_temp; i++) { | ||
1861 | data->reg_temp[i] = W83627EHF_REG_TEMP[i]; | ||
1862 | data->reg_temp_over[i] = W83627EHF_REG_TEMP_OVER[i]; | ||
1863 | data->reg_temp_hyst[i] = W83627EHF_REG_TEMP_HYST[i]; | ||
1864 | data->reg_temp_config[i] = W83627EHF_REG_TEMP_CONFIG[i]; | ||
1865 | } | ||
1866 | } | ||
1867 | |||
1868 | static void __devinit | ||
1856 | w83627ehf_check_fan_inputs(const struct w83627ehf_sio_data *sio_data, | 1869 | w83627ehf_check_fan_inputs(const struct w83627ehf_sio_data *sio_data, |
1857 | struct w83627ehf_data *data) | 1870 | struct w83627ehf_data *data) |
1858 | { | 1871 | { |
@@ -1955,17 +1968,8 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev) | |||
1955 | || sio_data->kind == nct6775 | 1968 | || sio_data->kind == nct6775 |
1956 | || sio_data->kind == nct6776) ? 3 : 4; | 1969 | || sio_data->kind == nct6776) ? 3 : 4; |
1957 | 1970 | ||
1971 | /* Default to 3 temperature inputs, code below will adjust as needed */ | ||
1958 | data->have_temp = 0x07; | 1972 | data->have_temp = 0x07; |
1959 | /* Check temp3 configuration bit for 667HG */ | ||
1960 | if (sio_data->kind == w83667hg) { | ||
1961 | u8 reg; | ||
1962 | |||
1963 | reg = w83627ehf_read_value(data, W83627EHF_REG_TEMP_CONFIG[2]); | ||
1964 | if (reg & 0x01) | ||
1965 | data->have_temp &= ~(1 << 2); | ||
1966 | else | ||
1967 | data->in6_skip = 1; /* either temp3 or in6 */ | ||
1968 | } | ||
1969 | 1973 | ||
1970 | /* Deal with temperature register setup first. */ | 1974 | /* Deal with temperature register setup first. */ |
1971 | if (sio_data->kind == nct6775 || sio_data->kind == nct6776) { | 1975 | if (sio_data->kind == nct6775 || sio_data->kind == nct6776) { |
@@ -2042,16 +2046,12 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev) | |||
2042 | } else if (sio_data->kind == w83667hg_b) { | 2046 | } else if (sio_data->kind == w83667hg_b) { |
2043 | u8 reg; | 2047 | u8 reg; |
2044 | 2048 | ||
2049 | w83627ehf_set_temp_reg_ehf(data, 4); | ||
2050 | |||
2045 | /* | 2051 | /* |
2046 | * Temperature sources are selected with bank 0, registers 0x49 | 2052 | * Temperature sources are selected with bank 0, registers 0x49 |
2047 | * and 0x4a. | 2053 | * and 0x4a. |
2048 | */ | 2054 | */ |
2049 | for (i = 0; i < ARRAY_SIZE(W83627EHF_REG_TEMP); i++) { | ||
2050 | data->reg_temp[i] = W83627EHF_REG_TEMP[i]; | ||
2051 | data->reg_temp_over[i] = W83627EHF_REG_TEMP_OVER[i]; | ||
2052 | data->reg_temp_hyst[i] = W83627EHF_REG_TEMP_HYST[i]; | ||
2053 | data->reg_temp_config[i] = W83627EHF_REG_TEMP_CONFIG[i]; | ||
2054 | } | ||
2055 | reg = w83627ehf_read_value(data, 0x4a); | 2055 | reg = w83627ehf_read_value(data, 0x4a); |
2056 | data->temp_src[0] = reg >> 5; | 2056 | data->temp_src[0] = reg >> 5; |
2057 | reg = w83627ehf_read_value(data, 0x49); | 2057 | reg = w83627ehf_read_value(data, 0x49); |
@@ -2086,12 +2086,23 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev) | |||
2086 | 2086 | ||
2087 | data->temp_label = w83667hg_b_temp_label; | 2087 | data->temp_label = w83667hg_b_temp_label; |
2088 | } else { | 2088 | } else { |
2089 | w83627ehf_set_temp_reg_ehf(data, 3); | ||
2090 | |||
2089 | /* Temperature sources are fixed */ | 2091 | /* Temperature sources are fixed */ |
2090 | for (i = 0; i < 3; i++) { | 2092 | |
2091 | data->reg_temp[i] = W83627EHF_REG_TEMP[i]; | 2093 | if (sio_data->kind == w83667hg) { |
2092 | data->reg_temp_over[i] = W83627EHF_REG_TEMP_OVER[i]; | 2094 | u8 reg; |
2093 | data->reg_temp_hyst[i] = W83627EHF_REG_TEMP_HYST[i]; | 2095 | |
2094 | data->reg_temp_config[i] = W83627EHF_REG_TEMP_CONFIG[i]; | 2096 | /* |
2097 | * Chip supports either AUXTIN or VIN3. Try to find | ||
2098 | * out which one. | ||
2099 | */ | ||
2100 | reg = w83627ehf_read_value(data, | ||
2101 | W83627EHF_REG_TEMP_CONFIG[2]); | ||
2102 | if (reg & 0x01) | ||
2103 | data->have_temp &= ~(1 << 2); | ||
2104 | else | ||
2105 | data->in6_skip = 1; | ||
2095 | } | 2106 | } |
2096 | } | 2107 | } |
2097 | 2108 | ||