aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adt7470.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/adt7470.c')
-rw-r--r--drivers/hwmon/adt7470.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index 1311a595147e..da6c9306ca5f 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -137,8 +137,6 @@ I2C_CLIENT_INSMOD_1(adt7470);
137#define FAN_PERIOD_INVALID 65535 137#define FAN_PERIOD_INVALID 65535
138#define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID) 138#define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID)
139 139
140#define ROUND_DIV(x, divisor) (((x) + ((divisor) / 2)) / (divisor))
141
142struct adt7470_data { 140struct adt7470_data {
143 struct device *hwmon_dev; 141 struct device *hwmon_dev;
144 struct attribute_group attrs; 142 struct attribute_group attrs;
@@ -360,7 +358,7 @@ static ssize_t set_temp_min(struct device *dev,
360 if (strict_strtol(buf, 10, &temp)) 358 if (strict_strtol(buf, 10, &temp))
361 return -EINVAL; 359 return -EINVAL;
362 360
363 temp = ROUND_DIV(temp, 1000); 361 temp = DIV_ROUND_CLOSEST(temp, 1000);
364 temp = SENSORS_LIMIT(temp, 0, 255); 362 temp = SENSORS_LIMIT(temp, 0, 255);
365 363
366 mutex_lock(&data->lock); 364 mutex_lock(&data->lock);
@@ -394,7 +392,7 @@ static ssize_t set_temp_max(struct device *dev,
394 if (strict_strtol(buf, 10, &temp)) 392 if (strict_strtol(buf, 10, &temp))
395 return -EINVAL; 393 return -EINVAL;
396 394
397 temp = ROUND_DIV(temp, 1000); 395 temp = DIV_ROUND_CLOSEST(temp, 1000);
398 temp = SENSORS_LIMIT(temp, 0, 255); 396 temp = SENSORS_LIMIT(temp, 0, 255);
399 397
400 mutex_lock(&data->lock); 398 mutex_lock(&data->lock);
@@ -671,7 +669,7 @@ static ssize_t set_pwm_tmin(struct device *dev,
671 if (strict_strtol(buf, 10, &temp)) 669 if (strict_strtol(buf, 10, &temp))
672 return -EINVAL; 670 return -EINVAL;
673 671
674 temp = ROUND_DIV(temp, 1000); 672 temp = DIV_ROUND_CLOSEST(temp, 1000);
675 temp = SENSORS_LIMIT(temp, 0, 255); 673 temp = SENSORS_LIMIT(temp, 0, 255);
676 674
677 mutex_lock(&data->lock); 675 mutex_lock(&data->lock);