Skip to content

Commit 6ba71de

Browse files
Jean DelvareJean Delvare
authored andcommitted
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>
1 parent 2265cef commit 6ba71de

1 file changed

Lines changed: 32 additions & 21 deletions

File tree

‎drivers/hwmon/w83627ehf.c‎

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,19 @@ static void w82627ehf_swap_tempreg(struct w83627ehf_data *data,
18521852
data->reg_temp_config[r2] = tmp;
18531853
}
18541854

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+
18551868
static void __devinit
18561869
w83627ehf_check_fan_inputs(const struct w83627ehf_sio_data *sio_data,
18571870
struct w83627ehf_data *data)
@@ -1955,17 +1968,8 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
19551968
|| sio_data->kind == nct6775
19561969
|| sio_data->kind == nct6776) ? 3 : 4;
19571970

1971+
/* Default to 3 temperature inputs, code below will adjust as needed */
19581972
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-
}
19691973

19701974
/* Deal with temperature register setup first. */
19711975
if (sio_data->kind == nct6775 || sio_data->kind == nct6776) {
@@ -2042,16 +2046,12 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
20422046
} else if (sio_data->kind == w83667hg_b) {
20432047
u8 reg;
20442048

2049+
w83627ehf_set_temp_reg_ehf(data, 4);
2050+
20452051
/*
20462052
* Temperature sources are selected with bank 0, registers 0x49
20472053
* and 0x4a.
20482054
*/
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-
}
20552055
reg = w83627ehf_read_value(data, 0x4a);
20562056
data->temp_src[0] = reg >> 5;
20572057
reg = w83627ehf_read_value(data, 0x49);
@@ -2086,12 +2086,23 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
20862086

20872087
data->temp_label = w83667hg_b_temp_label;
20882088
} else {
2089+
w83627ehf_set_temp_reg_ehf(data, 3);
2090+
20892091
/* Temperature sources are fixed */
2090-
for (i = 0; i < 3; i++) {
2091-
data->reg_temp[i] = W83627EHF_REG_TEMP[i];
2092-
data->reg_temp_over[i] = W83627EHF_REG_TEMP_OVER[i];
2093-
data->reg_temp_hyst[i] = W83627EHF_REG_TEMP_HYST[i];
2094-
data->reg_temp_config[i] = W83627EHF_REG_TEMP_CONFIG[i];
2092+
2093+
if (sio_data->kind == w83667hg) {
2094+
u8 reg;
2095+
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;
20952106
}
20962107
}
20972108

0 commit comments

Comments
 (0)