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 21B993FFAC0 for ; Wed, 29 Apr 2026 16:14: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=1777479289; cv=none; b=YoOguSYe71eRE+z0X4tkUYyE9ggmuoFcnmS6u1s5IqbRRkrdA61jtTN7LE4DO1kyBwwIzkUvp7E1pXagOdrgPHAuuGn3VGFXKzd80RHc+nMOzLz956f7IS44lpq5uhBKq11xyp5UFep885S9oXcYB6F6vzlx9Mc/I3oy70WIuKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777479289; c=relaxed/simple; bh=GMW15JQKvh68RISGmBmQhQtahGk5c0uHc5SrSpqibxk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i1TOT+bKOmE1bQ++FOY9uZuz9JZk9+LFDdyGRx+IH4Nb8wn2kjaeUd6iaOUEMNs3O/6RgdGb0ipr7kLNJf3s2hD7CVPN+j+KqOee3yYA3pVOSexIUBDggHKlDE2WcBJu5s9ZFeX50QG1p1L59O/P7SpvKFXOT/1AJZUGhawajEQ= 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=Hu62zZRs; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=XhSfUpDT; 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="Hu62zZRs"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="XhSfUpDT" Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63TFTjnL1641981 for ; Wed, 29 Apr 2026 16:14:43 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=knJvi0AtUY/ Bcp4iZX+go0eWYlAuBgaLg+IAzj9hl5U=; b=Hu62zZRsSuI5mdtp2s46mby9gS2 KSAkAKoaRT+bhvxTxekRT4klxPG4w4RTrvp78ZNOT2uir2IodOtTKpcZgK/zAtwJ +/IKmMvAnfrwBEu/GQKqVbA9zrz/iRvSjPGEB3dHGv7fr6dWMm/NG5E1uT1oOisc a3nQYQCoQBiRhvhkJk8b7zUi0/eVKw/LVmAWrZ6Yp2ln3RFtGmyFRh1OTLcjW6d6 EsFlMSuwrC8XA2Q9MOAKR29nyw8LP7AOMOnVQ56ZiiSAzkRhm+NI8RRLqbyyPK2S qYXeFo/MkL5o4CswHlOZEmonv/x1nKIGIS3/zrwHV4B/wzs7xvdAyzj41NQ== Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ducj82dca-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 29 Apr 2026 16:14:43 +0000 (GMT) Received: by mail-vk1-f198.google.com with SMTP id 71dfb90a1353d-56eecfd79e7so25414081e0c.1 for ; Wed, 29 Apr 2026 09:14:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777479283; x=1778084083; 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=knJvi0AtUY/Bcp4iZX+go0eWYlAuBgaLg+IAzj9hl5U=; b=XhSfUpDThCaO7LgdkyZ+juE15I+ZXKSmabJM9FUOw6ELfC+Zg9NeVZJjDPEOydeaxV x12H80crWANaD4bJgxSGnGbX6NfyZStzy9pfbysiOj71qaUvmIIo1IBl8s43s04JwTym phDZ9U41uSPxdYttxfrKR23NQ90Rtu/AFc+I11GeoiF8pAR0cimuB5GESGOVnn8w9dOr ZuGrqmHHiM3KrYCyB1ceBZkn0XjvpSsjoqMJ0rUUEipDFLinuIugCMGp7nYF3PmeqRbo IJxnuOKMZCvn1b0U+ze0LG+p3Dc0GeopKTBeKfxDI+1qTribe/x0ujx8mr8E7kGE9Xwi WZ5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777479283; x=1778084083; 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=knJvi0AtUY/Bcp4iZX+go0eWYlAuBgaLg+IAzj9hl5U=; b=QcjwpTpiuZwjsMUnZ8fo6EzKrKzdj7ZTPt61/v4OVkfuojZ3+1OtIIssSnKTgVL4pX ttgq5YmO5n5Lt9+H/5zg19oNfS+FLBju293y4pFOdvkoeTqN9tprH+ie8w4ILOFfJoib dZcVfKLIZ568YMpA+Q0+utFoAg9aIBPWgxy9ZRqo6zNSWe7oRdpZUYBzf8S8td934hby 6AO00swAlhA/DPQKoW08CGSR8PhniNQMb5RMwGilCH7zcfR06ZZq/QbAnots7Bu/lRMa s4gJll+d78InYyx3BhfqR5nEzyeXgnVZby1LS6iYsEIpuNdF3uVO32y+x/JB2Mhpe1qh lxHQ== X-Forwarded-Encrypted: i=1; AFNElJ/w30LrgQIjh9l+5J3rbU2/n1HH4GX/ig3FD06tZIsORfeuPPaJMkLX56mwYE9uAgiOYWcUf60tM+ysmTs=@vger.kernel.org X-Gm-Message-State: AOJu0YylomHQpyCYLXlQmxnZeEMzfha5nLo87DDtQmhJw80lii1Dg8X/ tBzM7i1o9WDFgLzJ1yk1eauebLAzg7Rr1KWeaqEKKiWP5dc7TEdLNKcx4ZzLsiQGLx54jJsaRzM 3t65nZVgm3yLgqIm6hd/miw/7RcQtpCPpGQTKsZT29O40sa1QCJ0eTae5JyZ+LTEHV/M= X-Gm-Gg: AeBDiesnveSLYXlkdEdxezS0S8ZZaEMResdit/k5CuoBhZmmh18vN08/t42qXbqJJfn 4TuZM/+2439Iny4zXz4j/a/t1+rMeT6nZqvFiNnniMpLF+S6e1DZBf6Wn2dhWJehsVAFAO4b6g9 xGXFKaC82EFOWj5n31lYXDpEcIIRFwipMHfcp394W5fmdiLYKHiVSf1/S5IJixnt0JB+LBL24ar Mf1MpVZsiR7CQ4nc5wnS+WiOeyJPMJCTmoD4xkK4ZhfHmYJ0s0kBiA+8qnm3/hoUFs2TzV+7upD 7xM94mPquU+/618+YTDnHvVtQLM1HZPxS8wPbPwlKmdftrkTEr3qROQfEkBFYG22nogMmXwx5Rl h/K26M8pKAjDax7tl9wypHovbOzkO0FfvepVqu2+aW2EusNBTotz1EtLSs9JO X-Received: by 2002:a05:6122:179b:b0:56a:ef51:4cae with SMTP id 71dfb90a1353d-573b348ac72mr2720494e0c.4.1777479282905; Wed, 29 Apr 2026 09:14:42 -0700 (PDT) X-Received: by 2002:a05:6122:179b:b0:56a:ef51:4cae with SMTP id 71dfb90a1353d-573b348ac72mr2720438e0c.4.1777479282359; Wed, 29 Apr 2026 09:14:42 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:ae20:597c:99b8:d161]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a81ed659dsm2438525e9.2.2026.04.29.09.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2026 09:14:41 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@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 Subject: [PATCH v3 02/11] thermal/core: Add a non-OF registering function Date: Wed, 29 Apr 2026 18:14:15 +0200 Message-ID: <20260429161430.3802970-3-daniel.lezcano@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429161430.3802970-1-daniel.lezcano@oss.qualcomm.com> References: <20260429161430.3802970-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-ORIG-GUID: e_p2vi7UHcawZZRIKFoqLVMAxGuS6zDe X-Authority-Analysis: v=2.4 cv=RI6D2Yi+ c=1 sm=1 tr=0 ts=69f22e73 cx=c_pps a=1Os3MKEOqt8YzSjcPV0cFA==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=AEQiIq00j7-0rvc0-mQA:9 a=hhpmQAJR8DioWGSBphRh:22 X-Proofpoint-GUID: e_p2vi7UHcawZZRIKFoqLVMAxGuS6zDe X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI5MDE2MiBTYWx0ZWRfX86YGbN0SPjFU xZ79wXR3eWBt1kISJhoZ/89zYcThKRTDQDvHKQRX/AzbUsKboqHMfe+jZj62OpI0VF3uypRVaOv d1689a4kL3VtxU72K/LIQ6BFq0311dx3o20PvI534v2R4eKD2CF4mLb9adX/49vcKRfHvS0MlJb sWx48U+SdCOP3tQuJm6q1ovGshBbnZ41zCPCn6MCDJFVyR39gJFOwIMyAMhEC5+r+oMneO07Et6 EPWABJD169yB0jfWAqdEaGm1rESLY5YivRm4xNMqdwsuHqXKby05/JyLbsQ07I/PKPwiVBco8Zo aJqC/d5u1vY4ETXroMXz6dJgmu0I88OcfQ1wnIC8bpbP3CyYBUgQBBaEBMeBkUdS2XJOzYThjVk pqdCaqga18SjrDcFN3hMyc7+WOA5fCRpHDcZdMXgmsqRjHuntJ7kJxSFQzKbK2bQDvSmX/tjFHz 4y5SoEtNToDc1F/U82g== 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-29_01,2026-04-28_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604290162 In order to propose an alternative to non OF code registering a cooling device, provide functions which are not for OF code. That sets the scene for OF and non-OF code split. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 35 ++++++++++++++++++++++++++++++++++ include/linux/thermal.h | 16 ++++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 664a4cc95199..5c954bcae4a4 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1194,6 +1194,41 @@ static void thermal_cooling_device_release(void *data) thermal_cooling_device_unregister(cdev); } +/** + * 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 *cdev; + int ret; + + cdev = __thermal_cooling_device_register(NULL, type, devdata, ops); + if (IS_ERR(cdev)) + return cdev; + + ret = devm_add_action_or_reset(dev, thermal_cooling_device_release, cdev); + if (ret) + return ERR_PTR(ret); + + return cdev; +} +EXPORT_SYMBOL_GPL(devm_thermal_cooling_device_register); + /** * devm_thermal_of_cooling_device_register() - register an OF thermal cooling * device diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 0ddc77aeeca2..50b43e328ab9 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -253,8 +253,12 @@ void thermal_zone_device_update(struct thermal_zone_device *, struct thermal_cooling_device *thermal_cooling_device_register(const char *, void *, const struct thermal_cooling_device_ops *); struct thermal_cooling_device * -thermal_of_cooling_device_register(struct device_node *np, const char *, void *, - const struct thermal_cooling_device_ops *); +devm_thermal_cooling_device_register(struct device *dev, const char *type, + void *devdata, const struct thermal_cooling_device_ops *ops); + +struct thermal_cooling_device * +thermal_of_cooling_device_register(struct device_node *np, const char *type, + void *devdata, const struct thermal_cooling_device_ops *ops); struct thermal_cooling_device * devm_thermal_of_cooling_device_register(struct device *dev, struct device_node *np, @@ -304,6 +308,14 @@ static inline struct thermal_cooling_device * thermal_cooling_device_register(const char *type, void *devdata, const struct thermal_cooling_device_ops *ops) { return ERR_PTR(-ENODEV); } + +static inline 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 struct thermal_cooling_device * thermal_of_cooling_device_register(struct device_node *np, const char *type, void *devdata, -- 2.43.0