From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 B836C2DF6E6 for ; Sun, 19 Apr 2026 18:22:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776622966; cv=none; b=AAb0y69QXH+56Zx38RdxdwW8QtrfV4Id1q51VClkQHr5aSzV2gwH852WqdaJtdbmvQMzRDrOMwSbATSlsFhsKEseJTaJh3FjRONVgrUNRlSlhpchPR9IHDTUHR1ZiTEnyTkoqiPE/k5YH+bMeLIchZPj/wjN669UvP7Fxl5um58= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776622966; c=relaxed/simple; bh=QFEKU97eqvDA0QMBKvkfQSYoQ7Mbh0z7Y4dUY+CpPEU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yb5R1zG+lI4NertpW0U0KM/gyaMbaGHCr9cfjozc2yuFxadu56iVQsYbHLD54ftXZg3SXnBn1ufiprEz9QrKsRV8kY8cDZyRCYnfv/1LWh3s1U86/w0xbAVrnYHcxaYqCBi2SwSLbi+irmHVf2iSBI/1fQlsyLxjE260VaKRhKE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=HY++AqGA; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=PcBZ2F8J; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="HY++AqGA"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="PcBZ2F8J" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63J2sA0B3971063 for ; Sun, 19 Apr 2026 18:22:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=8SJc8Ox6w4Z ygU6cO3C5yCKbel/yP+52HnTiIJQrGqw=; b=HY++AqGAu74IXd8c8x1L+F7ZUqR lSjqC6zchyrO75jh2vj5B0BDFA3hUtW8HeUBr5WYz304QyHcwWy4d0e2C0QbXWsb hZc5qNoJTXpvgjvrAIA7XBiPlpKm2ZSNREJ6jefmfD2CnIXm9ZKjHhAUB7ko2Pzo fJxACJn3JlGs7md2/McoajKWFq6r3HZTS9jB+HvCcOwt8sr0SdTspnSXEncnuG2C HfjgWZltexqh5UreiST4+FSyDloBAtZhTZPCQljgBX6o5r05dGjC4Nxp1whnFs8s z/gLn8qA/tzx/dyAz4uRiiu31feEDXP3uZGUTukZs2Wi7/CVsS4NS9btXGw== Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dm19fu30k-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sun, 19 Apr 2026 18:22:43 +0000 (GMT) Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-50e423a05c8so32063051cf.0 for ; Sun, 19 Apr 2026 11:22:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1776622963; x=1777227763; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8SJc8Ox6w4ZygU6cO3C5yCKbel/yP+52HnTiIJQrGqw=; b=PcBZ2F8JSu++3vfOirU6VjiJJtwQVI+vnh6da3EA+/q+ZpSdAHHZB9PlxQTGJ4uvmD wR1S7bf4Z1+Ldet3DS9F9RNwwSXS8eDj2djKIVXSh209u1LXgCAccmPnw+WFX3WqnS8j EzzWEBy4XW9iSwwQ6ocdC6QkwUT9R8Sc3eMyD/fgOTFcVmTTGnXDELNADBckz0a88yWH fh/nLqFsnCoDAfGztIZ0Jdl1ebPyXtGMPokvH+Wqwy+fhlZsDy4wiQ+ykfgUXCOp0sSJ B71tK673lPfkjXFyptEZtVadRtXxMgJmK4pp1risJ8Iig3sX41SYP7vBCx1zN12SEZQI 5KiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776622963; x=1777227763; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8SJc8Ox6w4ZygU6cO3C5yCKbel/yP+52HnTiIJQrGqw=; b=HYanu4o1Vpq4b9e+7GeaqMFVuzhmipnFuzEPu0UcdYtje0zUbbgKFXsxCzsIR/1xZj I1usRPLqxeJt49warHyevoT9S9byqHfhBpXVTvRyIckRsYP3LdCUfGdRpE/SJz5KTXHn xCywzySDeBYGdmKXh6cQODscNBNJS1dCP9wpKWnjV0dQpobZzEht0mNzFsNbecTXU7Rh C2HXqziRDMZxmB08MU8zsBnsiCF4KbUyXqlPHZONybetO212PBjH8Cw3dqQUc1kOV9Ua OF6rfFLxLT4gYx7vj8WnbmX9zbsX0+blD+HEQzaDCtzdeaNu1SuvOlTTIC6L3Oh615Y8 sYnA== X-Forwarded-Encrypted: i=1; AFNElJ+bPGmStduWrL56wIllO4iv1J5+zPNFv1Mid5KgSECX2F3qwwIt3XZxOcF7JJwRMb3sMrar1b6UqbvfJy4=@vger.kernel.org X-Gm-Message-State: AOJu0YzRyA+NVIPW47OJt1Pxrdaa9NQNvTdvCNrId/srpbrEs7mALzey tKIzoLpWyxdVc+3oUuKzJNmf2OKCw5TTj5VpDn2Yt3F/QOekFaVW4n20i9d7CCU8jmTHEhBYQST sSjL998mLt7iUC/MVHUJBShO3SBHv14Vo9Tl3De7/9ddLWFS+0dss6sABqNrMMl+7pxQ= X-Gm-Gg: AeBDiesaquesB0pmabrrQQwQFV6zvCYWIGJ/tFcu/hcfHCag6uKfthovFmNDGRAW/y9 /FIRJKBYvSMMPh+wQgW81ZxHZv6+zkK2GjPjjVzLpLN8qGsib5yNiEQogTm32zTgSpWB/yrL3ol cbxpt/D20I4n2P1etS6gg+VkZqImoFGJUwy0iGUhMRubtSJQnLF8CL2p22DtmpeIVyD6h08LZIB J80vyCaYVR1FU+aVgZVd/gaqDC17mo8uXV+Od77olEmmnK6q9MvcbgTJL7kguq5o3sxzm+xUXsv Qs0Mq+EtmLEuFIyYohP9OdSM3Jm0zGbQWAvUNfcEY6x1aqmoumpXV2CW9u0pEIQj04t9fYufnug cCANU0Fc2iaH+UwxDgGa2RGw33xEKMGsIzoWYsPlSZpEbREXGkg89wWaYaFKi X-Received: by 2002:ac8:7fcf:0:b0:50e:32cd:52fa with SMTP id d75a77b69052e-50e3661d434mr140438721cf.3.1776622962822; Sun, 19 Apr 2026 11:22:42 -0700 (PDT) X-Received: by 2002:ac8:7fcf:0:b0:50e:32cd:52fa with SMTP id d75a77b69052e-50e3661d434mr140438211cf.3.1776622962349; Sun, 19 Apr 2026 11:22:42 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:ae20:597c:99b8:d161]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4e59f97sm25723070f8f.37.2026.04.19.11.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2026 11:22:41 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org Cc: gaurav.kohli@oss.qualcomm.com, Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lucas Stach , Russell King , Christian Gmeiner , David Airlie , Simona Vetter , Guenter Roeck , Joel Stanley , Andrew Jeffery , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Benson Leung , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Heiko Stuebner , Thierry Reding , Jonathan Hunter , Bjorn Andersson , Konrad Dybcio , Amit Daniel Kachhap , Viresh Kumar , Neil Armstrong , Amit Kucheria , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Daniel Lezcano Subject: [PATCH v1 06/14] thermal/core: Register cooling device non-OF drivers Date: Sun, 19 Apr 2026 20:21:50 +0200 Message-ID: <20260419182203.4083985-7-daniel.lezcano@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260419182203.4083985-1-daniel.lezcano@oss.qualcomm.com> References: <20260419182203.4083985-1-daniel.lezcano@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE5MDE5NyBTYWx0ZWRfX7XWomikxzn2g kK27mMQVNurLcMO3xkQgv6c0MknBn+iUcjhT81FF2C/UFRAnb4RxjsiBoA44ybnDH/bj8igGSaZ GwtiRDUkCP1TB0S3m2ZDGjHobaVEl9fjyXoC4AdgZOv4Sosblr0tU8PzM2T1TcaCpelpBLtdQf5 irNitWYtl0Qx5aD1TFnQIAdLwmA7g0pll0ljHA4Bnx8R32ZuM6XuKPEEmop4on7reH797eRGZfx H94Y8RfSvaEYQobwd1i5vnLSpIcU1Hjku1zz0w04QQZ2pS0J461qqBVX57N6rtI+k9gEKYYPVrp O7YcrSvgwcm8QTp4mdRI2AdNegyyEHcKXcrChnM08Pi0ZElYgC2/bzogfVu+jIkcpIaN4JUyema R0DP5rylytRrp5zaXZEZAmqVWeDPA4n/tjT+jvlqAxsl+UjxnGsCL1iILYGwDMD9inl6d1IxGGh Ym9mQ+Gu2xZFJxGPW6Q== X-Proofpoint-ORIG-GUID: pa2sVTuJysgo9q3JiA43cH7buxeyxvDq X-Proofpoint-GUID: pa2sVTuJysgo9q3JiA43cH7buxeyxvDq X-Authority-Analysis: v=2.4 cv=FMorAeos c=1 sm=1 tr=0 ts=69e51d73 cx=c_pps a=EVbN6Ke/fEF3bsl7X48z0g==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=axTsjYC8yfnw0r5e9iIA:9 a=a_PwQJl-kcHnX1M80qC6:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-19_05,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 priorityscore=1501 phishscore=0 adultscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604070000 definitions=main-2604190197 Provide a non-OF functions to register a cooling device in order to have a clear separation between OF and non-OF code. Drivers not using a devicetree can then migrate to this function. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 44 ++++++++++++++++++++++++++++++++++ include/linux/thermal.h | 13 ++++++++++ 2 files changed, 57 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 2f5d214d51a1..356a49e541fd 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1164,6 +1164,50 @@ thermal_cooling_device_register(const char *type, void *devdata, } EXPORT_SYMBOL_GPL(thermal_cooling_device_register); +static void thermal_cooling_device_release(struct device *dev, void *res) +{ + thermal_cooling_device_unregister(*(struct thermal_cooling_device **)res); +} + +/** + * devm_thermal_cooling_device_register() - register a thermal cooling device + * @dev: a valid struct device pointer of a sensor device. + * @type: the thermal cooling device type. + * @devdata: device private data. + * @ops: standard thermal cooling devices callbacks. + * + * This function will register a cooling device with device tree node reference. + * This interface function adds a new thermal cooling device (fan/processor/...) + * to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself + * to all the thermal zone devices registered at the same time. + * + * Return: a pointer to the created struct thermal_cooling_device or an + * ERR_PTR. Caller must check return value with IS_ERR*() helpers. + */ +struct thermal_cooling_device * +devm_thermal_cooling_device_register(struct device *dev, const char *type, + void *devdata, const struct thermal_cooling_device_ops *ops) +{ + struct thermal_cooling_device **ptr, *tcd; + + ptr = devres_alloc(thermal_cooling_device_release, sizeof(*ptr), + GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + tcd = thermal_cooling_device_register(type, devdata, ops); + if (IS_ERR(tcd)) { + devres_free(ptr); + return tcd; + } + + *ptr = tcd; + devres_add(dev, ptr); + + return tcd; +} +EXPORT_SYMBOL_GPL(devm_thermal_cooling_device_register); + static bool thermal_cooling_device_present(struct thermal_cooling_device *cdev) { struct thermal_cooling_device *pos = NULL; diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 0ddc77aeeca2..d9332b037188 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -260,6 +260,11 @@ devm_thermal_of_cooling_device_register(struct device *dev, struct device_node *np, const char *type, void *devdata, const struct thermal_cooling_device_ops *ops); + +struct thermal_cooling_device * +devm_thermal_cooling_device_register(struct device *dev, const char *type, + void *devdata, const struct thermal_cooling_device_ops *ops); + void thermal_cooling_device_update(struct thermal_cooling_device *); void thermal_cooling_device_unregister(struct thermal_cooling_device *); struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name); @@ -317,6 +322,14 @@ devm_thermal_of_cooling_device_register(struct device *dev, { return ERR_PTR(-ENODEV); } + +struct thermal_cooling_device * +devm_thermal_cooling_device_register(struct device *dev, const char *type, + void *devdata, const struct thermal_cooling_device_ops *ops) +{ + return ERR_PTR(-ENODEV); +} + static inline void thermal_cooling_device_unregister( struct thermal_cooling_device *cdev) { } -- 2.43.0