From nobody Sat Jul 25 23:42:31 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3FE539184C; Sat, 11 Jul 2026 09:59:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783763972; cv=none; b=F76ZEWDYsHM0cxEJGxXByyO2uzXtsj98YB89uJ5NCuamBQfPnqLauywy6lNei047zkrpLFGSltjuTiOLkEE51hvue/gP+JyzweVvefaaTkUwRunF3NANWv47U+nC6sr8rf6SHv9Fc4Szkaj5/v6MRBvq6KkVUjUinfSAaM70gag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783763972; c=relaxed/simple; bh=jthXYdBVWqNR/7CFQ6yzASpbT1+pG2syGHyOYibktD4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FA7WB9c1sj5zDtvllxxvzBFOzn4FGJGCyeOr3nGtvRvpQ/HT3Yu4uEu72E/fiHWmeiS5J4TGyo62KcCNw+B6CzuvRa91kXIIzgyXHAXZ+6Dpd7OVtiaeVwIG7FDxIIH4v/0XyLwxTdBvqpw43DES9XyR7E8qIm7ffK4+095wfBY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=Z1MwexPo; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="Z1MwexPo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1783763962; bh=jthXYdBVWqNR/7CFQ6yzASpbT1+pG2syGHyOYibktD4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Z1MwexPoxOElfkNQmn/RXHR24h0OpqUT35bvLsJbl7wX04XhZg79QvHwuwL81ScBU Jljo7hZWk/6LRAlsgMs7LyASvpDn2yjIjG+RN0rwi5h8mOR3hKZe+/rQcJ0fIcDnEQ 445Ggc1+yQUvGdjx4AdPj4sAgrVzV9FYKfXfYQHk= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 11 Jul 2026 11:59:05 +0200 Subject: [PATCH 1/3] hwmon: (cros_ec) Register the thermal devices after the hwmon ones Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260711-cros_ec-hwmon-locking-v1-1-cb6d0fdbb2d3@weissschuh.net> References: <20260711-cros_ec-hwmon-locking-v1-0-cb6d0fdbb2d3@weissschuh.net> In-Reply-To: <20260711-cros_ec-hwmon-locking-v1-0-cb6d0fdbb2d3@weissschuh.net> To: Guenter Roeck , Benson Leung Cc: Sung-Chi Li , Guenter Roeck , chrome-platform@lists.linux.dev, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1783763961; l=1446; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=jthXYdBVWqNR/7CFQ6yzASpbT1+pG2syGHyOYibktD4=; b=9FPU4EdehkkD/g70WArz0Cgm2TsuEjVr5ZBaiYda19TZp5U7r8ngmTc+jHsIZjzKFkzc+JI0T j/AOObrmRTKDPNbY4ZtdJO49Lgig/k0lBMyFt1uRv62MsiIxqqKDoKD X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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=C3=9Fschuh --- 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 =3D cros_ec_hwmon_probe_fan_control_supported= (priv->cros_ec); priv->temp_threshold_supported =3D is_cros_ec_cmd_available(priv->cros_ec, EC_CMD_THERMAL_GET_THRESHOLD, 1); - cros_ec_hwmon_register_fan_cooling_devices(dev, priv); =20 hwmon_dev =3D 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); =20 - return PTR_ERR_OR_ZERO(hwmon_dev); + return 0; } =20 static int cros_ec_hwmon_suspend(struct platform_device *pdev, pm_message_= t state) --=20 2.55.0 From nobody Sat Jul 25 23:42:31 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3F4F37C922; Sat, 11 Jul 2026 09:59:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783763971; cv=none; b=b99U6U/z2vFmBZWiHV0gvfEKU+E+Dbk9CnnYTL4Tyv7XUoywTtXVyC3h/Awk4giQUfT+ZSeEcRI3lKbACMyiqPDISp9S9LU/MFVgLFHhPlGCZFJmmWukrnerZ0eHC5U8B3bUrUjNHjyeGsO12RNlbHy2B7vDZGO4iPMONmUjtUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783763971; c=relaxed/simple; bh=dMQ1lUCssYuYB0g5dtX2VVlawMxWhQ8Jiw8sj/VeuN8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FdTErXUY5bO4eplhcKbZ8EaS1bD30s5WCN5IY20PlimQtW33ir/rlgURDRmUMtf8DZQIL0c5kHxGxzzUbXCAmkmRM2t6UvFI8Pt8Ox4O+9fBlX0pc0JOTBRMke3DzO2GdiOjWDOJJ0KQTGFySdaNNd8UAU7gyu68S4zOnnfxpbU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=JEtPA5Tp; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="JEtPA5Tp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1783763961; bh=dMQ1lUCssYuYB0g5dtX2VVlawMxWhQ8Jiw8sj/VeuN8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=JEtPA5Tp9CihFXAByX+ln8wFQTirG8N1pXheW6PfU4tA5Ak+002D3b0oL/as9zKma ke1axLvadIRM9n26XdoPh19lFiVuejIC8qHFI77P6+b4wDJmK9BRhZPWEVEHJs6J1V x4p8j18QsB0W3slMJgDnBrcyybtAaDQ8/Zcsk9P8= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 11 Jul 2026 11:59:06 +0200 Subject: [PATCH 2/3] hwmon: (cros_ec) Store the hwmon device in cros_ec_hwmon_priv Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260711-cros_ec-hwmon-locking-v1-2-cb6d0fdbb2d3@weissschuh.net> References: <20260711-cros_ec-hwmon-locking-v1-0-cb6d0fdbb2d3@weissschuh.net> In-Reply-To: <20260711-cros_ec-hwmon-locking-v1-0-cb6d0fdbb2d3@weissschuh.net> To: Guenter Roeck , Benson Leung Cc: Sung-Chi Li , Guenter Roeck , chrome-platform@lists.linux.dev, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1783763961; l=1686; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=dMQ1lUCssYuYB0g5dtX2VVlawMxWhQ8Jiw8sj/VeuN8=; b=/6S1kv5sEnl2udIrX3KqyZmocpWG+79Lb1xc9Bca4NciQteyqGy4JWSQAqVwjyxZwG6rllfji Ic4XYhOIDTnA1eAga3YARj5sJzswokYkba0p2c1LJbkazZUlLzwn3vU X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The upcoming locking scheme for thermal devices will require access to the hwmon device. Add it do the priv struct. Signed-off-by: Thomas Wei=C3=9Fschuh --- drivers/hwmon/cros_ec_hwmon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c index f9b19da50472..fb5daa9f80d1 100644 --- a/drivers/hwmon/cros_ec_hwmon.c +++ b/drivers/hwmon/cros_ec_hwmon.c @@ -25,6 +25,7 @@ =20 struct cros_ec_hwmon_priv { struct cros_ec_device *cros_ec; + struct device *hwmon_dev; const char *temp_sensor_names[EC_TEMP_SENSOR_ENTRIES + EC_TEMP_SENSOR_B_E= NTRIES]; u8 usable_fans; bool fan_control_supported; @@ -556,7 +557,6 @@ static int cros_ec_hwmon_probe(struct platform_device *= pdev) struct cros_ec_dev *ec_dev =3D dev_get_drvdata(dev->parent); struct cros_ec_device *cros_ec =3D ec_dev->ec_dev; struct cros_ec_hwmon_priv *priv; - struct device *hwmon_dev; u8 thermal_version; int ret; =20 @@ -580,10 +580,10 @@ static int cros_ec_hwmon_probe(struct platform_device= *pdev) priv->temp_threshold_supported =3D is_cros_ec_cmd_available(priv->cros_ec, EC_CMD_THERMAL_GET_THRESHOLD, 1); =20 - hwmon_dev =3D 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); + priv->hwmon_dev =3D devm_hwmon_device_register_with_info(dev, "cros_ec", = priv, + &cros_ec_hwmon_chip_info, NULL); + if (IS_ERR(priv->hwmon_dev)) + return PTR_ERR(priv->hwmon_dev); =20 cros_ec_hwmon_register_fan_cooling_devices(dev, priv); =20 --=20 2.55.0 From nobody Sat Jul 25 23:42:31 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAFEB3932DC; Sat, 11 Jul 2026 09:59:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783763972; cv=none; b=dFsLJCTIfAS79ZcgJw7LrywFsegLfYu/RxE2Sofsip6icJvN1663m5zklPOQpYl6DArysm0Av1HhFCWBwLjvAhsEQ0XVOAhkSp4+vF9oPa8O2lfqfRFSBGuRR31qbiZ+WmUZbea9rDdGEnDmvdJjzDUmr8FJiRWpvJJD3YzNN54= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783763972; c=relaxed/simple; bh=1glqh3NKjLr4HSQMMiqeuVdFfYOD/vKOcJ+KkT72tPo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RJ09JvMbkgJ38aBA0QZ/IH2CwV2UbEG278K2xcODL70JCXn4df2wa17UCy6opoSfTzWQ9ACnBSgSSuInYlcr9byooZFYVnRYcZBhYZ1Ii9y6AMstVvKPXCWh9/w2OJsUbBoLg7b6EMivewKGMlItmke4XYaOBDqn7esBvE0qu6Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=RFQYiVZq; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="RFQYiVZq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1783763961; bh=1glqh3NKjLr4HSQMMiqeuVdFfYOD/vKOcJ+KkT72tPo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RFQYiVZqQVDvOswygHZxE5vjeTAAgnzYxjJ4IcRvawLai+Bw1OCv0fNAkuUkJRDam pTpfSvg7h1BfTRNsWIKog/T48dP1F36745BsEZIfwuZZbUss5v73lxF13Ty80kLXp6 zw1z9W/63bziQuHWbSoTuiOy39tXpYeKQStUK9so= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 11 Jul 2026 11:59:07 +0200 Subject: [PATCH 3/3] hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260711-cros_ec-hwmon-locking-v1-3-cb6d0fdbb2d3@weissschuh.net> References: <20260711-cros_ec-hwmon-locking-v1-0-cb6d0fdbb2d3@weissschuh.net> In-Reply-To: <20260711-cros_ec-hwmon-locking-v1-0-cb6d0fdbb2d3@weissschuh.net> To: Guenter Roeck , Benson Leung Cc: Sung-Chi Li , Guenter Roeck , chrome-platform@lists.linux.dev, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1783763961; l=1444; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=1glqh3NKjLr4HSQMMiqeuVdFfYOD/vKOcJ+KkT72tPo=; b=oiodRxfkJhMc/PP1eC1YX7FMjKP8QE5nFYj0zvQA42EzAvnPrCe1MUPI8K2AD1X4r+T71hRPM zCpzjI/SQ0gAJAaoQTTWjZbzS6zL0eRNAnS66CvLmfoTW1RzbZq4AaI X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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: 5798b62867b4 ("hwmon: (cros_ec) register fans into thermal framework= cooling devices") Signed-off-by: Thomas Wei=C3=9Fschuh --- drivers/hwmon/cros_ec_hwmon.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c index fb5daa9f80d1..76d83e1c68cf 100644 --- a/drivers/hwmon/cros_ec_hwmon.c +++ b/drivers/hwmon/cros_ec_hwmon.c @@ -5,6 +5,7 @@ * Copyright (C) 2024 Thomas Wei=C3=9Fschuh */ =20 +#include #include #include #include @@ -411,6 +412,8 @@ static int cros_ec_hwmon_cooling_get_cur_state(struct t= hermal_cooling_device *cd u8 read_val; int ret; =20 + guard(hwmon_lock)(priv->hwmon_priv->hwmon_dev); + ret =3D cros_ec_hwmon_read_pwm_value(priv->hwmon_priv->cros_ec, priv->ind= ex, &read_val); if (ret) return ret; @@ -424,6 +427,8 @@ static int cros_ec_hwmon_cooling_set_cur_state(struct t= hermal_cooling_device *cd { const struct cros_ec_hwmon_cooling_priv *priv =3D cdev->devdata; =20 + guard(hwmon_lock)(priv->hwmon_priv->hwmon_dev); + return cros_ec_hwmon_write_pwm_input(priv->hwmon_priv->cros_ec, priv->ind= ex, val); } =20 --=20 2.55.0