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 90ECE3815E8 for ; Wed, 29 Apr 2026 16:15:00 +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=1777479305; cv=none; b=JqAZTLvygN6rw96dGIIhMW7S4lmJsoVNHNMNuSWvbso+PU7/HP5ZVEGu1mex3KwDrIQQ0Pd5xMHEZ24sFHruirA6qLkkABrc4BIdPNP6/Wn9WJDsv1YF3PECdKH6WSAYWnEXciTXgpoG5pj/iajh8X9XSYVTvmjZzWaS8/ljVJw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777479305; c=relaxed/simple; bh=W/DA7KZaSHERCdjZ7882n6PYIAmCOm8xM23/+2wKGcM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=joN70/P0E3Pow9FDOMVQ+DmVdscLG58qhl9D7dIb4Lk4qkRx7scGkM/MBIj7Grs4GliAnR0pmyOQQkCAo50WJYb/NMAN+EGBjlNMCBkkGlZWvxZrkBuEbZA5r8u3jd47qt+O8ruKwTsDLrgnK0N+LvQiKW+WOGESlD6m79Ge87c= 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=foDga1mj; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Gm1v7X5b; 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="foDga1mj"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Gm1v7X5b" 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 63TFXCni2094157 for ; Wed, 29 Apr 2026 16:14:58 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=PdrQctDCz1u Wf9yrg/YenTJPvqTEqEJU5WiItR+z2bc=; b=foDga1mjOzOQkMlobyazC6MANnO Pay10GstU7ntOvRj0gCfl0TQ4ligxn7IYEVZftyfFGH+oDcSu5RgkJPd3oct3DvF ZYWlOARKL3Vfc4dBNjK+/j7xLVKhQmyBw1ZZyJIpxGU0aaOH7rz+HDydlVzRp/2U 7yr3ZNhQT0XcS/LKe5NsO9XhePt/9bXgSSEpWB8VxXV0AWT/tPzu45mqlXPatrv0 PlitsHUbfUH40rO3D2SBuGczj+Tv33cUd/7NhP1bTmmN8sjZX8qFDBVJlOakFP5d UVvU+/xgJPb038GdVTooJZN02BciqBHjAgzNIFMOiztwcVjoX+wutjGarQQ== Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dudh3t66e-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 29 Apr 2026 16:14:58 +0000 (GMT) Received: by mail-vk1-f199.google.com with SMTP id 71dfb90a1353d-56d9f191b6eso21902944e0c.2 for ; Wed, 29 Apr 2026 09:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777479298; x=1778084098; 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=PdrQctDCz1uWf9yrg/YenTJPvqTEqEJU5WiItR+z2bc=; b=Gm1v7X5b+I5ZQ8tgaMqtOivIilIwFcrBn296LYLvXnh2Rgw/NQy2tRd0XVywxdAC1e gm3ynmL2Aw9Hnfsg1svQD6JTmigB0vCxjtOcYWIG5VHKoe6Ph/jDhQfpHAefEavcsORc FX+y0OozZ+MxtOnPvN0weRcK7Nz4RBYKqn9zJu/SZXFgUopAAeuBj4ozB0EUU4RotrbV T/Y9VK89l7Gs86kvYz7c694d5GJjifFk4X9zKmjO2Z6iIc0kl7iX0RN6efQLZXu0Zmqk h+eKAd5xNs295z6K43CbWG2PvUyEMdPB2FbO2z9f7hykYaafA+B6doQt0dFYtLyTvZox lvTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777479298; x=1778084098; 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=PdrQctDCz1uWf9yrg/YenTJPvqTEqEJU5WiItR+z2bc=; b=Idp/M1sI7WrUSzjbZCUoHHVRlV8HF2/mDAiqM4RYtnAUXW+GyFTtUYQhR9JceyTp6b yHz4vcSEJ6NxVKU3KRrE2FP30qonILy4B+EbDElCeZ+LRhMGDH84h3nmDLnULUREUqRy BFT0G4bpxKclNafuwgPyCcJhtf4UeIZ7TfdqjvNMhZ8ScRJ8RfxTFC4iJYQ6XYsAjp8i fKUuKbfAUv4O4hnO04fAxaN+gliTdhZis+4sXingvf0AA+UKQN4kY/Pahrgigec3PH/P WKMpRgsCTG0/+UlpdWv379BWaekUoIcjsr0xx4HXS6+i/AKn1/gdnxGqNPiMY2RxHsMb znqg== X-Forwarded-Encrypted: i=1; AFNElJ+mlKdE/pQg9a12IoXZA2jO/FDZmfY/+Ybs+mrSoksfFFYq+wgQePptIXgHJtH5RrFsHWu4fXWB5bUeRkE=@vger.kernel.org X-Gm-Message-State: AOJu0YwhSnxSSzw+hUEyUSUljO4JnsHQU2Tgxv+MPgaKfnrpIwqEUvzR qfo5FySRDCzlbMnosvJN4Agc+8mHa/OODigVHIi0m/g1FsiiQ9y7cQwYJ6GK7348/f8vItEPnxA DP34umH9T+rjJ1jMesvRz8UDOGL1e4mScJeLb65iMnW/I55jdPPBiTLUp0PsFjhlyvaU= X-Gm-Gg: AeBDieuGcRNZj74DebjpHy9snbLnGHIQUQJcBixmROrBGN64osDHweszSEmNy/iasXA HuoO1h1zPGLl3ykC5nkn2g/nFYkGmwTz6t3Yscr8NdlQHHHG0jaYWdPxm8wuhLKfb+5piUG7bXB FoYnshCDJ5zSz21QPyYOc1Nr/C5vMzRvUVYdPF0UHrM5pVI8nsZTz47tOx0kQHMNPM+0JQEldC6 efGsYUV2lClvNJP1qd52dHp14qATLbwCGRoLw+9dI1fKzpy2jnZai5OEhLUGkyDQFNE2CUpRq9m BYj3piYj+e1LF9u3FSqXsNSJJ10r8tU2pxkCA7cBhD3A25PlVG1V1MLM/a8283A/irLA+zUdCao WVn7mX4Dg4L/s65gKGbGAXhgG1ZQMIw/mqDqn9aXIGN05kCI0wn2CmaHy2XoG X-Received: by 2002:a05:6122:e202:b0:56f:317a:65d9 with SMTP id 71dfb90a1353d-573b34b118cmr2667143e0c.1.1777479297614; Wed, 29 Apr 2026 09:14:57 -0700 (PDT) X-Received: by 2002:a05:6122:e202:b0:56f:317a:65d9 with SMTP id 71dfb90a1353d-573b34b118cmr2667099e0c.1.1777479297210; Wed, 29 Apr 2026 09:14:57 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2026 09:14:56 -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 09/11] thermal/of: Pass the of_index and add a function to register with an index Date: Wed, 29 Apr 2026 18:14:22 +0200 Message-ID: <20260429161430.3802970-10-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-GUID: Vp0WYd0fwaS09HZq7d-5QERCUkIKDxAc X-Authority-Analysis: v=2.4 cv=A4dc+aWG c=1 sm=1 tr=0 ts=69f22e82 cx=c_pps a=+D9SDfe9YZWTjADjLiQY5g==:117 a=V4iKOSeYOELjiAWC:21 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=KHKEB8RYcew9Qe18FDUA:9 a=vmgOmaN-Xu0dpDh8OwbV:22 X-Proofpoint-ORIG-GUID: Vp0WYd0fwaS09HZq7d-5QERCUkIKDxAc X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI5MDE2MiBTYWx0ZWRfXw7O9Uyw6uM22 8IVuWZteWpLNq5Nm5oHZal3W4Qa1z5+fXuEt+7rWztPWffGKjBjw9mI5oO9udd5DhEl4XZDFr5p nBKB7kFLzlC8aueLY1XjEnFBewhJr8FVCxzh0EjCui0QSjUTYEIVe9gtMmLRSgLihjg/+FFfpOP g/vgs/RmoJGrblvHZN3GoAsNThPf9ME38npLASAqrsYfBcCyndbhu/9pHjJyOg9EpKRMmc/Oy1q 1IfKKbRkRFWdY5XShJEG1st8eXhIw3jjln+yIL4TDWIqJmRrTd4N8218bHcMqb9yUbxesMWWsB4 ME2P0Pw+r672DXnUHWIPFd/psHUZe/dEocD4TaMxVxX/6qq0pqpv0XRAyTkL/5Q7DqRNrtI5Hzf W7CPXFZtHmhtkKmcN4wX+GrqWBvdjHR5Q5YIzYAUeJXl/Hk7PtQ+kmbYXG+AXEPwVVYvwLEuRFo 6GEWuSUP0YZDdUEgcPw== 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 clxscore=1015 spamscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 bulkscore=0 impostorscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604290162 Introduce a new function devm_thermal_of_cooling_device_register() which will register a cooling device and its id. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 58 ++++++++++++++++++++++++++++-------- include/linux/thermal.h | 13 ++++++++ 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index b38623f6b89f..c9190a03993f 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -567,6 +567,51 @@ static void thermal_of_cooling_device_release(void *data) thermal_cooling_device_unregister(cdev); } +static struct thermal_cooling_device * +__devm_thermal_of_cooling_device_register(struct device *dev, struct device_node *np, + int of_index, const char *type, void *devdata, + const struct thermal_cooling_device_ops *ops) +{ + struct thermal_cooling_device *cdev; + int ret; + + cdev = thermal_of_cooling_device_register(np, of_index, type, devdata, ops); + if (IS_ERR(cdev)) + return cdev; + + ret = devm_add_action_or_reset(dev, thermal_of_cooling_device_release, cdev); + if (ret) + return ERR_PTR(ret); + + return cdev; +} + +/** + * devm_thermal_of_cooling_device_register() - register an OF thermal cooling device + * @dev: a valid struct device pointer of a sensor device. + * @of_index: a cooling device index in the cooling controller + * @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_of_cooling_device_register(struct device *dev, int of_index, + const char *type, void *devdata, + const struct thermal_cooling_device_ops *ops) +{ + return __devm_thermal_of_cooling_device_register(dev, dev->of_node, of_index, + type, devdata, ops); +} +EXPORT_SYMBOL_GPL(devm_thermal_of_cooling_device_register); + /** * devm_thermal_of_child_cooling_device_register() - register an OF thermal cooling * device @@ -593,17 +638,6 @@ devm_thermal_of_child_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_of_cooling_device_register(np, 0, type, devdata, ops); - if (IS_ERR(cdev)) - return cdev; - - ret = devm_add_action_or_reset(dev, thermal_of_cooling_device_release, cdev); - if (ret) - return ERR_PTR(ret); - - return cdev; + return __devm_thermal_of_cooling_device_register(dev, np, 0, type, devdata, ops); } EXPORT_SYMBOL_GPL(devm_thermal_of_child_cooling_device_register); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 26e33c0236c4..3b21b47de7c9 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -206,6 +206,11 @@ thermal_of_cooling_device_register(struct device_node *np, int of_index, const char *type, void *data, const struct thermal_cooling_device_ops *ops); +struct thermal_cooling_device * +devm_thermal_of_cooling_device_register(struct device *dev, int of_index, + const char *type, void *devdata, + const struct thermal_cooling_device_ops *ops); + struct thermal_cooling_device * devm_thermal_of_child_cooling_device_register(struct device *dev, struct device_node *np, @@ -233,6 +238,14 @@ thermal_of_cooling_device_register(struct device_node *np, int of_index, return ERR_PTR(-ENODEV); } +static inline struct thermal_cooling_device * +devm_thermal_of_cooling_device_register(struct device *dev, int of_index, + const char *type, void *devdata, + const struct thermal_cooling_device_ops *ops) +{ + return ERR_PTR(-ENODEV); +} + static inline struct thermal_cooling_device * devm_thermal_of_child_cooling_device_register(struct device *dev, struct device_node *np, -- 2.43.0