mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 16:53:20 -04:00
hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks
To guarantee consistency for the read-modify-write access in
cros_ec_hwmon_cooling_set_cur_state(), locking is necessary.
Use the existing hwmon device lock to do so.
Fixes: 5798b62867 ("hwmon: (cros_ec) register fans into thermal framework cooling devices")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20260711-cros_ec-hwmon-locking-v1-3-cb6d0fdbb2d3@weissschuh.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
committed by
Guenter Roeck
parent
434baf3aea
commit
26db273640
@@ -5,6 +5,7 @@
|
||||
* Copyright (C) 2024 Thomas Weißschuh <linux@weissschuh.net>
|
||||
*/
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/math.h>
|
||||
@@ -410,6 +411,8 @@ static int cros_ec_hwmon_cooling_get_cur_state(struct thermal_cooling_device *cd
|
||||
u8 read_val;
|
||||
int ret;
|
||||
|
||||
guard(hwmon_lock)(priv->hwmon_priv->hwmon_dev);
|
||||
|
||||
ret = cros_ec_hwmon_read_pwm_value(priv->hwmon_priv->cros_ec, priv->index, &read_val);
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -423,6 +426,8 @@ static int cros_ec_hwmon_cooling_set_cur_state(struct thermal_cooling_device *cd
|
||||
{
|
||||
const struct cros_ec_hwmon_cooling_priv *priv = cdev->devdata;
|
||||
|
||||
guard(hwmon_lock)(priv->hwmon_priv->hwmon_dev);
|
||||
|
||||
return cros_ec_hwmon_write_pwm_input(priv->hwmon_priv->cros_ec, priv->index, val);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user