diff options
| author | Cong Nguyen <congnt264@gmail.com> | 2026-08-10 11:28:39 +0700 |
|---|---|---|
| committer | Guenter Roeck <linux@roeck-us.net> | 2026-08-16 14:40:33 -0700 |
| commit | acc52bd431e2d8698fae8d82a74ac45d79b62e0a (patch) | |
| tree | 10a8188ad1029ae027da83eee28053b3fde4758c /tools/perf/scripts/python/bin/stackcollapse-record | |
| parent | 24fbeb83d9b750a36da42cb835a154d80fd3d495 (diff) | |
hwmon: (max6621) fix negative temperature offset and crit readings
max6621_read() reads the CONFIG2 offset and the critical alert threshold
registers into a u32 and scales them without sign extension:
/* offset */ *val = (regval >> MAX6621_REG_TEMP_SHIFT) * 1000L;
/* crit */ *val = regval * 1000L;
Both attributes are writable and their write paths clamp to a negative
minimum and encode negative values, so a value written as negative is read
back as a large positive number. For example, writing a -10 degrees C
offset stores max6621_temp_mc2reg(-10000) = (-10 << 6) = 0xfd80; the read
then computes 0xfd80 >> 6 = 1014 -> 1014000 instead of -10000.
Cast the register value to s16 before scaling so the read preserves the
sign the write path encodes. The temperature input path already uses an s8
intermediate and is left unchanged.
Fixes: 92b64580f14b ("hwmon: (max6621) Add support for Maxim MAX6621 temperature sensor")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
Link: https://lore.kernel.org/r/ad0baddbd6163cf73545c8e9273258136718585c.1786334038.git.congnt264@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'tools/perf/scripts/python/bin/stackcollapse-record')
0 files changed, 0 insertions, 0 deletions
