hwmon: (emc2305) fix pwm never being able to set lower
authorXingjiang Qiao <nanpuyue@gmail.com>
Tue, 6 Dec 2022 05:53:31 +0000 (13:53 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:23 +0000 (13:32 +0100)
commit774d97b5ed7c8b837cd5fcf6efe79fa8e22ad2b0
tree46c392eb07fb129976717e020bb64eaea0d217f2
parent4cf53e91f36a8e8b7b6ffe33fd5c8ad195ed0f80
hwmon: (emc2305) fix pwm never being able to set lower

[ Upstream commit 364ffd2537c44cb6914ff5669153f4a86fffad29 ]

There are fields 'last_hwmon_state' and 'last_thermal_state' in the
structure 'emc2305_cdev_data', which respectively store the cooling state
set by the 'hwmon' and 'thermal' subsystem, and the driver author hopes
that if the state set by 'hwmon' is lower than the value set by 'thermal',
the driver will just save it without actually setting the pwm. Currently,
the 'last_thermal_state' also be updated by 'hwmon', which will cause the
cooling state to never be set to a lower value. This patch fixes that.

Signed-off-by: Xingjiang Qiao <nanpuyue@gmail.com>
Link: https://lore.kernel.org/r/20221206055331.170459-2-nanpuyue@gmail.com
Fixes: 0d8400c5a2ce1 ("hwmon: (emc2305) add support for EMC2301/2/3/5 RPM-based PWM Fan Speed Controller.")
[groeck: renamed emc2305_set_cur_state_shim -> __emc2305_set_cur_state]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hwmon/emc2305.c