Re: [PATCH] iio: temperature: mcp9600: Bound thresholds before scaling
From: Joshua Crofts
Date: Mon Nov 09 2026 - 18:03:44 EST
On Mon, 9 Nov 2026 17:35:17 +0800
Zhu Jun <zhujun2@xxxxxxxxxxxxxxxxxxxx> wrote:
> From: zhujun <zhujun2@xxxxxxxxxxxxxxxxxxxx>
>
> mcp9600_write_thresh() multiplies the integer part by 1000000 before
> clamping to the supported temperature range. The multiplication can
> overflow int, so a request such as 3000 degrees can select the lower
> threshold instead of the upper threshold.
>
> Clamp the integer part to the hot-junction range before scaling. Keep
> the existing final clamp for fractional values and the narrower cold-
> junction range.
>
> Fixes: dea750f8015b ("iio: temperature: mcp9600: add threshold events support")
> ---
> Validation: x86-64 and i386 driver objects built with W=1.
> Source-extracted boundary tests passed on 32-bit and 64-bit;
> the corresponding test fails on the base revision. I/O is mocked.
> No physical sensor hardware or booted-kernel test was available.
> OpenAI Codex assisted analysis, code, tests and changelog drafting.
> The human submitter must review and add their Signed-off-by.
Just noticed this sentence... I guess this was copied 1:1 from Codex...
--
Joshua Crofts