Re: [PATCH v5 1/5] hwmon: (aquacomputer_d5next) Avoid truncating scaled sensor readings
From: Guenter Roeck
Date: Mon Oct 26 2026 - 16:48:09 EST
On Sun, Sep 27, 2026 at 10:13:12PM +0300, Vas Zayarskiy wrote:
> High Flow Next power is reported in watts. Multiplying the 16-bit value
> by one million can overflow both the signed intermediate and the u32
> cache. Store power in long, perform the conversion in u64, and clamp to
> LONG_MAX. The other existing power conversions fit in a signed 32-bit
> value. Return -ENODATA for unavailable power instead of exposing the
> stored error as a reading.
>
> The power cache is updated by HID reports without the hwmon read mutex.
> Read it once with READ_ONCE() and use that snapshot for both the
> availability check and the returned value. Mark the corresponding
> updates with WRITE_ONCE() so that the shared accesses are explicit.
>
> Widen the shared current cache to u32. The Aquastream XT conversion to
> milliamperes can exceed 65535 mA; clamp its negative conversion results
> to zero before assigning to the unsigned cache. This also permits devices
> with scaled aggregate currents to store milliamperes directly.
>
> Assisted-by: LLM sparse
> Signed-off-by: Vas Zayarskiy <contact@xxxxxxxxx>
Applied.
Thanks,
Guenter