Re: [PATCH v2] hwmon: (adm1177) fix sysfs ABI violation and current unit conversion

From: Guenter Roeck

Date: Wed Mar 25 2026 - 10:06:22 EST


On Wed, Mar 25, 2026 at 05:13:06AM +0000, Pradhan, Sanman wrote:
> From: Sanman Pradhan <psanman@xxxxxxxxxxx>
>
> The adm1177 driver exposes the current alert threshold through
> hwmon_curr_max_alarm. This violates the hwmon sysfs ABI, where
> *_alarm attributes are read-only status flags and writable thresholds
> must use currN_max.
>
> The driver also stores the threshold internally in microamps, while
> currN_max is defined in milliamps. Convert the threshold accordingly
> on both the read and write paths.
>
> Widen the cached threshold and related calculations to 64 bits so
> that small shunt resistor values do not cause truncation or overflow.
> Also use 64-bit arithmetic for the mA/uA conversions, clamp writes
> to the range the hardware can represent, and propagate failures from
> adm1177_write_alert_thr() instead of silently ignoring them.
>
> Update the hwmon documentation to reflect the attribute rename and
> the correct units returned by the driver.
>
> Fixes: 09b08ac9e8d5 ("hwmon: (adm1177) Add ADM1177 Hot Swap Controller and Digital Power Monitor driver")
> Signed-off-by: Sanman Pradhan <psanman@xxxxxxxxxxx>
> Acked-by: Nuno Sá <nuno.sa@xxxxxxxxxx>

Applied.

Thanks,
Guenter