From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 48C0F34FF78 for ; Fri, 8 May 2026 18:05:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778263521; cv=none; b=qU/UdzKC7umdWJtXiNrOauNwZgMYADwk4QjAYT4u9tkpk+76wEJ19rl6w/70RBppIlhCDiZW8nhhYy64xWUCKnA+jvthpch6ccQeH7x9Y7uIahgAnfx9F1NrGzlsj6cEoJ7Mmu8hW1OZbsOfioX6pZ3qXMeZ1wFbpAja+eLh30g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778263521; c=relaxed/simple; bh=zrGzrYkPdY7YMJuo7N4SHYemZtOQAa2dtQkSWaMsWQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pMR/5SGbLPSlO1CEhtutPsn12Ug+vjs6OMXTN4A2+FxybzdxVGJ2y6CnSaKSeIXOrzfEJe03q+oeYCblGKXp3So5Rf0BojinqAHAa/0rqV94wJwpL3XExx6GlGQb1AXK4udFi7DDmKQQiRArGXMWgdZZOGkluD8qjlj/kyL4eaw= 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=TSwM5HUP; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=dhBsWCTN; arc=none smtp.client-ip=205.220.168.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="TSwM5HUP"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="dhBsWCTN" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 648G4BwH1093603 for ; Fri, 8 May 2026 18:05:19 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=1hHCHNh9vUV dYOKHBom2l0BFmQ2i374kNIpIcv8mpZU=; b=TSwM5HUPDYMwjBpyM7wXFsUvSoI 0biTfbnRW11KIJfWYRXVvpHyzso9MhJxEo3DE0zC0PGsM6NgiA99XnTUT52S3MRg ugdLDjgh5Zdc7TDMU/0Pdmd7aGRy+of/wfx/ZmoJ9s+9R+h6rnafQPbLa1loW689 GuJ39xfVxDfLBW99TN5BsCcjguMJEUeC2fBvKpV4SlNU08wx1l3p5qm9jHQdwjWw iaaIKzLuj8fmIRVT1ProrxZJu+dLVolqYuIPwavlEvkAa/5s2ZcUoqC8jSVR5bUD e/YvRkNHjlakoevUUMqH67XWzjV1jFE71o9vFot5i7pxMmC2kpTOPldXyPw== Received: from mail-vs1-f71.google.com (mail-vs1-f71.google.com [209.85.217.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e1k1d0evx-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 08 May 2026 18:05:19 +0000 (GMT) Received: by mail-vs1-f71.google.com with SMTP id ada2fe7eead31-611af0d600bso1564568137.2 for ; Fri, 08 May 2026 11:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1778263518; x=1778868318; 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=1hHCHNh9vUVdYOKHBom2l0BFmQ2i374kNIpIcv8mpZU=; b=dhBsWCTN4VUJ4jkvIflF3L5F088NAKu0uBiFAcaVWmqogAiXMdJIumDGjzwbo4k5ud mU9+ztXEkJE8ADO2dcfRpe0I3PrefW2G6KjeOGtbMys32SGzbmi1gcDt2SOzKoragF1C cb80H0T6pKmEs1Vj2YVLSIF0ky0HLMNvYJ6BwQ0mdvcIhpKU4x0JocIoAmvDMkFWoW1K KwDD5R5CXvQSbIxPfFGJTY/Kz1tiU+t49gCn9RIPQq69bu4SzqmQ5w5SbmpZm9BWKkfo XzZZXbMk4gB+B71QQiFzd4mDvofeVzJN6TBLUyWE7rTQyvl/NPy3bsJpZA0soB20zasL 4LNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778263518; x=1778868318; 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=1hHCHNh9vUVdYOKHBom2l0BFmQ2i374kNIpIcv8mpZU=; b=mxUQbR6cjjH41reYUXGWCtgN2vI+emFIe7pb8f8qpOmDJA3ycCQeNzhGbaXJMK+aJ/ 3du7Qen6gnDvI6MKev4BzW2MPK8rdDwp+5AFy2wf41ktK0Ix2yGIKrwfWOaOG1+RsmM0 2wm/kPz2BLtpZq6JNO5tWBwLzJhixkvt8qmfPspIngvlddUBfyB8YiHJiLCYhB9LDK9b e0C+wfWFbm45Fc04xY9yvrQAankVTqboPYvLAcuK+sdpBbdmS4DJ5uFmKW1J9DRAc6WN rHvORKmoAnJGTVYFBy32oYi+arCehjvG7BC9qi4qzpzboByvzZ04KUWAFUAmTOPXM5Cu suCA== X-Forwarded-Encrypted: i=1; AFNElJ/JgZYpAX8/R3k829JXyV5mvwuUFgr6XhJLzJLXpKknVyLcvgziuNyHMyN1l8oBlEJT+LUtP5+Yt/pybOo=@vger.kernel.org X-Gm-Message-State: AOJu0Yys0dFZxP3FQ7+HtzK+mRmriazr6FvYtPGBnwk3wmIe8meMDY8t y1+iu33peqTeApFlU8nnyMq9BZA90P2ZO6/5foSemnKIdH/eApEleCzKra288ORd0SXLbRnG5jq fWMwi3F6dYI7ebkNEGdrpgBpaB9yqg4Cc3JHwsHxwchABXg6PWv8H4l2MCqQuI/tUU+I= X-Gm-Gg: Acq92OGQlKo+xg7ovgPHvdQYd/PViVv0hLbJ/CRJanRLAf2eO1NS+xJBb9rAZQ/fK5f g3FlnH1OAgqjZuR859h6nojsqUSN/H8DMNuX65RRUrrEeNwKcFmUSthzMWHua56NwQq9ZaNeBV4 gm2Lf4EDvY8cSHzS9bdf2W46SoGAbDe8ZDjaZqvrrYuZyD9G8LvSKffFYbEmKJc3BE2lvJee5fT rgxGZmK3Sc6Psd1lW2BU+1p55zVVG3CSZ2GgFGsgoZ90/b6bkwJxSZtQ1MtOug0NCqUXFGqM6k2 O6JEmDfWBZ993FxITKfMBf8/lIeyvGFDfLUhvToPazYGS444vGgnyjoiUFAi+UtH3aYtctGA5P+ 9dUYpsQbkluCsI54Cfh2T/LbD+a53yJbBf+SMkYRZUgLT6c20HQ== X-Received: by 2002:a05:6102:5813:b0:62f:357a:329a with SMTP id ada2fe7eead31-630f8c3229bmr7109944137.0.1778263518580; Fri, 08 May 2026 11:05:18 -0700 (PDT) X-Received: by 2002:a05:6102:5813:b0:62f:357a:329a with SMTP id ada2fe7eead31-630f8c3229bmr7109898137.0.1778263518134; Fri, 08 May 2026 11:05:18 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:cda6:5a1c:b564:d3ee]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e6dd32afasm11654825e9.5.2026.05.08.11.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2026 11:05:17 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@oss.qualcomm.com, lukasz.luba@arm.com, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] thermal/core: Add dedicated release callback for thermal zones Date: Fri, 8 May 2026 20:05:09 +0200 Message-ID: <20260508180511.1306659-3-daniel.lezcano@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260508180511.1306659-1-daniel.lezcano@oss.qualcomm.com> References: <20260508180511.1306659-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: AW1haW4tMjYwNTA4MDE4MCBTYWx0ZWRfX/mhCIg032SW5 OmsC7969nRP0kgQZ4tGEevfNiFqp8zBB0jtO2nP3B1cJ3ErUxaddIwtLPh24Ht3g6qYacfQOUp+ SEh8okK/UreWCZPUqzUyufvwSLVQ3eo78GG4jYmQ0QtlgGCAm91ei9TMY1YxW7powXimoqESlYS bnnqWkvnrI0ustrjj6oOY35Z2+nsZiIulVUZQ80/My8lan2z79nmqbFaCa2N4kbzqySaX/P30gE 37sn/t5WHOWvpwckQB2BqESXXJxPIrHdLoMtz4V8ZnOrIFCEOufdOFT84lFW6FrDGpNkLrycJ9k YXTX53sqjj46BshuZzfcEvEwwz5Ufcre3gTjTbJ4tbzRUyac0j0LXbDdyMBTKc8z75fBREL+6Ft XddARGw+gwPFeUHm01upTgM18RFOS+M8da5R21BoySLiL2fGb2Q7xmdhOBXa1vJ0mMNDOdMKhWI QsCiKPGbSa/dGPqg8BQ== X-Authority-Analysis: v=2.4 cv=GLU41ONK c=1 sm=1 tr=0 ts=69fe25df cx=c_pps a=P2rfLEam3zuxRRdjJWA2cw==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=fxX41ZqujnG29gMSCLkA:9 a=ODZdjJIeia2B_SHc_B0f:22 X-Proofpoint-ORIG-GUID: vdaQWYkGUBwrMyd5Ps1NXrAxpb1rzNzP X-Proofpoint-GUID: vdaQWYkGUBwrMyd5Ps1NXrAxpb1rzNzP 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-05-07_02,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 adultscore=0 malwarescore=0 phishscore=0 clxscore=1015 impostorscore=0 spamscore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605080180 The thermal class release callback currently handles thermal zone cleanup by checking the device name prefix. Move the thermal zone cleanup to a dedicated struct device release callback. This avoids relying on device names to select the release path and keeps the thermal zone lifetime handling local to the thermal zone object. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index cf5d4a9c11fe..a79fc4cdb078 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -949,24 +949,8 @@ static void thermal_unbind_cdev_from_trip(struct thermal_zone_device *tz, kfree(pos); } -static void thermal_release(struct device *dev) -{ - struct thermal_zone_device *tz; - - if (!strncmp(dev_name(dev), "thermal_zone", - sizeof("thermal_zone") - 1)) { - tz = to_thermal_zone(dev); - thermal_zone_destroy_device_groups(tz); - thermal_set_governor(tz, NULL); - ida_destroy(&tz->ida); - mutex_destroy(&tz->lock); - complete(&tz->removal); - } -} - static const struct class thermal_class = { .name = "thermal", - .dev_release = thermal_release, }; static bool thermal_class_unavailable __ro_after_init = true; @@ -1473,6 +1457,17 @@ static void thermal_zone_init_complete(struct thermal_zone_device *tz) __thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); } +static void thermal_zone_device_release(struct device *dev) +{ + struct thermal_zone_device *tz = to_thermal_zone(dev); + + thermal_zone_destroy_device_groups(tz); + thermal_set_governor(tz, NULL); + ida_destroy(&tz->ida); + mutex_destroy(&tz->lock); + complete(&tz->removal); +} + /** * thermal_zone_device_register_with_trips() - register a new thermal zone device * @type: the thermal zone device type @@ -1580,6 +1575,7 @@ thermal_zone_device_register_with_trips(const char *type, tz->ops.critical = thermal_zone_device_critical; tz->device.class = &thermal_class; + tz->device.release = thermal_zone_device_release; tz->devdata = devdata; tz->num_trips = num_trips; for_each_trip_desc(tz, td) { -- 2.43.0