mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
hwmon: (corsair-cpro) Cache fan target only after a successful command
set_target() updates the cached fan target before sending the command.
If the command fails, subsequent fanN_target reads report the failed
request instead of the previous value. For example, after successfully
setting 1200 RPM, a rejected request for 1800 RPM returns an error but
leaves fanN_target reporting 1800. A failed request also replaces
-ENODATA when no target has been successfully set.
Update the target cache under the existing mutex only after
send_usb_cmd() succeeds, as set_pwm() already does when invalidating
the target. Preserve the previous cached value and return the original
error on failure.
Fixes: 40c3a44542 ("hwmon: add Corsair Commander Pro driver")
Cc: stable@vger.kernel.org
Signed-off-by: Baek Kyu, Kim <pocj8ur4in@gmail.com>
Link: https://patch.msgid.link/20261020160941.36787-1-pocj8ur4in@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
5eab1e7f7e
commit
e2c26431b4
|
|
@ -215,10 +215,11 @@ static int set_target(struct ccp_device *ccp, int channel, long val)
|
|||
int ret;
|
||||
|
||||
val = clamp_val(val, 0, 0xFFFF);
|
||||
ccp->target[channel] = val;
|
||||
|
||||
mutex_lock(&ccp->mutex);
|
||||
ret = send_usb_cmd(ccp, CTL_SET_FAN_TARGET, channel, val >> 8, val);
|
||||
if (!ret)
|
||||
ccp->target[channel] = val;
|
||||
|
||||
mutex_unlock(&ccp->mutex);
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user