Re: [PATCH] iio: temperature: tmp117: fix calibbias cache update on I2C write failure

From: David Lechner

Date: Sat Aug 22 2026 - 14:29:15 EST


On 8/21/26 7:49 PM, Salah Triki wrote:
> The calibbias cache (data->calibbias) was updated before the I2C
> write to TMP117_REG_TEMP_OFFSET was known to succeed. If the write
> failed, the function correctly returned an error, but the driver's
> internal cache had already been updated to the new value.
>
> This causes the cache and the actual hardware register to go out of
> sync: a subsequent write of the same value would be silently
> skipped by the early "if (off == data->calibbias) return 0;" check,
> since the cache matches even though the register was never
> successfully updated.
>
> Update data->calibbias only after confirming the I2C write
> succeeded, so the cache always reflects the actual state of the
> device.
>

For fixes, it is always useful to know how you found the problem. I'm
guessing code inspection here.

> Fixes: df041e737a38 ("iio: temperature: add driver support for ti tmp117")
> Signed-off-by: Salah Triki <salah.triki@xxxxxxxxx>
> ---