Skip to content

Commit

Permalink
hwmon: (lm95241) Use more accurate limits
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
groeck committed Sep 9, 2016
1 parent e8172a9 commit 637ab15
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions drivers/hwmon/lm95241.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);

Expand All @@ -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,
Expand All @@ -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);

Expand Down

0 comments on commit 637ab15

Please sign in to comment.