From 849562406e995a1db34f7c09f17dd994d5510370 Mon Sep 17 00:00:00 2001 From: Ksawlii Date: Sun, 24 Nov 2024 00:23:40 +0100 Subject: [PATCH] Revert "hwmon: (lm95234) Fix underflows seen when writing limit attributes" This reverts commit 05464792b17b1717862d4df54cc5c45ff24ab53f. --- drivers/hwmon/lm95234.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/lm95234.c b/drivers/hwmon/lm95234.c index db2aecdfb..ac169a994 100755 --- a/drivers/hwmon/lm95234.c +++ b/drivers/hwmon/lm95234.c @@ -301,8 +301,7 @@ static ssize_t tcrit2_store(struct device *dev, struct device_attribute *attr, if (ret < 0) return ret; - val = DIV_ROUND_CLOSEST(clamp_val(val, 0, (index ? 255 : 127) * 1000), - 1000); + val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 0, index ? 255 : 127); mutex_lock(&data->update_lock); data->tcrit2[index] = val; @@ -351,7 +350,7 @@ static ssize_t tcrit1_store(struct device *dev, struct device_attribute *attr, if (ret < 0) return ret; - val = DIV_ROUND_CLOSEST(clamp_val(val, 0, 255000), 1000); + val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 0, 255); mutex_lock(&data->update_lock); data->tcrit1[index] = val; @@ -392,7 +391,7 @@ static ssize_t tcrit1_hyst_store(struct device *dev, if (ret < 0) return ret; - val = DIV_ROUND_CLOSEST(clamp_val(val, -255000, 255000), 1000); + val = DIV_ROUND_CLOSEST(val, 1000); val = clamp_val((int)data->tcrit1[index] - val, 0, 31); mutex_lock(&data->update_lock); @@ -432,7 +431,7 @@ static ssize_t offset_store(struct device *dev, struct device_attribute *attr, return ret; /* Accuracy is 1/2 degrees C */ - val = DIV_ROUND_CLOSEST(clamp_val(val, -64000, 63500), 500); + val = clamp_val(DIV_ROUND_CLOSEST(val, 500), -128, 127); mutex_lock(&data->update_lock); data->toffset[index] = val;