[PATCH 1/3] hwmon: (cros_ec) Register the thermal devices after the hwmon ones

From: Thomas Weißschuh

Date: Sat Jul 11 2026 - 06:00:19 EST


To guarantee consistency for the read-modify-write access in
cros_ec_hwmon_cooling_set_cur_state(), locking is necessary.
The locking will use standard hwmon device locks, which requires
the hwmon device to be ready before the fan devices are set up.

Reorder the initialization so this works.

Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
drivers/hwmon/cros_ec_hwmon.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c
index 44291799dd8e..f9b19da50472 100644
--- a/drivers/hwmon/cros_ec_hwmon.c
+++ b/drivers/hwmon/cros_ec_hwmon.c
@@ -579,13 +579,17 @@ static int cros_ec_hwmon_probe(struct platform_device *pdev)
priv->fan_control_supported = cros_ec_hwmon_probe_fan_control_supported(priv->cros_ec);
priv->temp_threshold_supported = is_cros_ec_cmd_available(priv->cros_ec,
EC_CMD_THERMAL_GET_THRESHOLD, 1);
- cros_ec_hwmon_register_fan_cooling_devices(dev, priv);

hwmon_dev = devm_hwmon_device_register_with_info(dev, "cros_ec", priv,
&cros_ec_hwmon_chip_info, NULL);
+ if (IS_ERR(hwmon_dev))
+ return PTR_ERR(hwmon_dev);
+
+ cros_ec_hwmon_register_fan_cooling_devices(dev, priv);
+
platform_set_drvdata(pdev, priv);

- return PTR_ERR_OR_ZERO(hwmon_dev);
+ return 0;
}

static int cros_ec_hwmon_suspend(struct platform_device *pdev, pm_message_t state)

--
2.55.0