From: Guenter Roeck <linux@roeck-us.net>
To: Jean Delvare <jdelvare@suse.com>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 6/6] hwmon: (lm95241) Use more accurate limits
Date: Sun, 7 Aug 2016 16:32:00 -0700 [thread overview]
Message-ID: <1470612720-30165-6-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1470612720-30165-1-git-send-email-linux@roeck-us.net>
The lower temperature limit is -128 degrees C. The supported upper limits
are 127.875 or 255.875 degrees C. Also, don't fail if a value outside
the supported range is provided when setting a temperature limit.
Instead, clamp the provided value to the available value range.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/hwmon/lm95241.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c
index df94f486b21c..3d96c3fcba9b 100644
--- a/drivers/hwmon/lm95241.c
+++ b/drivers/hwmon/lm95241.c
@@ -205,7 +205,7 @@ static ssize_t show_min(struct device *dev, struct device_attribute *attr,
return snprintf(buf, PAGE_SIZE - 1,
data->config & to_sensor_dev_attr(attr)->index ?
- "-127000\n" : "0\n");
+ "-128000\n" : "0\n");
}
static ssize_t set_min(struct device *dev, struct device_attribute *attr,
@@ -216,8 +216,6 @@ static ssize_t set_min(struct device *dev, struct device_attribute *attr,
if (kstrtol(buf, 10, &val) < 0)
return -EINVAL;
- if (val < -128000)
- return -EINVAL;
mutex_lock(&data->update_lock);
@@ -242,7 +240,7 @@ static ssize_t show_max(struct device *dev, struct device_attribute *attr,
return snprintf(buf, PAGE_SIZE - 1,
data->config & to_sensor_dev_attr(attr)->index ?
- "127000\n" : "255000\n");
+ "127875\n" : "255875\n");
}
static ssize_t set_max(struct device *dev, struct device_attribute *attr,
@@ -253,8 +251,6 @@ static ssize_t set_max(struct device *dev, struct device_attribute *attr,
if (kstrtol(buf, 10, &val) < 0)
return -EINVAL;
- if (val >= 256000)
- return -EINVAL;
mutex_lock(&data->update_lock);
--
2.5.0
prev parent reply other threads:[~2016-08-07 23:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-07 23:31 [PATCH 1/6] hwmon: (lm95241) Fix overflow problems, write conversion rate to chip Guenter Roeck
2016-08-07 23:31 ` [PATCH 2/6] hwmon: (lm95241) Add support for fault attributes Guenter Roeck
2016-08-07 23:31 ` [PATCH 3/6] hwmon: (lm95241) Order include files alphabetically Guenter Roeck
2016-08-07 23:31 ` [PATCH 4/6] hwmon: (lm95241) Drop FSF address Guenter Roeck
2016-08-07 23:31 ` [PATCH 5/6] hwmon: (lm95241) Use BIT macro where appropriate Guenter Roeck
2016-08-07 23:32 ` Guenter Roeck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1470612720-30165-6-git-send-email-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).