Re: [PATCH] hwmon: (lm95245) Fix negative temperature conversion
From: Guenter Roeck
Date: Thu Sep 24 2026 - 13:28:32 EST
On Wed, Sep 23, 2026 at 05:25:48PM +0000, Ridham Khurana wrote:
> temp_from_reg_signed() uses only the high byte when the sign bit is set
> and drops the fractional bits in the low byte. Writing -500 to
> temp2_offset stores 0xff80 (-0.5 degrees C) in the offset registers,
> but reading temp2_offset back returns -1000.
>
> Negative temp1_input and temp2_input values are rounded down to the
> next whole degree the same way. The chip reports -0.125 degrees C as
> 0xffe0, which the driver returns as -1000.
>
> Treat the register pair as a single 16-bit two's complement value.
> lm95241 had the same conversion fixed in commit 0c2a40e2fe4f
> ("hwmon: (lm95241) Fix negative temperature results").
>
> Fixes: fffd80ccc1e6 ("hwmon: LM95245 driver")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Ridham Khurana <khurana.ridham222@xxxxxxxxx>
Applied.
Thanks,
Guenter