public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.10 1/9] hwmon: (f71882fg) Fix negative temperature
@ 2022-05-10 15:45 Sasha Levin
  2022-05-10 15:45 ` [PATCH AUTOSEL 5.10 2/9] ASoC: max98090: Reject invalid values in custom control put() Sasha Levin
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Sasha Levin @ 2022-05-10 15:45 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Ji-Ze Hong (Peter Hong), Ji-Ze Hong, Guenter Roeck, Sasha Levin,
	jdelvare, linux-hwmon

From: "Ji-Ze Hong (Peter Hong)" <hpeter@gmail.com>

[ Upstream commit 4aaaaf0f279836f06d3b9d0ffeec7a1e1a04ceef ]

All temperature of Fintek superio hwmonitor that using 1-byte reg will use
2's complement.

In show_temp()
	temp = data->temp[nr] * 1000;

When data->temp[nr] read as 255, it indicate -1C, but this code will report
255C to userspace. It'll be ok when change to:
	temp = ((s8)data->temp[nr]) * 1000;

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
Link: https://lore.kernel.org/r/20220418090706.6339-1-hpeter+linux_kernel@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hwmon/f71882fg.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
index 4dec793fd07d..94b35723ee7a 100644
--- a/drivers/hwmon/f71882fg.c
+++ b/drivers/hwmon/f71882fg.c
@@ -1577,8 +1577,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
 		temp *= 125;
 		if (sign)
 			temp -= 128000;
-	} else
-		temp = data->temp[nr] * 1000;
+	} else {
+		temp = ((s8)data->temp[nr]) * 1000;
+	}
 
 	return sprintf(buf, "%d\n", temp);
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-05-10 15:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-10 15:45 [PATCH AUTOSEL 5.10 1/9] hwmon: (f71882fg) Fix negative temperature Sasha Levin
2022-05-10 15:45 ` [PATCH AUTOSEL 5.10 2/9] ASoC: max98090: Reject invalid values in custom control put() Sasha Levin
2022-05-10 15:45 ` [PATCH AUTOSEL 5.10 3/9] ASoC: max98090: Generate notifications on changes for custom control Sasha Levin
2022-05-10 15:45 ` [PATCH AUTOSEL 5.10 4/9] ASoC: ops: Validate input values in snd_soc_put_volsw_range() Sasha Levin
2022-05-10 15:45 ` [PATCH AUTOSEL 5.10 5/9] s390: disable -Warray-bounds Sasha Levin
2022-05-10 15:45 ` [PATCH AUTOSEL 5.10 6/9] net: emaclite: Don't advertise 1000BASE-T and do auto negotiation Sasha Levin
2022-05-10 15:45 ` [PATCH AUTOSEL 5.10 7/9] net: sfp: Add tx-fault workaround for Huawei MA5671A SFP ONT Sasha Levin
2022-05-10 15:45 ` [PATCH AUTOSEL 5.10 8/9] tcp: resalt the secret every 10 seconds Sasha Levin
2022-05-10 15:45 ` [PATCH AUTOSEL 5.10 9/9] Revert "parisc: Fix patch code locking and flushing" Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox