[PATCH 3/5] hwmon: (cros_ec) Split out cros_ec_hwmon_get_thermal_config()
From: Thomas Weißschuh
Date: Fri May 29 2026 - 16:38:22 EST
Some upcoming changes require access to the raw
'struct ec_thermal_config'.
Split out the logic to get it from the EC into a new helper.
Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
drivers/hwmon/cros_ec_hwmon.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c
index 932e45caba9c..a6cc909e56b7 100644
--- a/drivers/hwmon/cros_ec_hwmon.c
+++ b/drivers/hwmon/cros_ec_hwmon.c
@@ -117,19 +117,31 @@ static int cros_ec_hwmon_read_temp(struct cros_ec_device *cros_ec, u8 index, u8
return 0;
}
-static int cros_ec_hwmon_read_temp_threshold(struct cros_ec_device *cros_ec, u8 index,
- enum ec_temp_thresholds threshold, u32 *temp)
+static int cros_ec_hwmon_get_thermal_config(struct cros_ec_device *cros_ec, u8 index,
+ struct ec_thermal_config *config)
{
struct ec_params_thermal_get_threshold_v1 req = {};
- struct ec_thermal_config resp;
int ret;
req.sensor_num = index;
ret = cros_ec_cmd(cros_ec, 1, EC_CMD_THERMAL_GET_THRESHOLD,
- &req, sizeof(req), &resp, sizeof(resp));
+ &req, sizeof(req), config, sizeof(*config));
if (ret < 0)
return ret;
+ return 0;
+}
+
+static int cros_ec_hwmon_read_temp_threshold(struct cros_ec_device *cros_ec, u8 index,
+ enum ec_temp_thresholds threshold, u32 *temp)
+{
+ struct ec_thermal_config resp;
+ int ret;
+
+ ret = cros_ec_hwmon_get_thermal_config(cros_ec, index, &resp);
+ if (ret)
+ return ret;
+
*temp = resp.temp_host[threshold];
return 0;
}
--
2.54.0