]> www.infradead.org Git - users/jedix/linux-maple.git/commit
hwmon: (amc6821) Make reading and writing fan speed limits consistent
authorGuenter Roeck <linux@roeck-us.net>
Thu, 27 Jun 2024 00:46:04 +0000 (17:46 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 8 Jul 2024 14:52:36 +0000 (07:52 -0700)
commit8f4fd97df27ea4bc8b569c647fb2189a57047cac
tree31caf498d8934799282c8b7b3a7549ffe2907375
parentaf4d04b8ce08a734889fb0777059063635242614
hwmon: (amc6821) Make reading and writing fan speed limits consistent

The default value of the maximum fan speed limit register is 0,
essentially translating to an unlimited fan speed. When reading
the limit, a value of 0 is reported in this case. However, writing
a value of 0 results in writing a value of 0xffff into the register,
which is inconsistent.

To solve the problem, permit writing a limit of 0 for the maximim fan
speed, effectively translating to "no limit". Write 0 into the register
if a limit value of 0 is written. Otherwise limit the range to
<1..6000000> and write 1..0xffff into the register. This ensures that
reading and writing from and to a limit register return the same value
while at the same time not changing reported values when reading the
speed or limits.

While at it, restrict fan limit writes to non-negative numbers; writing
a negative limit does not make sense and should be reported instead of
being corrected.

Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/amc6821.c