diff options
Diffstat (limited to 'drivers/hwmon/adt7473.c')
-rw-r--r-- | drivers/hwmon/adt7473.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/hwmon/adt7473.c b/drivers/hwmon/adt7473.c index 18aa30866a6c..0a6ce2367b42 100644 --- a/drivers/hwmon/adt7473.c +++ b/drivers/hwmon/adt7473.c | |||
@@ -129,8 +129,6 @@ I2C_CLIENT_INSMOD_1(adt7473); | |||
129 | #define FAN_PERIOD_INVALID 65535 | 129 | #define FAN_PERIOD_INVALID 65535 |
130 | #define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID) | 130 | #define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID) |
131 | 131 | ||
132 | #define ROUND_DIV(x, divisor) (((x) + ((divisor) / 2)) / (divisor)) | ||
133 | |||
134 | struct adt7473_data { | 132 | struct adt7473_data { |
135 | struct device *hwmon_dev; | 133 | struct device *hwmon_dev; |
136 | struct attribute_group attrs; | 134 | struct attribute_group attrs; |
@@ -459,7 +457,7 @@ static ssize_t set_temp_min(struct device *dev, | |||
459 | if (strict_strtol(buf, 10, &temp)) | 457 | if (strict_strtol(buf, 10, &temp)) |
460 | return -EINVAL; | 458 | return -EINVAL; |
461 | 459 | ||
462 | temp = ROUND_DIV(temp, 1000); | 460 | temp = DIV_ROUND_CLOSEST(temp, 1000); |
463 | temp = encode_temp(data->temp_twos_complement, temp); | 461 | temp = encode_temp(data->temp_twos_complement, temp); |
464 | 462 | ||
465 | mutex_lock(&data->lock); | 463 | mutex_lock(&data->lock); |
@@ -495,7 +493,7 @@ static ssize_t set_temp_max(struct device *dev, | |||
495 | if (strict_strtol(buf, 10, &temp)) | 493 | if (strict_strtol(buf, 10, &temp)) |
496 | return -EINVAL; | 494 | return -EINVAL; |
497 | 495 | ||
498 | temp = ROUND_DIV(temp, 1000); | 496 | temp = DIV_ROUND_CLOSEST(temp, 1000); |
499 | temp = encode_temp(data->temp_twos_complement, temp); | 497 | temp = encode_temp(data->temp_twos_complement, temp); |
500 | 498 | ||
501 | mutex_lock(&data->lock); | 499 | mutex_lock(&data->lock); |
@@ -720,7 +718,7 @@ static ssize_t set_temp_tmax(struct device *dev, | |||
720 | if (strict_strtol(buf, 10, &temp)) | 718 | if (strict_strtol(buf, 10, &temp)) |
721 | return -EINVAL; | 719 | return -EINVAL; |
722 | 720 | ||
723 | temp = ROUND_DIV(temp, 1000); | 721 | temp = DIV_ROUND_CLOSEST(temp, 1000); |
724 | temp = encode_temp(data->temp_twos_complement, temp); | 722 | temp = encode_temp(data->temp_twos_complement, temp); |
725 | 723 | ||
726 | mutex_lock(&data->lock); | 724 | mutex_lock(&data->lock); |
@@ -756,7 +754,7 @@ static ssize_t set_temp_tmin(struct device *dev, | |||
756 | if (strict_strtol(buf, 10, &temp)) | 754 | if (strict_strtol(buf, 10, &temp)) |
757 | return -EINVAL; | 755 | return -EINVAL; |
758 | 756 | ||
759 | temp = ROUND_DIV(temp, 1000); | 757 | temp = DIV_ROUND_CLOSEST(temp, 1000); |
760 | temp = encode_temp(data->temp_twos_complement, temp); | 758 | temp = encode_temp(data->temp_twos_complement, temp); |
761 | 759 | ||
762 | mutex_lock(&data->lock); | 760 | mutex_lock(&data->lock); |