diff options
author | Amy Shih <amy.shih@advantech.com.tw> | 2020-05-12 09:38:06 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-06-03 08:21:14 +0200 |
commit | ce1ef281e786bcb00eeb227ae07705ae67eda18b (patch) | |
tree | e227046644d2820070ffee8ad2dfb9b92749cf18 /drivers/hwmon | |
parent | 68d72327999af2c7d9955ded4c0e9033fd3f477f (diff) |
hwmon: (nct7904) Fix incorrect range of temperature limit registers
[ Upstream commit 7b2fd270af27edaf02acb41a7babe805a9441914 ]
The format of temperature limitation registers are 8-bit 2's complement
and the range is -128~127.
Converts the reading value to signed char to fix the incorrect range
of temperature limitation registers.
Signed-off-by: Amy Shih <amy.shih@advantech.com.tw>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/nct7904.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c index 281c81edabc6..dfb122b5e1b7 100644 --- a/drivers/hwmon/nct7904.c +++ b/drivers/hwmon/nct7904.c @@ -356,6 +356,7 @@ static int nct7904_read_temp(struct device *dev, u32 attr, int channel, struct nct7904_data *data = dev_get_drvdata(dev); int ret, temp; unsigned int reg1, reg2, reg3; + s8 temps; switch (attr) { case hwmon_temp_input: @@ -461,7 +462,8 @@ static int nct7904_read_temp(struct device *dev, u32 attr, int channel, if (ret < 0) return ret; - *val = ret * 1000; + temps = ret; + *val = temps * 1000; return 0; } |