diff options
author | Zhuang Yuyao <mlistz@gmail.com> | 2016-04-17 20:21:42 -0400 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2016-04-21 17:20:59 -0400 |
commit | 9a3dce62cc5640d7ea17733a2bd1b57665c232b0 (patch) | |
tree | 18262d9099432d76b6598453783c69ea25d77c8a | |
parent | 00c9329ebe2d19a13afd86ba75218f868f2788ba (diff) |
rtc: ds1307: ds3231 temperature s16 overflow
while retrieving temperature from ds3231, the result may be overflow
since s16 is too small for a multiplication with 250.
ie. if temp_buf[0] == 0x2d, the result (s16 temp) will be negative.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Tested-by: Michael Tatarinov <kukabu@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
-rw-r--r-- | drivers/rtc/rtc-ds1307.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index b2156ee5bae1..ee3cae2f212e 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -863,7 +863,7 @@ out: | |||
863 | * A user-initiated temperature conversion is not started by this function, | 863 | * A user-initiated temperature conversion is not started by this function, |
864 | * so the temperature is updated once every 64 seconds. | 864 | * so the temperature is updated once every 64 seconds. |
865 | */ | 865 | */ |
866 | static int ds3231_hwmon_read_temp(struct device *dev, s16 *mC) | 866 | static int ds3231_hwmon_read_temp(struct device *dev, s32 *mC) |
867 | { | 867 | { |
868 | struct ds1307 *ds1307 = dev_get_drvdata(dev); | 868 | struct ds1307 *ds1307 = dev_get_drvdata(dev); |
869 | u8 temp_buf[2]; | 869 | u8 temp_buf[2]; |
@@ -892,7 +892,7 @@ static ssize_t ds3231_hwmon_show_temp(struct device *dev, | |||
892 | struct device_attribute *attr, char *buf) | 892 | struct device_attribute *attr, char *buf) |
893 | { | 893 | { |
894 | int ret; | 894 | int ret; |
895 | s16 temp; | 895 | s32 temp; |
896 | 896 | ||
897 | ret = ds3231_hwmon_read_temp(dev, &temp); | 897 | ret = ds3231_hwmon_read_temp(dev, &temp); |
898 | if (ret) | 898 | if (ret) |