Commit 91bba688 authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (lm73) Fix lower and upper temperature limits

While the LM73 is only specified for temperatures from -40 to +150 degrees C,
its power-up minimum and maximum temperature limits are -256 and +255.75
degrees C. For better consistency and to avoid confusion, clamp limits to
the power-up limits and not to -40 / +150 degrees C.
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent b0636707
...@@ -36,8 +36,8 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4c, ...@@ -36,8 +36,8 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4c,
#define LM73_ID 0x9001 /* 0x0190, byte-swapped */ #define LM73_ID 0x9001 /* 0x0190, byte-swapped */
#define DRVNAME "lm73" #define DRVNAME "lm73"
#define LM73_TEMP_MIN (-40) #define LM73_TEMP_MIN (-256000 / 250)
#define LM73_TEMP_MAX 150 #define LM73_TEMP_MAX (255750 / 250)
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
...@@ -56,8 +56,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, ...@@ -56,8 +56,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
return status; return status;
/* Write value */ /* Write value */
value = (short) clamp_val(temp / 250, LM73_TEMP_MIN * 4, value = clamp_val(temp / 250, LM73_TEMP_MIN, LM73_TEMP_MAX) << 5;
LM73_TEMP_MAX * 4) << 5;
err = i2c_smbus_write_word_swapped(client, attr->index, value); err = i2c_smbus_write_word_swapped(client, attr->index, value);
return (err < 0) ? err : count; return (err < 0) ? err : count;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment