]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
hwmon: (pwm-fan) Fix RPM calculation
authorPaul Barker <pbarker@konsulko.com>
Wed, 11 Nov 2020 16:46:43 +0000 (16:46 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Nov 2020 12:38:53 +0000 (13:38 +0100)
commit72d9927b7bdc51ebdac7ff8e65fd7a9ca30f248e
treed76873fa338ee6a8faa8816c84a7eb39c45df8c5
parentefbd794540ad887ca03bfe7b154e67c93cdae3ca
hwmon: (pwm-fan) Fix RPM calculation

[ Upstream commit fd8feec665fef840277515a5c2b9b7c3e3970fad ]

To convert the number of pulses counted into an RPM estimation, we need
to divide by the width of our measurement interval instead of
multiplying by it. If the width of the measurement interval is zero we
don't update the RPM value to avoid dividing by zero.

We also don't need to do 64-bit division, with 32-bits we can handle a
fan running at over 4 million RPM.

Signed-off-by: Paul Barker <pbarker@konsulko.com>
Link: https://lore.kernel.org/r/20201111164643.7087-1-pbarker@konsulko.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hwmon/pwm-fan.c