diff options
Diffstat (limited to 'drivers/hwmon/adm1031.c')
-rw-r--r-- | drivers/hwmon/adm1031.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index ff37363ea5bc..44e1fd7f3d81 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -233,18 +233,15 @@ static const auto_chan_table_t auto_channel_select_table_adm1030 = { | |||
233 | * nearest match if no exact match where found. | 233 | * nearest match if no exact match where found. |
234 | */ | 234 | */ |
235 | static int | 235 | static int |
236 | get_fan_auto_nearest(struct adm1031_data *data, | 236 | get_fan_auto_nearest(struct adm1031_data *data, int chan, u8 val, u8 reg) |
237 | int chan, u8 val, u8 reg, u8 *new_reg) | ||
238 | { | 237 | { |
239 | int i; | 238 | int i; |
240 | int first_match = -1, exact_match = -1; | 239 | int first_match = -1, exact_match = -1; |
241 | u8 other_reg_val = | 240 | u8 other_reg_val = |
242 | (*data->chan_select_table)[FAN_CHAN_FROM_REG(reg)][chan ? 0 : 1]; | 241 | (*data->chan_select_table)[FAN_CHAN_FROM_REG(reg)][chan ? 0 : 1]; |
243 | 242 | ||
244 | if (val == 0) { | 243 | if (val == 0) |
245 | *new_reg = 0; | ||
246 | return 0; | 244 | return 0; |
247 | } | ||
248 | 245 | ||
249 | for (i = 0; i < 8; i++) { | 246 | for (i = 0; i < 8; i++) { |
250 | if ((val == (*data->chan_select_table)[i][chan]) && | 247 | if ((val == (*data->chan_select_table)[i][chan]) && |
@@ -264,13 +261,11 @@ get_fan_auto_nearest(struct adm1031_data *data, | |||
264 | } | 261 | } |
265 | 262 | ||
266 | if (exact_match >= 0) | 263 | if (exact_match >= 0) |
267 | *new_reg = exact_match; | 264 | return exact_match; |
268 | else if (first_match >= 0) | 265 | else if (first_match >= 0) |
269 | *new_reg = first_match; | 266 | return first_match; |
270 | else | ||
271 | return -EINVAL; | ||
272 | 267 | ||
273 | return 0; | 268 | return -EINVAL; |
274 | } | 269 | } |
275 | 270 | ||
276 | static ssize_t show_fan_auto_channel(struct device *dev, | 271 | static ssize_t show_fan_auto_channel(struct device *dev, |
@@ -301,11 +296,12 @@ set_fan_auto_channel(struct device *dev, struct device_attribute *attr, | |||
301 | 296 | ||
302 | mutex_lock(&data->update_lock); | 297 | mutex_lock(&data->update_lock); |
303 | 298 | ||
304 | ret = get_fan_auto_nearest(data, nr, val, data->conf1, ®); | 299 | ret = get_fan_auto_nearest(data, nr, val, data->conf1); |
305 | if (ret) { | 300 | if (ret < 0) { |
306 | mutex_unlock(&data->update_lock); | 301 | mutex_unlock(&data->update_lock); |
307 | return ret; | 302 | return ret; |
308 | } | 303 | } |
304 | reg = ret; | ||
309 | data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1); | 305 | data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1); |
310 | if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) ^ | 306 | if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) ^ |
311 | (old_fan_mode & ADM1031_CONF1_AUTO_MODE)) { | 307 | (old_fan_mode & ADM1031_CONF1_AUTO_MODE)) { |