Re: [PATCH 3/3] hwmon: (max31760) Report 0 RPM before the first fan speed measurement

From: Guenter Roeck

Date: Sun Nov 08 2026 - 10:58:52 EST


On Sun, Nov 08, 2026 at 03:59:55AM +0000, Stanislav Aleksandrov wrote:
> The tachometer count registers initialize to 0 until the first
> measurement cycle completes after power-on. To prevent division by
> zero, tach_to_rpm() clamped tach == 0 to 1, causing it to compute
> and report 3,000,000 RPM (60 * 100000 / 1 / 2).
>
> Return 0 RPM when tach == 0 instead.
>
> Fixes: 38b04ad02d0d ("drivers: hwmon: Add max31760 fan speed controller driver")
> Signed-off-by: Stanislav Aleksandrov <lightofmysoul@xxxxxxxxx>

Applied.

Thanks,
Guenter

> ---
> drivers/hwmon/max31760.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/max31760.c b/drivers/hwmon/max31760.c
> index e967555a21af..896bd0326b8c 100644
> --- a/drivers/hwmon/max31760.c
> +++ b/drivers/hwmon/max31760.c
> @@ -68,8 +68,9 @@ static const int max31760_pwm_freq[] = {33, 150, 1500, 25000};
>
> static int tach_to_rpm(u16 tach)
> {
> + /* The count is 0 until the first measurement */
> if (tach == 0)
> - tach = 1;
> + return 0;
>
> return 60 * 100000 / tach / 2;
> }