From patchwork Thu Oct 10 18:06:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13830640 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0CC08CFC5EC for ; Thu, 10 Oct 2024 18:12:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XVR/FvDP5mhKIoh1Y1kujnxSoI8PJE0vC17HhQCmzJ4=; b=fCmz2g3LWAe1nMq4lshMH0vGn5 Fkbx7QPi4+eP3Y6n/4f13e9xms+/39/UyfVc1N6B141/48YGwwj7kXWA0sFUL6VcSI8Jg2HMm80t5 FiLNUAzgYxssIN/eLiykJKU089XAG5no4DofKAurquXcwRvFeDDDcgZa1VxFbSow5XSQOSccN0M8v mBkzTbCtNKLx1VzA01XRcTgso+0IMGX7IOC2d3ea405Mxhkq6nUg4GCRw4lISQUhGZHcr53R4fsd0 Hxin9iWgqcWs4ygFq7GAJ6pmaG0LSR7GccMe/Ri+v+TSCN2QoTnhKdHpItgDWp6D4FQeenTTD0q+s 3cZs6l4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syxea-0000000DnOK-0l6R; Thu, 10 Oct 2024 18:12:48 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syxYZ-0000000Dmdf-2fxW for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 18:07:30 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a994df6bf42so13495366b.2 for ; Thu, 10 Oct 2024 11:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728583594; x=1729188394; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=XVR/FvDP5mhKIoh1Y1kujnxSoI8PJE0vC17HhQCmzJ4=; b=y5OKrULSNII3rM9WGRlcpIrBbXxoyJQvEc89Uafm6wXZo5cStGC0lDtQKyhmcZZaPT mB/5Wy7vdy90PCswguq3y9W3KxdjF/XQFZVE7AvfeKgX/8Zmkjl+2kr5IrkVAqgz6HB0 Ckb9S9rcNDVgfnCzc3GMiMbyYTA2lZ4qkDevXJ2xNe9PPJj6P5CPTfKw8FnzFXiec35X obhwO8BONOJnCJFdbwYWkxHSYT5PptwswueMa3TOZLYtrTCIK1NzWUY8fX3imDrzIhUZ F7EMPFpKT5uPk2Qm6pxUJ7kVavPcSrjklScynYxahQxiKZLq/4BSRDLo6FQGza6J6sH+ qVQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728583594; x=1729188394; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XVR/FvDP5mhKIoh1Y1kujnxSoI8PJE0vC17HhQCmzJ4=; b=iPhZ7K4nRTnkZSLQHjj9kSSlYxkU9Xlfw8ldajsOg5ggzh3MEC70SLv8dFySsRjNJ3 ICuFW9GqiiWVZg31A2+EKrj8/Su8D/QXvYdberrIVp7nJUqPTkSs5geXagvp5APuVzmv DvXB92+zM9c/jydB1Lbb98i5ob0qAwfUJkoD45mhp0SAA2Mk+qxp4yTLzepCS3nR/Pui /u28rcY8id7a9aLvMYfjNsXQOkK+OFgCaW7ppeanfLUg2t1/ZF1fjxyIZzh099I6lkV2 TYoaEIVDr/S0WAS6lamotOxuUPu/IYQVFC9VOatMztQnzjluM3RUkGX2ocPemswGFfQT LohA== X-Forwarded-Encrypted: i=1; AJvYcCUjoXO3O2zuLQPaZm0koehGalAy8mzNsMlvFLDwcVvcVrYHtnKYYBEkc2VNUwXFPF2UBZ0Qx0IqbIy0q8OPNzU9@lists.infradead.org X-Gm-Message-State: AOJu0YxKC68wJ83v1al3Dm6OKtqmuVfwhDLG89T2v8LFaSVYNkUXtrvy CDzcIjrULDLhMHROtfcpqZhD8tyyo109RJdACTCPIBm4MYhKVYnyHJtvn6+BBZfO/06bii9L3wv y X-Google-Smtp-Source: AGHT+IHpSo1bYpbQTRApH52ZLkx22//wr4+WM4NMb5T69enhQxaHE8oy4HxKVHQ9HPHYW4HoXxn5kw== X-Received: by 2002:a17:907:2d8e:b0:a8d:4410:3bd6 with SMTP id a640c23a62f3a-a998d16a1bcmr285817266b.4.1728583594256; Thu, 10 Oct 2024 11:06:34 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80c1b8asm119757966b.116.2024.10.10.11.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 11:06:33 -0700 (PDT) From: Krzysztof Kozlowski Date: Thu, 10 Oct 2024 20:06:17 +0200 Subject: [PATCH v4 1/6] thermal: of: Simplify thermal_of_should_bind with scoped for each OF child MIME-Version: 1.0 Message-Id: <20241010-b4-cleanup-h-of-node-put-thermal-v4-1-bfbe29ad81f4@linaro.org> References: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> In-Reply-To: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Amit Kucheria , Thara Gopinath , Thierry Reding , Jonathan Hunter , Vasily Khoruzhick , Yangtao Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Jonathan Cameron , Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1418; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=21ObDeB7Uw+CZa7niRziQZGtHt4YzVv2qAEMDtifp+A=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnCBegb1ST/vPn7ZbI4vbAm3dM40R8drrb7KNXe ium4Vc1Q5qJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwgXoAAKCRDBN2bmhouD 1wR/EACaO+1utPorr9k+KbMHdTtCwjgZJ0u+vdGMXRDDjW3QbIQfwJl/2brqpM6MmZv+QBLAhe3 9E67zox8RRdjTRvyCyV4B4qXqA88p9tnj9iLBBgNt4I9aXXeYwpfIGaRk/FDZtVsG+kT9qRe5gW njBUzqQELD10L77i8aglLv7Wz2BZyLegcXh1RpiE/jBphdpydEfiG7zMT/gupnQ9uG946N9Hkzs rVXexntG66EPfAzg8fG6a/fTjnzwTwEYP3mfb644cLbAa0+Fq2BS1YdupOyRkuQEweVTeWQhM2u MGHBXwWcEULDqc9I///ZayC7rqIeSa0AEqyXt6IegYO9eNHWtbTOFk4L2Wsb6xiPflzQyvEECdO ubdTdXqDvabhRuvsl/xY4SLKqzzwhF1QY5FmyCzD0w42dLuzC0+4k6oKn7zGxt+yyn7VysLqJ1C LC/bNXi9OEVnDQpSVJoPPVn2PanSEBiI28SySUhmf8V9qUDUfsPzZpQUSbSCp0x6xS+ViWdVMt6 tHFuaKM/rvM4RCYbTGPktSGmHKaFqetIeaheu51jTt6e0U9ts/rPeksEP3RC55+aUNH5FSOByhM zt4jqgBHUYsKZ4C7WvkKn3CixKM0yVU0uv3pFzg+0rs1d/CdnaO7JoqeGQoi25NfFG1jJvSPeUN p4g7KXqiXCwj83A== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_110635_713524_87648F9B X-CRM114-Status: GOOD ( 12.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Reviewed-by: Jonathan Cameron Signed-off-by: Krzysztof Kozlowski --- Changes in v3: 1. New patch --- drivers/thermal/thermal_of.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index a4caf7899f8e4a5f3422e4c02c66502b5050fd6d..f0ffc0e335ba9406f4fd858d6c561f9d23f4b842 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -301,7 +301,7 @@ static bool thermal_of_should_bind(struct thermal_zone_device *tz, struct thermal_cooling_device *cdev, struct cooling_spec *c) { - struct device_node *tz_np, *cm_np, *child; + struct device_node *tz_np, *cm_np; bool result = false; tz_np = thermal_of_zone_get_by_name(tz); @@ -315,7 +315,7 @@ static bool thermal_of_should_bind(struct thermal_zone_device *tz, goto out; /* Look up the trip and the cdev in the cooling maps. */ - for_each_child_of_node(cm_np, child) { + for_each_child_of_node_scoped(cm_np, child) { struct device_node *tr_np; int count, i; @@ -334,7 +334,6 @@ static bool thermal_of_should_bind(struct thermal_zone_device *tz, break; } - of_node_put(child); break; } From patchwork Thu Oct 10 18:06:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13831154 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9534FD24456 for ; Thu, 10 Oct 2024 21:16:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9TkkM0LfkMfefPTa5rHdBKo7UEPK6bYMYTQ0A6kZ7h4=; b=rFYjxziBsQNllv9Yb8OXEzv7jA C7F6XEwNOaWGmH89UPDaXSUuAAnM0PoFP/fiprWuTnVSx3jyo4sGNIUVNLZqekxMhMir+8vVGzbpN dIsCdnSPnxaup3pt2GyNnH4RlNd80zPLSIaqcSQls0tvfguMQ48g+s4kxeDGHPQyAbxTeRb36qB5i iZhKTtCUAcrud9KzqGyKMMtguzAwJ3xZJURoB7E4u8/q7rD4Cd0elFU8VsD65X5NwLK0++o/8Hpb5 a6oEp5YYRCwSj1YjO6oMnUaOeWRUYYoxBWTna4f2AvwapFjJyQLwn5qD34TX7RD9FkrTSN8sSC2+3 K9boFhKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sz0WH-0000000ENVD-1OpC; Thu, 10 Oct 2024 21:16:25 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syxYc-0000000Dmdu-16Qm for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 18:07:29 +0000 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5c93109d09aso239860a12.3 for ; Thu, 10 Oct 2024 11:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728583596; x=1729188396; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=9TkkM0LfkMfefPTa5rHdBKo7UEPK6bYMYTQ0A6kZ7h4=; b=EhzlbC4LOMAxGkRqRnUBSEfbBxj+yryOykE0Bo7KktPdZ1AIqXNlNFEQsN8aZEFpKD 5tCiqJhdERyQ8BHQ6xTV2CXTi6QbNFCwk0rUfAea20TI9uGA3hl2CAvogin8r72TPNnB FrRrg96fFDydMByekiInGhaPUsjJuKkjhkzywp4dEY4cziQPhHBEygIddCej7F4FzYbS WM4nfA8uP1v3H8ZTO0Z8bNMUpkP0y+pLdpIn3HyLcnSyQfC66Pp+fT1GHwVaEsW8eRGC NcX552vVdi+Ceom90VIFSgDOL5iKq4vV2U1J7Lc4GRr8efJK2ISmDGaN/sL2srQ/3bdC nN+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728583596; x=1729188396; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9TkkM0LfkMfefPTa5rHdBKo7UEPK6bYMYTQ0A6kZ7h4=; b=oIiRAh1Y3HUXaXohqQPxLidqRBQanVK/vnoM6FHQv+EulcwUNzEQEs9bGq82AT8hGg uQoqlqqETsCyrcQqd9SzJf8ayXOgcBoUTNAtzp1LmQKrv0V8kgErMReB4Yty0qe9x/+x IOwf6oXahuz56SDXf/C4wDAGkerR1BPmC/Luyhiji81MFpwjgONpN6WSs48uJyvJmTQZ 79DxtZKI7Zoy7nK6v7T78fYqWVVb4ImwVGKSs96UDD1CYkqa5xGOf47L4NZIOSP/Unn7 neQxs1tYGIsBXkuAjDE/fDCAG8075S31LzGiAZUkl6y/aUWwl+D3haoSnS14EM/kW7WI oXmA== X-Forwarded-Encrypted: i=1; AJvYcCXgChi+4cbwrqr4eRWHxKLSxFNsZ54/abjGgFjLwNXDSzc5oHkxAyCT6uu3ReQxA1gnPRVQNae51XbThB9826cN@lists.infradead.org X-Gm-Message-State: AOJu0YySb2Uh6FAAu5ZKUp+PSZADjYgcSnmkeBkIOM+JvmDRaiHO1E9Z pI+jkRaE4aHdAk9JCZDrbUsbnrOeydpWMI2ScR3PPIFytGXLb0ohYjJD8QS+up8= X-Google-Smtp-Source: AGHT+IHQRcErwxHEKdjZt+qsy96mbwbA+guyRE+y4sdV2qs9+3gIUD4PBa5Cd/NrmsCIMD8+zgg50A== X-Received: by 2002:a17:906:7956:b0:a80:f63e:159b with SMTP id a640c23a62f3a-a998cf45766mr262023366b.0.1728583596117; Thu, 10 Oct 2024 11:06:36 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80c1b8asm119757966b.116.2024.10.10.11.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 11:06:35 -0700 (PDT) From: Krzysztof Kozlowski Date: Thu, 10 Oct 2024 20:06:18 +0200 Subject: [PATCH v4 2/6] thermal: of: Use scoped memory and OF handling to simplify thermal_of_trips_init() MIME-Version: 1.0 Message-Id: <20241010-b4-cleanup-h-of-node-put-thermal-v4-2-bfbe29ad81f4@linaro.org> References: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> In-Reply-To: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Amit Kucheria , Thara Gopinath , Thierry Reding , Jonathan Hunter , Vasily Khoruzhick , Yangtao Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Krzysztof Kozlowski , Jonathan Cameron , Chen-Yu Tsai X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2767; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=aNb62zhsaKHIGiPAT70VpnT9AK5gMixXxxVjnHNtWyg=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnCBehPqvqDFh6IfCbkUeXvLZoTSi0gnsGqnksp eTAMoFrw+KJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwgXoQAKCRDBN2bmhouD 1ye1D/486TX4yMFc+ACmtgLM7zbJrXqUMiIGwM0J59oJV5FJLLInEAecAXxLtIUAEj0lC59biU9 Ny0TJWWJatFtaWOlaTJkn9IS37gYCHGuCPHBVclw7lwJ8X+6w8MlCj2K4XcjXSBpC9AMKRfUyBa fTeYhRMZs8KR6TyNmbDhxSkpKD4Ehx6UnFdM9EMg6yylnWIE117rJtSwcHyZkCS+IzVaV57YjDu UHCV181U0knrxBjU0QGzvK0yafY471v7ykkgueBYUc+OdZDELxoSGlPcTpcIBIiJp7opZ1mWdDM w6+ka7YoWt9Qz3CtkNApPn0oSbyj0ZEKN2lZ5X0gqtckJVh/VeHGJl+TFpsM6gR9OC1KtuEIHQK 4zQvpJggWGVRC6Zm6RGfi2R9woFXMnEdwEso/Nzt8eUQkKLaQS7KACvC21U6rmUt77/GXq2BRHX HyXlvc+1nIZP/zj0n1m6xL0SB1mYf5KMFbCeleY/qjjif7gXpOSRZ7jNsnWGwG2ASNHNWM1u/tQ OmdtPnSTluq5tZGFzgB5vldo45QwkB4tf9o9jUxNJkPihsXpiqb2PnFGnwoYnCXAkRw340DAMMT tx/Ijc0LsoVxeKkEp9y1gnSL1mHUdAzUH2q2lkIwiXklkpSppBTOGuFiBq0jwNmLYBcNXORr2Lf SaxsThJH/GQ8tSA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_110638_339203_57701A1F X-CRM114-Status: GOOD ( 16.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Obtain the device node reference and allocate memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. The code is not equivalent in one minor aspect: outgoing parameter "*ntrips" will not be zeroed on errors of memory allocation. This difference is not important, because code was already not zeroing it in case of earlier errors and the only caller does not rely on ntrips being 0 in case of errors. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Chen-Yu Tsai Reviewed-by: Jonathan Cameron --- Cc: Jonathan Cameron Cc: Chen-Yu Tsai Changes in v4: 1. Significant change: kzalloc() also with scoped-handling so the entire error handling could be removed. 2. Due to above, drop review-tags (Chen-Yu, Jonathan). Changes in v2: 1. Drop left-over of_node_put in regular exit path (Chen-Yu) --- drivers/thermal/thermal_of.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index f0ffc0e335ba9406f4fd858d6c561f9d23f4b842..37db435b54b124abf25b1d75d6cc4fb75f1c1e5c 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -95,11 +95,9 @@ static int thermal_of_populate_trip(struct device_node *np, static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *ntrips) { - struct thermal_trip *tt; - struct device_node *trips; int ret, count; - trips = of_get_child_by_name(np, "trips"); + struct device_node *trips __free(device_node) = of_get_child_by_name(np, "trips"); if (!trips) { pr_err("Failed to find 'trips' node\n"); return ERR_PTR(-EINVAL); @@ -108,36 +106,23 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n count = of_get_child_count(trips); if (!count) { pr_err("No trip point defined\n"); - ret = -EINVAL; - goto out_of_node_put; + return ERR_PTR(-EINVAL); } - tt = kzalloc(sizeof(*tt) * count, GFP_KERNEL); - if (!tt) { - ret = -ENOMEM; - goto out_of_node_put; - } - - *ntrips = count; + struct thermal_trip *tt __free(kfree) = kzalloc(sizeof(*tt) * count, GFP_KERNEL); + if (!tt) + return ERR_PTR(-ENOMEM); count = 0; for_each_child_of_node_scoped(trips, trip) { ret = thermal_of_populate_trip(trip, &tt[count++]); if (ret) - goto out_kfree; + return ERR_PTR(ret); } - of_node_put(trips); + *ntrips = count; - return tt; - -out_kfree: - kfree(tt); - *ntrips = 0; -out_of_node_put: - of_node_put(trips); - - return ERR_PTR(ret); + return no_free_ptr(tt); } static struct device_node *of_thermal_zone_find(struct device_node *sensor, int id) From patchwork Thu Oct 10 18:06:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13830639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9139DCFC5EC for ; Thu, 10 Oct 2024 18:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1QMbawNbB2pemOrxGvjwG9oTD4DjBo2bQpJ4URqAkxc=; b=qEIzAZhWS07ydSg/1p7FC25Vr9 g1EDPw9L1NM7LKHvNcTO0SwuSCnej0e19aw9RAWr8GOIbcPjcmVUV2xP0HRvLkMhgFGnt0Kpfrtt4 6IejurQBhs4LmfNhnksCrOYJpP8mstxHDdgszkJ0V6ZTnkCHybQjJVpby4zrzRP0gGv2poWMMD1KU T574piUYbS5oxwZilS7CSGmZpyuFIQ/C3bYw+ksnKu/UpJXT4jwa2ah9k6unKNl2gkWnbK4tQepJf hDI7RGx3HW0xwhNdSVLfz3P1k8MKHDNQl8Pur1E/1RRjTIjSq9s1EE0ZMb+GySlZGMLLRJWf7hMz3 biL0qDgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syxdG-0000000DnCB-0ct7; Thu, 10 Oct 2024 18:11:26 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syxYe-0000000Dme8-0uot for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 18:07:30 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a995a0fc401so14682966b.2 for ; Thu, 10 Oct 2024 11:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728583598; x=1729188398; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1QMbawNbB2pemOrxGvjwG9oTD4DjBo2bQpJ4URqAkxc=; b=x43/Ev1kxesa5gPPRroBFiIXm0j4c+vOJNXq4IlyF2gtl+p1AuLrvDjXZTCT0nOAJY hdf0s6TsXDSEn1/+bnW52ptUQkQnQEE3CUxfD254CHsRH5IXTosRYsN1Yiix1a51htUh 6V+H35gE4FLlqwgHQPdekwnMzYm/wLznnPDVbMRBDxiMk4DtQ3jfIBPtAC56czOOqhaT BUHryDfhw7SrTz7Wm0SY3trRrJCFG6piluji+jRQtD2O+MZzE+3IHLIRn2heRgiYKFe6 dOCXKJQPrayebJ61QMZIeqCmApZR9cHXRz6Yjn/UiRNYQiVRzdCfVG2Oj2d+7K/+dj15 wQ6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728583598; x=1729188398; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1QMbawNbB2pemOrxGvjwG9oTD4DjBo2bQpJ4URqAkxc=; b=A5nwlNFFsD7wo5nNyAHUPjGcEka51TlWCKGH9VbGavGXYZDMA7ybJ3KTP0DER1MNHJ V0BnZ+H8e5+eb47KtpyFNrMIdxa3N284iaydUwiTmYzaPrtMrCWOLMg1+xiN/r67uS4W J4vbeOs1JuxBT2WXsVdzzM6Ew2oYT1HZ95BMfPZVmcVUMmI/W2qp4vqQoMTal7xn6Dm2 DVdtHnjO4K4kLqKTLF7fLC+E+97gcmsFyHmWx3FTB1M2tPABMMv2/FM/ze5Qv9DG+naN 2TUfEIW3HKPbs7XhbQ53jv4wRS0OU6sngLfggnPK7RK5i4e5Ke2VGkfQhIKZmoTUEf3c gYYQ== X-Forwarded-Encrypted: i=1; AJvYcCVrq9GtL2rsZpeW7D+90EhlHPD9pj6mdfsmqwbWO/vyUF/RsuoZkS7tNwEnGSixETDHj65fX2HHLRmx7Trw66O4@lists.infradead.org X-Gm-Message-State: AOJu0YxfPAFNzn/Yd96WEFDuh/qGI0utMrUNycGhwUJbgMgvIQsjFfy+ +3cDRT+bqwlmChtvmAqasS5MfXwKA4C4p0xNg9Cf6kF1czHEeaJ425aSqmgLQJo= X-Google-Smtp-Source: AGHT+IGoLFle7c3swn9/rv3LyHsELE4XyheQpS1XJpGhNDCvGHEEviqlcrtkS1myk5GRLypn6mdLCQ== X-Received: by 2002:a17:907:ea5:b0:a99:6036:900 with SMTP id a640c23a62f3a-a998d16a50emr323248866b.4.1728583598040; Thu, 10 Oct 2024 11:06:38 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80c1b8asm119757966b.116.2024.10.10.11.06.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 11:06:37 -0700 (PDT) From: Krzysztof Kozlowski Date: Thu, 10 Oct 2024 20:06:19 +0200 Subject: [PATCH v4 3/6] thermal: of: Use scoped device node handling to simplify of_thermal_zone_find() MIME-Version: 1.0 Message-Id: <20241010-b4-cleanup-h-of-node-put-thermal-v4-3-bfbe29ad81f4@linaro.org> References: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> In-Reply-To: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Amit Kucheria , Thara Gopinath , Thierry Reding , Jonathan Hunter , Vasily Khoruzhick , Yangtao Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Chen-Yu Tsai , Jonathan Cameron , Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2293; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=IKkYyEEUqBTCZShccEeitn/IT5/XA0WevxOw6lxgVCI=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnCBehPUvBEauTEbyosFo9Xwu1uK9auHaT6zB9A VFMj1hVK7qJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwgXoQAKCRDBN2bmhouD 1zQqD/4qvqH3gUy07CdQwQksDO1VwmECOuVXL8ucYoDSkfJ7iXfUWjIwVueTMozOgXG5ffgbbdh n0/UPMG13ETnJ8NHsDtPuqB08OQnf4G2RzZuTzqYvEOD/3aDQjpNLXYneuw3oWDhiIJ1po/jPoH hl65pj944m0cx7/B9hEHLRirR5BFuBvs6US40buZ1Dn60LcaLXb7OIWt6A+d8V+Ad2HOUC5rzjA YcVdtW8FmRcIy/6Tj8sqP0h3IBzAkFNE8rVCh0avCTYWFxLqd0FsrmlGKgqmSo3Z6ix7rH4hwNG JNq1kXjmrLBghMxb0m2IXA+XGhd9czJnH+CQypj/AHN0VLz49eMxBxelC+PoWRbbnhmB8oGhZZ7 YTad7W1uGdR+kgHTfRpUwCzwSp70/AuyL5LzEo6YEX/UUCWqkivt6jvLTdL9vZKAKyyhxewh9JI XYkw8CYFFCp6ByuF4P5C86814J7wEX3x4faqcWIIo+KjUwC/2TZzdZJwrgcUJKOZy478DnqSEzp Jtm31R4QnRfz6xzkEfDlChFJDlWZiM4qibx9q+b90Cm5K1erObf+JEX5Aiavwv3FHio103gxUk2 DMgQUXr9gpJMNcDQeXjTC93WlJUwttKVw02K0N0HYMu+KfwMaQBCtzU5XtDtNcuIb0W6Q0SQi3o 6WsRYwn/NCW/aOw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_110640_306678_5D8FD26A X-CRM114-Status: GOOD ( 13.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Obtain the device node reference with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Reviewed-by: Chen-Yu Tsai Reviewed-by: Jonathan Cameron Signed-off-by: Krzysztof Kozlowski --- drivers/thermal/thermal_of.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 37db435b54b124abf25b1d75d6cc4fb75f1c1e5c..66514120f460940ed7cfba791140c958b99e056e 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -127,10 +127,9 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n static struct device_node *of_thermal_zone_find(struct device_node *sensor, int id) { - struct device_node *np, *tz; struct of_phandle_args sensor_specs; - np = of_find_node_by_name(NULL, "thermal-zones"); + struct device_node *np __free(device_node) = of_find_node_by_name(NULL, "thermal-zones"); if (!np) { pr_debug("No thermal zones description\n"); return ERR_PTR(-ENODEV); @@ -148,8 +147,7 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int "#thermal-sensor-cells"); if (count <= 0) { pr_err("%pOFn: missing thermal sensor\n", child); - tz = ERR_PTR(-EINVAL); - goto out; + return ERR_PTR(-EINVAL); } for (i = 0; i < count; i++) { @@ -161,22 +159,18 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int i, &sensor_specs); if (ret < 0) { pr_err("%pOFn: Failed to read thermal-sensors cells: %d\n", child, ret); - tz = ERR_PTR(ret); - goto out; + return ERR_PTR(ret); } if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ? sensor_specs.args[0] : 0)) { pr_debug("sensor %pOFn id=%d belongs to %pOFn\n", sensor, id, child); - tz = no_free_ptr(child); - goto out; + return no_free_ptr(child); } } } - tz = ERR_PTR(-ENODEV); -out: - of_node_put(np); - return tz; + + return ERR_PTR(-ENODEV); } static int thermal_of_monitor_init(struct device_node *np, int *delay, int *pdelay) From patchwork Thu Oct 10 18:06:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13830641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8D0ACFC5EB for ; Thu, 10 Oct 2024 18:14:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=T87muPGakKecqoFQwCwDAV8Lh+PZOzuzFVteMhdsZl4=; b=R4r2yDFRj/pHN7ZBVhn0uCEDtE PwXFrfCbDPvnuKowetlXCFZtX+Oa3LlOSF569u0XVliU0+MiiIoCQdYTkheJC5jAywnMpQDdz24T2 5j/ex502GhuRXWCLV3kcvqvABkggEj/I20PEyauUb5hM9YL8IYqMPT3N7CW3K3yZZswbJ3TS11cwE EdORsZnwxhgraL3dX49RsZyMBl5ZNgeZTidAM1CY/wuXnjhlkj6SWjNMZ8i/nzZD5GE+dV51N3nsb +wOHLQCntGKVfz/2SeWGn/1vPNf7ttZMRzBxPSMmOwdzrqe9VuyQDfhNY//q0dfeEqu6K/ZvzsypF 9t7sV7/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syxfz-0000000Dnew-1oJT; Thu, 10 Oct 2024 18:14:15 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syxYg-0000000DmeO-12dQ for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 18:07:43 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a994df6bf42so13496666b.2 for ; Thu, 10 Oct 2024 11:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728583600; x=1729188400; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=T87muPGakKecqoFQwCwDAV8Lh+PZOzuzFVteMhdsZl4=; b=YFQQWeVJVYR92peLuWZXFzSIMbL4O+bsNT5IMZvpmbci2YiJ06nTr38wOdOnif4b/N jUcRp+GTHyzJJmlIItSJfiFr4Sw/zDz+uL3A68KYI1TBVoZv/XBId2oK/FNAMLElji7C fIE+dNefTtxttbxkpJKwopjIRiLqvcxtu5UHTisnscXiq95EWinmzpfB9LKHi7wQQZMq 92+SpZA3ht0P2S4a8ufeJaAICvv57AUqwIj4O7PpUuafuqxY4MIunm67eyNcWzvhJcCf XizoTICK26yuFOJyssNepZwe86lR7ofnD9WyCjb4QvF0VwbCSNGNT/3IaRLvr3XhZRtf xA+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728583600; x=1729188400; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T87muPGakKecqoFQwCwDAV8Lh+PZOzuzFVteMhdsZl4=; b=lbeI5PL87WjNPnrOWbhWYojGgE4PUaXewZXO0/qDij68a7dSeJQEEjMyDN9lrVbaXj JG4S03VMByVZP8is97ryVS0rno0rK5xsZ1RhxuOar6x25LnkqtIzfZW4lMsVJIjfDh/X W65M4niqAWvi8eavGcT9NdJjvta7/81sfTrMA3jruQKWxqdjFILTgH+mi0EC/v5XEJbZ Wv5QRPO5h6FXHNawP4Usblsp/GvCA/YXnWofwnnIvsQt1h4U2ZajrBoiTYUyVTakimbG J7jXbrNm6fyxzazRIUF6ruT4eBIiW7DcZzSvgNtOgaonQ4ORf4iKzmkHgxn5fY4pL0av JpgQ== X-Forwarded-Encrypted: i=1; AJvYcCVUIy8ekTcaYo+x+2IgUiuytSkRoHj3oyog7JK7iqx4genIpdUmEag5mKJoumVj68emnLFKm48n6FdBHMu+9RFj@lists.infradead.org X-Gm-Message-State: AOJu0YzI5cZzp6sBPgfkMQUoGFZ6pmdr7IaC4pmRiUKVF1WhkLPPJIbi k5BeEJW5ceHp+s48xnW+VWJaVwn6Tjd6jffVihWvKPlm3iJ9ne1MRUdogN9cGH4= X-Google-Smtp-Source: AGHT+IFrJLzGfmSeY4fLffFxiKpfgPVtVi0hI0pqAhjV/N3dGTkIuoCJA+UIpnDwUjrA9tlgsN7+gA== X-Received: by 2002:a17:907:3f1d:b0:a99:53cf:26d5 with SMTP id a640c23a62f3a-a998d307d15mr331306666b.11.1728583600130; Thu, 10 Oct 2024 11:06:40 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80c1b8asm119757966b.116.2024.10.10.11.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 11:06:39 -0700 (PDT) From: Krzysztof Kozlowski Date: Thu, 10 Oct 2024 20:06:20 +0200 Subject: [PATCH v4 4/6] thermal: qcom-spmi-adc-tm5: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20241010-b4-cleanup-h-of-node-put-thermal-v4-4-bfbe29ad81f4@linaro.org> References: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> In-Reply-To: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Amit Kucheria , Thara Gopinath , Thierry Reding , Jonathan Hunter , Vasily Khoruzhick , Yangtao Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Chen-Yu Tsai , Jonathan Cameron , Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1450; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=F/6M460B12wipWGDyJ3DH4nQN17g4TQGelqGAmG6zMM=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnCBeibSc7HHoJfMrPMNz85qOOfTsHttHWu8lLh rAfMZtJv+CJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwgXogAKCRDBN2bmhouD 151lD/4nfzF0ejhz0ulFE2vT8CeAE7Ieg+4VBtu2Dsv9RMUy4rYMvfjiHgZNGU5s3mhdapRtgwV +j8bOKgBQsUXU/HzoWG9sf54gPp6k1Bpcg9ab3KfWSDMBbHSNrM0PUPBa1DY75PiFI97fDEel8j 3HNyRupjhiOQxMpHLSfesKOPXHk1nmTbGbUx+K/z5EduD023nVQSw6R9Bmnw5un/fxwWJpZQord nKD5OO5fIxUCaXUOiWDx1pv4v4Ieb069xF480SvUFU3SB1/2fD3htTcq3feZVkL5JG9DJjI0oDl JwEvxNsHl5pVkh054LprqvH5X8o6HyrToK7GHCwCeQ1R0DGiGP07WBb3LFgADZjGC8h2fYo1SSA Gnr6qISd6GtAn3xhJIcBbo3xSWtJD2Uf7hZMhLDbJfdjl5Vlq2CQ18IAvS6s0o0qiiGox9qtkie NrxWxNUNkWK120IBXyduE8/EgAsVeBKd0lnU5Y5LxLlWgyz15vq8vday7JkPYVtMzxjxuZWbQQL s3GYktASoFB026qr+pzzRNsruCUnVXbQ+MYrvcyFV7meWrX0dubnOunJbuy+fqccRsEUbsbCDWt +5/Zu8wUDuKev+8QrVnVhfjkJGcpz68HGRoFwkLpqELydAz5GxSiSf9WfvAse11dJXSwWIb2tBz IXhmCGmCmQMkFcA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_110642_322847_2D330A5C X-CRM114-Status: GOOD ( 13.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scoped for_each_available_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Reviewed-by: Chen-Yu Tsai Reviewed-by: Jonathan Cameron Signed-off-by: Krzysztof Kozlowski --- drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c index 5e94a45eba3eef65e436a01b3aa58aabf5f706c2..d7f2e6ca92c2c9fb532ca5d4bcc22b6c2cddbdb0 100644 --- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c +++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c @@ -938,7 +938,6 @@ static const struct adc_tm5_data adc_tm5_gen2_data_pmic = { static int adc_tm5_get_dt_data(struct adc_tm5_chip *adc_tm, struct device_node *node) { struct adc_tm5_channel *channels; - struct device_node *child; u32 value; int ret; struct device *dev = adc_tm->dev; @@ -982,12 +981,10 @@ static int adc_tm5_get_dt_data(struct adc_tm5_chip *adc_tm, struct device_node * adc_tm->avg_samples = VADC_DEF_AVG_SAMPLES; } - for_each_available_child_of_node(node, child) { + for_each_available_child_of_node_scoped(node, child) { ret = adc_tm5_get_dt_channel_data(adc_tm, channels, child); - if (ret) { - of_node_put(child); + if (ret) return ret; - } channels++; } From patchwork Thu Oct 10 18:06:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13830655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00AC9CFC5EC for ; Thu, 10 Oct 2024 18:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zMe5HePhBUeYRfUt+t783COcyrs/YnND8+jdMLpIJ/Q=; b=RVrudx7xSQXPcMcYYLohnYxyhz PYLCb3HrofcSfLqo7T4oFDmK91jg3Cn9+vmkybcl3FiOxsRwhUN9SFAOgyGnlW9K+nIQaYDGiPT1+ I4dDxi9+owspr0VFrkVSS8fD1VGiZiSHPfUqIAnu8eGHjrVXaPifuaAj8KRKhxTB/ZY4Qa9//jbSa cxygPSJvm23lieOMI7hXOZi9Ja+q0TRr6UU1M3S6ATkBbDrMePx3x6AP4np/YL7I5d+qaDUP1s92F TjsIy4UqJSQzraOTzajQfQpbRjdgKID5YN/HsejuiYrJZzoI22D17Al/DUje6ZkIVPB4A96r2ybtn btL9uo8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syxhJ-0000000DnqJ-1tXP; Thu, 10 Oct 2024 18:15:37 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syxYi-0000000Dmee-0U0G for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 18:07:53 +0000 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a99409f1cc7so17517866b.2 for ; Thu, 10 Oct 2024 11:06:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728583602; x=1729188402; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=zMe5HePhBUeYRfUt+t783COcyrs/YnND8+jdMLpIJ/Q=; b=Eh69q2yw+eKouyX8rK/ktBmH5sKQf3QEaAXJUG30ge33GRglc99md+S8WHBYcrQmTd KE4iCbq8bYr0r5cUhPe94maBZEwfI8+A1ipif6Mub8az6mqihRjLrxQ/E7phPOyspIM/ FtjYatu4TbOmebzj6FdZvMJeHE8CLN/5fTtldyletPBGE9luqksSl7WHTFnWWndfjisu xJ/b2NbRqNNTL6OLeXtueqvaVoZwJGgsnaGa2KM+e7omKDO4JShpWhrhgX02jY4wRpwl DA11yaVwHToiw0UrU3et2tvyavKt6Xb1FfvFpQlBynkj74ZlJUb8ZrQDk3TmJHoXk6HB Rd1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728583602; x=1729188402; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zMe5HePhBUeYRfUt+t783COcyrs/YnND8+jdMLpIJ/Q=; b=IVXcIIobbN/HSc20h3uxmkl99KpZwiQ5G/8caiEqi1ykBc179RUtCAfHrvGg/MM72f L1ir9Ls4wnBWvC0MzTeRHxnTeQNzkfo+uS49em8iVSthzowk/DETpp/mFF+H2XQ+73b1 D8UCI3lblLFv+ive23zb5sHAIlA2C665i0bn9BRqprf6Z6DMouVC9rlIPwGxkY1p3IIn L1yG9AdS9Ue82jt5etZ5oTz2IWXGI2bgvQMkwETWHlx7Le6+70QV/HLfReZJkU3Y9F21 WDU8OR76GawPlivz6CLawGs9Kxq3Vns5+XKq7xNp9zOL40TyQYJkqxmJjRHgdIXeXnZk rzqQ== X-Forwarded-Encrypted: i=1; AJvYcCX4jkF1w503DXL3dwhPgH1Gy2vVavFhvfvqSFvvfYP1aaUVMV68TIYhFnu8r0ddq/VIjxk4gtbUoo77xhrJajJU@lists.infradead.org X-Gm-Message-State: AOJu0YzUm/Ag/D3OdV0WhEoLROTYzgdzFfMDghlwNFA4hGt5Z2hUm1MY BULBB1P4UPZcrY6SMgDpN3wP65xMYZ06AMjbfylsVN+MT97z7dAYPAqRD7QVP41SpFZf/JiVeQY z X-Google-Smtp-Source: AGHT+IFjB63/jfrBk0eN6WcJADeEZxL3im8HrhNr5oZenhrqyJbL9Yal33sIcZCX4teS9nhkZm9GTw== X-Received: by 2002:a17:907:940f:b0:a99:6ca0:30cf with SMTP id a640c23a62f3a-a998d117c8amr324118866b.2.1728583602014; Thu, 10 Oct 2024 11:06:42 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80c1b8asm119757966b.116.2024.10.10.11.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 11:06:41 -0700 (PDT) From: Krzysztof Kozlowski Date: Thu, 10 Oct 2024 20:06:21 +0200 Subject: [PATCH v4 5/6] thermal: tegra: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20241010-b4-cleanup-h-of-node-put-thermal-v4-5-bfbe29ad81f4@linaro.org> References: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> In-Reply-To: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Amit Kucheria , Thara Gopinath , Thierry Reding , Jonathan Hunter , Vasily Khoruzhick , Yangtao Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Chen-Yu Tsai , Jonathan Cameron , Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1477; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=BdGrjkiZQWh1WcuBimpPZ6XtKP2yiGuNF+kzNxp4Gjs=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnCBejWV/QRORUzTaED875a/UAIUxkqjmo8EOWT kMOrdM0W7WJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwgXowAKCRDBN2bmhouD 18Z+D/9J0c7qqVdhn8oGOHhT50RX0ZxNnG/KK59zCeLsNgdpi8PtrKyaLDCkg5tnoYFYe+s2Rtq 4/ULr0gtVWSYjewjs+JwL2DenODGLK393X9djFuOVFYTJAkZjKwOp9u9vm+VeyEPWcl2fjZ2BC6 9Yy4YtoH4iqpiwqsocJlCzguxZL7//bURxaHbhk+LbqnHbrwH9cKk+TecI3Ia6MATdkjt90b4OE ve40c/G5MAJOjcKCqgXJQkNiC1W9dQ+s5iQ1g1Y885Al3kHUKGi6A/cjqg5Q+JsfNJ73Q+k6rT9 C08DY7x5GWlpVRdkNKEl/K0+oGhZUGhxZFwvgBAl91HlIgRn8LvMjQw7EaWng2SlLOwMQYrtlS4 JxNaMGKbccQo2rWiSA7trOUY0dGMQOxTaYDh/n858DvzIKFgtQw8IxU+F2Kl01ljhF+j83Kg267 pQuqO8JhZg1tvBE/XFQknST/+ga35RiHIZWgTusHM1fK2mgaqs7c6/Zon6sOLf1uDfsi5Zy0NEw y/LQdfnWOvr1EmDljXe2YZSAedCiMpEA3OiuuI8UU6eiSjto324tSJdfNyps3kLwZ/hL2OylK51 XD74I51ro7VBUjK01Ou8JUDTG1qj9D/zbvX6BFPja9bPg6Hl9vRQP9yYKJqsV3Y7dWuWFsxpzKG GhkctaLnxk2P4hA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_110644_199367_AF43352F X-CRM114-Status: GOOD ( 12.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Reviewed-by: Chen-Yu Tsai Reviewed-by: Jonathan Cameron Signed-off-by: Krzysztof Kozlowski --- drivers/thermal/tegra/soctherm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index a023c948afbddd6d9fc1a00b2fe310c71147bda9..ff4eedb553fb6e78c94b714dd179193c244b6589 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -1651,7 +1651,7 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct tegra_soctherm *ts = dev_get_drvdata(dev); - struct device_node *np_stc, *np_stcc; + struct device_node *np_stc; const char *name; int i; @@ -1668,7 +1668,7 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) return; } - for_each_child_of_node(np_stc, np_stcc) { + for_each_child_of_node_scoped(np_stc, np_stcc) { struct soctherm_throt_cfg *stc; struct thermal_cooling_device *tcd; int err; @@ -1683,7 +1683,6 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) if (stc->init) { dev_err(dev, "throttle-cfg: %s: redefined!\n", name); - of_node_put(np_stcc); break; } From patchwork Thu Oct 10 18:06:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13830656 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 640FCCFC5EB for ; Thu, 10 Oct 2024 18:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zNHd9uOUFYMvCAXebRo/fjYtsxyYPOLWHoAaGWoy1tE=; b=1nw0sJEaik5RCIqn8iXoU/hH85 /CW6phYinVgkXHbQH84ZFcgDxmj8KRXJuliY1t27JRjmA/LQV7DmN/vvlTWAwqCJrmWJTsHGTuH0l EaWaq4AXgWqx4EfP+jiZ9FkXyWALgua2Tz4459P0k4JTJ/tyofg63Aq4zBj1X9gRgAz2aGl9mlWf0 RcmrjQd5oZ/W0Zzm9iUI1Nm0s7kXZ9MK3n2BpHBy290ZROIv/Ee9fWNyZEVtslBufNLwWWUZ7NwM7 U4ZNDh1mmARwaFsFjbWBw0pe2wvVsKpTRJLdkqv0ffcvWbi5TlPWI4PrEhFO16Iv+FkaLPlMs/JCT 6QpeEF1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syxig-0000000DoCc-0vdg; Thu, 10 Oct 2024 18:17:02 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syxYk-0000000Dmew-03gY for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 18:08:08 +0000 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5c940512711so115968a12.1 for ; Thu, 10 Oct 2024 11:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728583604; x=1729188404; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=zNHd9uOUFYMvCAXebRo/fjYtsxyYPOLWHoAaGWoy1tE=; b=o/hr4/MjqCrQkJEwRGmIIvjlSop70vUoYCZ+Tvjf/3tvKZVj2RQ/lr9wgiAgaxHUiT Bhc4RfBymdBRPL4kGEL4sjF8C5CN78y5tbAH5bBnA5pePv7Cyttc28tWOgnEVExu1uO+ 8e8NijBU5ggRWxqoZkGlR9wmMk/4gf0Z0tJ44iAAlBACZvbzU6ABMEZNc6dWqeXf1pZi 2d/x2m8+anKvDF7h8uB15bCMS11yDI2mDH9jGRgih6sxiQNEhiji9gxFo1Px1y+ViwF4 XENGGeChW+hB+bl5U0HUgyK6snZw98H2L1589yLVw0zDUiw4RuRB0JwnXvJ5BMR6F1Re O4gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728583604; x=1729188404; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zNHd9uOUFYMvCAXebRo/fjYtsxyYPOLWHoAaGWoy1tE=; b=ERVpGWITrGFO6nFd8evZbItxSEJMObxWPySx7FvUzmbkXHI/kNoVlR+VhoUK3TkZHu sYMISkQWhk7NlgmG/9aTZL5xHDZJD5W4fziJ1zsYEu2dn3Ib7bsZypB2XFynJll8US9T nm49yKr0f5AZ1Bgj6S5Uzb5NAg18acNFjXIuZs7G48FQOERuTzxEwZEIRK+YWhY5m1X9 6pvKcz8f0dNChb4gYxNg1XLMPjbDDZv2ZaoE9h9RKayKPWYymxm7Zco8XFR3RsZ0CjQ6 grRUa04TGq7G/tKXsLTdWug68PmzVdBC1u59SaAbEoFaViIc561VgorCz8s5sGK5/7ZA n9Fg== X-Forwarded-Encrypted: i=1; AJvYcCVYTCYEXSDRWrGJzPRDMx51gZXSSs4mzA7tI8Vpu6qwAXqERZ2aTlxse1EDFAxR4tVh4rrDIhbP7ouSu9U5rOH7@lists.infradead.org X-Gm-Message-State: AOJu0Yw3OGsQDJkZZ55pHpRxUGrrlkCaM+44bsy17QoqjIn43Bg4epMf bAWyKOhqA5xIAOSJj2jk1eZPCIHb66gitf2vnC1ZXAgSy8Cy30HwXQu4XYYO8kA= X-Google-Smtp-Source: AGHT+IHXG8VaZInUUFAvxb002JlgmJFHrC3mhFZJAVtrcbAFOAxaAouRcGLkivAX5NM5oRoVFuCHnw== X-Received: by 2002:a17:907:d24:b0:a99:8cd3:5810 with SMTP id a640c23a62f3a-a998d1f64c8mr283223566b.8.1728583603840; Thu, 10 Oct 2024 11:06:43 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80c1b8asm119757966b.116.2024.10.10.11.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 11:06:43 -0700 (PDT) From: Krzysztof Kozlowski Date: Thu, 10 Oct 2024 20:06:22 +0200 Subject: [PATCH v4 6/6] thermal: sun8i: Use scoped device node handling to simplify error paths MIME-Version: 1.0 Message-Id: <20241010-b4-cleanup-h-of-node-put-thermal-v4-6-bfbe29ad81f4@linaro.org> References: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> In-Reply-To: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Amit Kucheria , Thara Gopinath , Thierry Reding , Jonathan Hunter , Vasily Khoruzhick , Yangtao Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Chen-Yu Tsai , Jonathan Cameron , Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1855; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=wYClXJKWHiD7HQHxTZ+cA0c/iCEus3r1K31L8rg0g5w=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnCBekdByvAQz7PIlOWkUvsQ+WBs5zS53VgUcf0 2GuMObk5cuJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwgXpAAKCRDBN2bmhouD 1/yKD/410uKcFyGlvzO15ze4hOKRpWLw5V67Kx5zo8B43YJaHxuSHUBpoOJeBWXrAQgdtP2GXzE l/qxBeSvhw3/GFyFCDOYDyG6HtkW3qO5tIqx8fVOCxHTiB0yf1+boloOALHg6vBDKdpzDHOBUNK b1YDa8X9+f1mk6f0pxvVyfKWfO5Uviy/aQHM1dc5Ccm4dZo8U3j7EQH4upqTCjjavpifP3MY3oT HuInbdw5jbjjlFdpo/ol4J4bSkwdH/4nj3349zrPrfnZ7SQOapQwexeoXfSXuKCdR8CgZDAb3cp O6LB80/4qxIJeiIbZZtgaGrBLXKSGT1g+T8er0tzcd+tA1SyZK6ZPB0wDH0pT7CdWrIhdpovTEM hRfI9tQsU0s5vI6wuU3DiNNP6KGsVqTJ6HgqBpCnQT2SeeJb7/Yn/rHj/+H5rPV61vr+8hNj8Lu qPy0HtHZAK+Cc76xRkB493/Z1IYRLJy6P5Pqumw+2e2OrmnG2A8q+IiwbWFOZ27DwwAfh1F1rjk QrLJV7lq513bxJLg9IFDzSO4lp4ZeaZH5wAmI0CM2u3/AAkkcZSblw5syk2ZrqWBdHDWtr4Vdnq l1jmQTDe1UvwKHwTbNvQBUJswCUTUtCcGKAadL/Hpd3Zo2rxZxtBcYQyKvZAHwIKsBif/rgIoTx pIR+Lgn8zsIoDqQ== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_110646_091703_0130F70F X-CRM114-Status: GOOD ( 14.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Obtain the device node reference with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Reviewed-by: Chen-Yu Tsai Reviewed-by: Jonathan Cameron Signed-off-by: Krzysztof Kozlowski --- drivers/thermal/sun8i_thermal.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index 3203d8bd13a8fc2a9e5a59b3547cefc2440542c6..22674790629a7b549d1ce618998ff51f6553613e 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -348,19 +349,18 @@ static void sun8i_ths_reset_control_assert(void *data) static struct regmap *sun8i_ths_get_sram_regmap(struct device_node *node) { - struct device_node *sram_node; struct platform_device *sram_pdev; struct regmap *regmap = NULL; - sram_node = of_parse_phandle(node, "allwinner,sram", 0); + struct device_node *sram_node __free(device_node) = + of_parse_phandle(node, "allwinner,sram", 0); if (!sram_node) return ERR_PTR(-ENODEV); sram_pdev = of_find_device_by_node(sram_node); if (!sram_pdev) { /* platform device might not be probed yet */ - regmap = ERR_PTR(-EPROBE_DEFER); - goto out_put_node; + return ERR_PTR(-EPROBE_DEFER); } /* If no regmap is found then the other device driver is at fault */ @@ -369,8 +369,7 @@ static struct regmap *sun8i_ths_get_sram_regmap(struct device_node *node) regmap = ERR_PTR(-EINVAL); platform_device_put(sram_pdev); -out_put_node: - of_node_put(sram_node); + return regmap; }