aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/w83627ehf.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/w83627ehf.c')
-rw-r--r--drivers/hwmon/w83627ehf.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 0e8ffd6059a0..0a89211c25f6 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -354,8 +354,8 @@ static inline unsigned int step_time_from_reg(u8 reg, u8 mode)
354 354
355static inline u8 step_time_to_reg(unsigned int msec, u8 mode) 355static inline u8 step_time_to_reg(unsigned int msec, u8 mode)
356{ 356{
357 return SENSORS_LIMIT((mode ? (msec + 50) / 100 : 357 return clamp_val((mode ? (msec + 50) / 100 : (msec + 200) / 400),
358 (msec + 200) / 400), 1, 255); 358 1, 255);
359} 359}
360 360
361static unsigned int fan_from_reg8(u16 reg, unsigned int divreg) 361static unsigned int fan_from_reg8(u16 reg, unsigned int divreg)
@@ -414,8 +414,7 @@ static inline long in_from_reg(u8 reg, u8 nr, const u16 *scale_in)
414 414
415static inline u8 in_to_reg(u32 val, u8 nr, const u16 *scale_in) 415static inline u8 in_to_reg(u32 val, u8 nr, const u16 *scale_in)
416{ 416{
417 return SENSORS_LIMIT(DIV_ROUND_CLOSEST(val * 100, scale_in[nr]), 0, 417 return clamp_val(DIV_ROUND_CLOSEST(val * 100, scale_in[nr]), 0, 255);
418 255);
419} 418}
420 419
421/* 420/*
@@ -1267,7 +1266,7 @@ store_temp_offset(struct device *dev, struct device_attribute *attr,
1267 if (err < 0) 1266 if (err < 0)
1268 return err; 1267 return err;
1269 1268
1270 val = SENSORS_LIMIT(DIV_ROUND_CLOSEST(val, 1000), -128, 127); 1269 val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), -128, 127);
1271 1270
1272 mutex_lock(&data->update_lock); 1271 mutex_lock(&data->update_lock);
1273 data->temp_offset[nr] = val; 1272 data->temp_offset[nr] = val;
@@ -1435,7 +1434,7 @@ store_pwm(struct device *dev, struct device_attribute *attr,
1435 if (err < 0) 1434 if (err < 0)
1436 return err; 1435 return err;
1437 1436
1438 val = SENSORS_LIMIT(val, 0, 255); 1437 val = clamp_val(val, 0, 255);
1439 1438
1440 mutex_lock(&data->update_lock); 1439 mutex_lock(&data->update_lock);
1441 data->pwm[nr] = val; 1440 data->pwm[nr] = val;
@@ -1514,7 +1513,7 @@ store_target_temp(struct device *dev, struct device_attribute *attr,
1514 if (err < 0) 1513 if (err < 0)
1515 return err; 1514 return err;
1516 1515
1517 val = SENSORS_LIMIT(DIV_ROUND_CLOSEST(val, 1000), 0, 127); 1516 val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 0, 127);
1518 1517
1519 mutex_lock(&data->update_lock); 1518 mutex_lock(&data->update_lock);
1520 data->target_temp[nr] = val; 1519 data->target_temp[nr] = val;
@@ -1540,7 +1539,7 @@ store_tolerance(struct device *dev, struct device_attribute *attr,
1540 return err; 1539 return err;
1541 1540
1542 /* Limit the temp to 0C - 15C */ 1541 /* Limit the temp to 0C - 15C */
1543 val = SENSORS_LIMIT(DIV_ROUND_CLOSEST(val, 1000), 0, 15); 1542 val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 0, 15);
1544 1543
1545 mutex_lock(&data->update_lock); 1544 mutex_lock(&data->update_lock);
1546 if (sio_data->kind == nct6775 || sio_data->kind == nct6776) { 1545 if (sio_data->kind == nct6775 || sio_data->kind == nct6776) {
@@ -1639,7 +1638,7 @@ store_##reg(struct device *dev, struct device_attribute *attr, \
1639 err = kstrtoul(buf, 10, &val); \ 1638 err = kstrtoul(buf, 10, &val); \
1640 if (err < 0) \ 1639 if (err < 0) \
1641 return err; \ 1640 return err; \
1642 val = SENSORS_LIMIT(val, 1, 255); \ 1641 val = clamp_val(val, 1, 255); \
1643 mutex_lock(&data->update_lock); \ 1642 mutex_lock(&data->update_lock); \
1644 data->reg[nr] = val; \ 1643 data->reg[nr] = val; \
1645 w83627ehf_write_value(data, data->REG_##REG[nr], val); \ 1644 w83627ehf_write_value(data, data->REG_##REG[nr], val); \