From patchwork Wed Aug 14 20:17:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763912 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 3F571C52D7F for ; Wed, 14 Aug 2024 20:19:32 +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=ObSCoIKHR53RsBAjPImzvWTBDUOXW/cdZ+itJeFwmLI=; b=abSb3aki76qBtYdPBLIEb7Ze70 4/7WlhJylTID4kT1SNMEcLjVyfICAEUs4WPKmHdDCCXgGZ1fTXKks+c4zLik0AbXEURwrfTBV+kYL f14WaemyQMMIupwTizSs5eSVvV92P34OWE0yXoujDG3QJwrMXq7SqokFRlLUNrBAFMgFmBshdIas3 VjghA67Hx+1JJX1tpQTCberv1CoJfoQKBc4rVVdKQxxBYvu0/cYwaYruKm5q1ReSHiJw0lCaJutJo 6bY3qrFI6V2qemjj/KHBnG6EeVZGjQ7GNCqvU/GASZO2+Yaa9bRHi2LyJng4NzxXzpUOgA4xHpFkn 4AxEdbPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seKSl-000000089VI-3GW5; Wed, 14 Aug 2024 20:19:20 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seKRY-000000089FT-2Wcb for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 20:18:05 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-42812945633so1234405e9.0 for ; Wed, 14 Aug 2024 13:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723666682; x=1724271482; 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=ObSCoIKHR53RsBAjPImzvWTBDUOXW/cdZ+itJeFwmLI=; b=IpjRBqSf72LjomLl7MVRPHLUDaEssX4yJH8eHcPVm3HUjQepHj8IMEhu1gnJWu87yc 9l5OUhL0YGkt20QOltITkjAjG9u74FaQJMfAgsD8Qv6yo+I2icPNfG4TpP3M2mO+O+kn 6JNP3qyCztcpMleIN8sNP9xZDOFrlS5IcgOiRaOFHgp9x8f/9MsqtNqwGbOlkguyR7al z+8W+YnGIeOlaaS/XVbePPPZ635EUSJh8RpUHfuzLtXTO08paReOaK5621+gi4wYGbrF J9p4EwgjgYYzx0zANCNC6D9W/5TWIgQ6VjVm4IsXU58QssAsuCLDTJVPsk7L4J6S70Bh T4dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723666682; x=1724271482; 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=ObSCoIKHR53RsBAjPImzvWTBDUOXW/cdZ+itJeFwmLI=; b=eVdRreDwwL0xCFhmjvOGNCLJSM8H3pRQroEYbzF+70KyLHXTIicDjMiq580TWn9JnK EZP4hX9hwFJfIYP2etiPziN0kWpoCqh1psuYM5+nfX1yNR9OdN7hn32fyu491XiP/A7P gkZHFbKSUL286/5xprx+eJ8bCh/mN/fq8C4T8jLm1K3O7LvhNWdRbRmjywKCVAyKkofM 2WDEuVJeyCfqgqdUiIXFNcGS5BjvZssZCD5xb6MiP8/QQTflJJesNBJPHlyh0YGhXtwI gm0KwSie4qW9RRVxcQnJfiZQgLf9ARDSaxr4V2yAHQQ61ItiFt4cQsIjCgNP1R5i7oeR zcvw== X-Forwarded-Encrypted: i=1; AJvYcCVdUMxCOK6R7fKI0zPhAuozvaDPdAJfsNs7QzXU/MlOzR8oNuWF5oGojoZKiW1sE4UvCNN8KT1FpaUtyDsEab98@lists.infradead.org X-Gm-Message-State: AOJu0Yznh2EQTcfsbtqvu7Bagt5B3QUqD8mlFRi+D+q5r5QoMOa3i21b srcoKXfQtFT+Cmv7uDcub+F5Evrnta0J/XQBGJbprvM6AChd3w2Tu8tAPJBzWdQ= X-Google-Smtp-Source: AGHT+IEjqXpjYet6ypGc802+q411OKw8d01xxmNltI0G2Yu9eqYwp/090Xmw263ZglHYyBOUSAWiig== X-Received: by 2002:a05:600c:4e8f:b0:426:55c4:ff34 with SMTP id 5b1f17b1804b1-429dd23b7ebmr25874885e9.15.1723666682300; Wed, 14 Aug 2024 13:18:02 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36e4ebd3631sm13623519f8f.110.2024.08.14.13.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 13:18:01 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 22:17:47 +0200 Subject: [PATCH 1/7] thermal: of: Use scoped device node handling to simplify of_find_trip_id() MIME-Version: 1.0 Message-Id: <20240814-b4-cleanup-h-of-node-put-thermal-v1-1-7a1381e1627e@linaro.org> References: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@linaro.org> In-Reply-To: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@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 X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1610; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=Jfl9CCDjoTMAykhligO10CdduRTjKmS0DGo6xlPScyg=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvRDww327vaCGWSmCQ5rATkIm5TMFxxObspRAg BwE3OcKQ1+JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr0Q8AAKCRDBN2bmhouD 10wNEACYQM02wcgcm6jW32tliH/1WiMeu85GF915kaNTEIw+b5lwNX8CD1OIwKt11RUVLIrxq2r fjTc4r7xwznphVHVZG0DtaMp4+nIxLeo7/odUs8f7rapwhtz+8PHbyAq5mEk6VTLjkq/5MQIChG 9CVFWkmuMj+cZL9nTtPPVITIUmuQDnslBlS27/vm5Jb2azkaZcg5dmgMj3QxGM9JyOfSuLhtqaX uF1wJBOafwHjG46OU/QvVVNGc7uZlBVpjRSI9L/ZZePiTcx7GhtK/GUm4w4WQpybcaJjQlmyghZ w91qS+XkrupTPhyZxQ2p0QBv0WBHH3eoeyP/LJO6AN0sRb87Lfifq7GyyVO1FA0+jOh+iYuRMiH sFid4KKB9Ahclv+XJHdCuXsUAULeU2SK3jtEiAx9fCrzqwNp7qyhGV0QqLAFQancLX1ZEdj31lt yxYCp4ee6/kKpcB3RHmdWZQUZ6X01FVavPeZIrIdyQrMQO+bv0a6zO3VAvD7pt6PqDPcSCgDejf vufLcOV3IRMZnObwPiw3RhlwrwMk+3FWdOKv1FmQtiAu7lD2PqMKUQPn/IozQAgXC+spvP3+90u 3+BjIpQ4YWpDdxbwdvZL+rXHD7KStxzwqih1EwGP5W7NYh27CP/zXW2AkupPw42+FWnuinaa5tq pIWUfWMRnZDMyEQ== 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-20240814_131804_686031_7BBD0720 X-CRM114-Status: GOOD ( 14.92 ) 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 and use scoped for_each_child_of_node_scoped() to reduce error handling in of_find_trip_id() and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Chen-Yu Tsai --- drivers/thermal/thermal_of.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 1f252692815a..a2278d4ad886 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -22,11 +23,9 @@ static int of_find_trip_id(struct device_node *np, struct device_node *trip) { - struct device_node *trips; - struct device_node *t; int i = 0; - 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 -EINVAL; @@ -35,20 +34,13 @@ static int of_find_trip_id(struct device_node *np, struct device_node *trip) /* * Find the trip id point associated with the cooling device map */ - for_each_child_of_node(trips, t) { - - if (t == trip) { - of_node_put(t); - goto out; - } + for_each_child_of_node_scoped(trips, t) { + if (t == trip) + return i; i++; } - i = -ENXIO; -out: - of_node_put(trips); - - return i; + return -ENXIO; } /* From patchwork Wed Aug 14 20:17:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763913 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 EFDA2C3DA4A for ; Wed, 14 Aug 2024 20:20:07 +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=++p+JxzQS5UPTkfx3ma3H7Ls6vAeOBS5jFyHbB6JISU=; b=MYJcRgQQnwQyVJQ3nB71ZD7xfs 1XMmqOtd+m3I9bQfkCkBbmM2jdO31++BdiIYIEAgvEjj369KVBPGi1crAv65SFXqLoConwV9FGE9o pfGK+JWTuYquW+jjTwfZcbha2Ouayv4LMT4HFl+EqUJJ/b12zrexU0ozzVIr7USxXOaevgnesP+VJ CrBQROOcCOo02ooFJHDTC0hifdP/UP/7dklsofXbsFcJWRGysmiu2sDnuQiRUTOCprKhESV0u6C92 WJmXuOMJYBnzw7PdR5cc3YGARn1PW5tMBXpVsPQZTBXnkJGFmBqlFaWVIouN/mkxcTX+8rimiGsw5 miQVA4Vg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seKTM-000000089ft-3udi; Wed, 14 Aug 2024 20:19:57 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seKRa-000000089Ft-2hM9 for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 20:18:07 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-429c4a4c6a8so1170705e9.0 for ; Wed, 14 Aug 2024 13:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723666685; x=1724271485; 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=++p+JxzQS5UPTkfx3ma3H7Ls6vAeOBS5jFyHbB6JISU=; b=t3Wzw+44/77XkKe+437ikSwvbrJdJiwwrt+OrbOPE+AQmVw9vCCO3x+5wUu/wl94qe T5Y7kfKqf46BoECiZZaOY1U/r7zVCBf6jyYqPH0bkSFljHx4Lwm5CPmuSx8VX8a1X6a5 xiRl97E/+YH3qWkaCo6yAi1QnuFcGPEvuj9YD+AQpPzZ3Qzvy269X9ftwcQqnKxLaRaY +NC4AQlS/gdS2AAOKI1RcYAmM86/7W6ehKRkbAmGNwy7Jxjxkd6DgGowbuk1U6Tn+V4e bEV51u8jZFhI9BaQj2y8RS0m1JpE3lUu6wZ+fVNVtZYTV81mmwOmn5AW3VJmq9M3O7xj TbPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723666685; x=1724271485; 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=++p+JxzQS5UPTkfx3ma3H7Ls6vAeOBS5jFyHbB6JISU=; b=BSMmyk1mNmfcnZO7KEdMXD/lYvQ94IWsv1aK4rUyCH35Oyd8EuS1a3j+rXg12dqwkI GECh0BugqhjEzy1ac7bCrOBFADyHKYpbKGg4Xl2FJyiM6Y8QNW/t95u/FyzZZMi2G4xL s5YshfKEgvrP+N50JvonyEsc8iyxMNm1Rtz2QjcLxn4hC197M8zl5iOxYOTk1C78HDkt NZQ9AA/VpI4gA/w81PiSxPXyyff3yI+WFQe6ZlWx8z3+rvize187S6E6ADOOm9ObRqxQ UJj/+yJAIAveST0hQI2COFC3fLAmKXk0AeetT6h1O5YqicS8c/Qpp3WYA4Gs0DsCjcPK t0tg== X-Forwarded-Encrypted: i=1; AJvYcCUy3UfTLtFKn3VEIkcjmnzhoP3yQHAuhYNZaEvo4fkauYWa4Z7Efa8m6qmkLmjorcpyr0DfgHTX+JSzdjcsL1WCS1ip9JDwmTTDPAHywW2N8MXsvFs= X-Gm-Message-State: AOJu0YxP7hDaajp8KfqUybDO84VjP/67+eFraToLYuUM1qZKdi/otFoF I0Pm512TcU4J6m3zTWsYLrw+SEBgoJoFS3e2OzVW5qvLiRkX1Qb2MLFboO5X7Oc= X-Google-Smtp-Source: AGHT+IGZiGFg5LA2lGJLTze5FU5Hft61dd3QE0hb8QyXPgP+/VawCBj27w0F0jk2ArjxvKBIS0JR2w== X-Received: by 2002:a05:600c:3c96:b0:426:6eae:6596 with SMTP id 5b1f17b1804b1-429dd264983mr25480435e9.25.1723666684504; Wed, 14 Aug 2024 13:18:04 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36e4ebd3631sm13623519f8f.110.2024.08.14.13.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 13:18:03 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 22:17:48 +0200 Subject: [PATCH 2/7] thermal: of: Use scoped device node handling to simplify thermal_of_trips_init() MIME-Version: 1.0 Message-Id: <20240814-b4-cleanup-h-of-node-put-thermal-v1-2-7a1381e1627e@linaro.org> References: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@linaro.org> In-Reply-To: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@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 X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1654; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=ACTPT/WKeh8vPrxZG+9k9m7syH9ZC+yY+13QhJEgNj0=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvRDx7NYdG6rXPPkRJrrDAHgRjoLKhzOmBCUbJ I8k1L+TZP6JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr0Q8QAKCRDBN2bmhouD 1wujEACJpmuU29GVP2zsxezI8prUfzlD7Dd1+Iqtv8zthOx8t2E5ZqFctpVVI+MKRT/R6mVKS// U4kJXFpNtgs4UEuc1kNVnl9nNX4jtvW24aQJmPkYMwlf9YBGuHWWYh/0LwjAla3bR7TQj3GpKGi cUKzjtiGHn/X/DsbY1vZNWYvLIxlf6liEtilmsZOJczvEQmxlyUrBaFhj4h7Etjgw6GvEiuBo6R +AUL0t1Ub4L+Da8vdWUd/DnOysxjTeDfAuY2gMpgRmfe4JFNF/BVhFc1ULBx9a373LNUvjlzI4v tzor1aruDD8jpccHc5jEEwsBifiYCavIf+/YwF4WYDV/JjoArEL0xavpKzdWaVsdEWBelvaFp2G Sz+7ZiUpDZQxiKiu5XYOPrUt/zBUb/Om88yNxspDCUFLpUB9tWapk2Bg5Dp1DjO7rtJxKrCwbKf FCU0iZo7E00Ibt8esX8i6IPfo96rrh2Uw43X3geCtY9zqA8hOWn/tZBiy0xxuNMOMR7MK7XYfK3 1TEQ7WkvZi+ytUQEEREOvCBUIcf8GOou/ALd+O5SFD4yFWBnqpR+mEYDvfOMLFFnrG9FvU2EfI2 ifFhHDDDczOFhS6oE3i1pHl7U3w1jzlco+CefAoXghMjvTE4xP3Pc9tGOmRp2XBFWnJVdizYn8r IJs7VOjqz7i23OA== 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-20240814_131806_718615_E6B7098E X-CRM114-Status: GOOD ( 13.17 ) 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. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Chen-Yu Tsai --- drivers/thermal/thermal_of.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index a2278d4ad886..c8ded4462bb8 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -117,10 +117,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); @@ -129,15 +128,12 @@ 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; - } + if (!tt) + return ERR_PTR(-ENOMEM); *ntrips = count; @@ -155,8 +151,6 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n out_kfree: kfree(tt); *ntrips = 0; -out_of_node_put: - of_node_put(trips); return ERR_PTR(ret); } From patchwork Wed Aug 14 20:17:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763914 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 E8CF4C3DA4A for ; Wed, 14 Aug 2024 20:20: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=9+1n3s2zX6xdpk3ZvL7MPliaB/tfVY+zMRhSsJd4xNI=; b=gbTnoojUEBUkkQN6Lq3KGq6xPu r/BM3QCNR02OowqC+TbB9SPszBm7B8KUBejBBcbTHr8JgW2tfNtu7P6xzImp+CDBhboAREL8CBSU7 nf0KK8g+NQjW2JQ4Ze/gKSZU3rrQIgxnV8jYbza+3B8KTu00/BjK2eQKidCwe9aU5+3QS9TsipxXD Tm8D8tvB89SXzcyJ+Te6A4EgrIfgjk15KUwmjQI9SUnrGOWJozmEQfQZqVK4XGkgqi3N+9xv8aL2u +CWFpkWwabMVa+sjQYPAJKKD1qCHHC96scsvl0uYYFqlOSG64k96yhX14QN9Yz7VSphzysATbXQ2h 0TFgSkRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seKTy-000000089qA-3d7Q; Wed, 14 Aug 2024 20:20:35 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seKRc-000000089GJ-2why for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 20:18:10 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-42812945633so1234725e9.0 for ; Wed, 14 Aug 2024 13:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723666687; x=1724271487; 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=9+1n3s2zX6xdpk3ZvL7MPliaB/tfVY+zMRhSsJd4xNI=; b=P2ucSV+nFoND+lWwQOc75PwZhVgNpZw/4sknnHXGN5qK9lyP5Vi1JmttXqij8s6+Ky UdBmgGUXjPCfCFotVMvTP0KoW9a+lih3Bk/mAb2qcb6/jL0/UfzMF826exxW7f6p8gip TGOVinDzJfcHCYNFzQddg8QEUExsAPLBA7NQjX9HcIUcOo2WrUt2+zqvO4fNXERcLVim 2pyClFpk5J8A1dkFuGcy4tb+BOwaIIh602pfryW+ouImRE94bg5QnDTyKhOznv8buxrG iLCC8nI0EbG7MYfJXNWWfBiGU17zGRtXAAOiNV1awMNjF2PVkHyRGssaFNzo6FTOgOlg 5xYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723666687; x=1724271487; 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=9+1n3s2zX6xdpk3ZvL7MPliaB/tfVY+zMRhSsJd4xNI=; b=DMWzDapSgyDOGNo8cYIXDvQvTRbyTFqg8IGTMkaposKGdq3TrnbmpRU8NYpW2XWlD+ TWq9Qp9iM+S6J5ewytHXuzlF7bF7SYVtCvufTp+gNfQahgGXG4H0+4vkj3zADhE9AgQY XC880wZYu8ScK6WrejqxEhO4Zf5o500SHBRJpT35dandj1RHfixhdZ5c+9WGsB/tPsB2 PQlOccZe6dn3sxZK3W8sRJ1/ywDVNoZVWTzAanRFzQKn2lGgYnzkE6tsKRWwz4czR6lz Pdcc1GYwIK4rEsNqjsiOlA9PPp5aAFcgvlOErc4tt4utdkiHUyZubRPjKz/cNtoVT3cp ZS/g== X-Forwarded-Encrypted: i=1; AJvYcCXm+NEF56S0C3B+bwOFy8UbpRC2C5zFJhScrZFLDFzNkn94li9a68tmIBmXmcKIXqQELNf9zWlp8TQzqxfd5tl8kDxDzr/2jfbY+MLFPmpDfDzbQV0= X-Gm-Message-State: AOJu0YzKz0IuWZdyuWHbylFtWRJK2crcdGHer/LD4ygWodOXyEQTQDhW V95OmNk9ciYzalpRTTlO3WiWQan4Ww1flmhxbZMRtPDkvP9erOG7WBBZoGhNUAI= X-Google-Smtp-Source: AGHT+IG4n49tsrR8OScJpRN4XgsLTLCrIDbgTVWLA8e+VO71vcZPvFOel1WkxQ1/4c3HXHM1sPIv4Q== X-Received: by 2002:a05:600c:190e:b0:428:16a0:1c3f with SMTP id 5b1f17b1804b1-429dd26c6femr30355955e9.32.1723666686643; Wed, 14 Aug 2024 13:18:06 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36e4ebd3631sm13623519f8f.110.2024.08.14.13.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 13:18:05 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 22:17:49 +0200 Subject: [PATCH 3/7] thermal: of: Use scoped device node handling to simplify of_thermal_zone_find() MIME-Version: 1.0 Message-Id: <20240814-b4-cleanup-h-of-node-put-thermal-v1-3-7a1381e1627e@linaro.org> References: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@linaro.org> In-Reply-To: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@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 X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2259; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=RFZ0W2aEzyo7qvNEznMOi4x7fvkwhw23R+553GKFwnw=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvRDy3q5OsepdeTfJJj9k6orTJGFRZF1/guOFd aYAeE2h9VWJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr0Q8gAKCRDBN2bmhouD 16ikD/sECNu5Kif9arWPRp0ZjOFAoqw/OIPurO5nyDcAb4WtSdbBmVnN6r+KS2TP+ILKGjRq4oh VVSiUMTzNLwVW6Nh22aHCvNpyodqWXR/zo82WBkPtT34PcjtA9OKGIz72Hf5wfVz42KQ483hYbr S7N0vN+kleySjh8OWCjgTREDkqk/00eo4TCMYF/pX2g2Bb/eochwYx2MxCNYYS15T+i/U+FiY1P sjA6z2+z7VyviQZbpo5AKZouIOohnijofx6UdTN3Xu941ch++gGQMSC8n7VL52pxTObRNxxMDJA lMsXzE7yMBFQIHGNkwC0wgYBDxGNM9TaRhpPan/h7X/VYSbHzRejqFQVqOu+q7m7R9fG/DVY9Yx sZcdf7HcZpFDBA7AH7jWr/EU7v1nUk5MbEKIJNnjV9qNri8i89WSb1CY4NPV23rafSoYN+BhBtc DPs13bbm+z+Q7o7MP0kQcGDAdDi9fDtaYl4rRQ8npLjnEjMrCFYYWRP54xSMxs4bVB9enR8q/77 rvZu6pPSz7wu9g3zKZvEiDjF7o79+r43pdtO/aIShlIN1EhowovcFj/4/DsgWx1DCgBxXvo4TT1 B5hzPDMtS73OAlAvXbYJCF30OQsHP5LQ8G23DG5YzvVVUPp8MLTJuYjE2aGcTXEry3sfO44tyWz sd6moH6jSSfdxiQ== 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-20240814_131808_782578_13E888DC X-CRM114-Status: GOOD ( 13.86 ) 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. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Chen-Yu Tsai --- This depends on my earlier fixes: https://lore.kernel.org/all/20240814195823.437597-1-krzysztof.kozlowski@linaro.org/ --- 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 c8ded4462bb8..fb5472d6ffea 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -157,10 +157,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); @@ -178,8 +177,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++) { @@ -191,22 +189,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 Wed Aug 14 20:17:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763915 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 DFB31C52D7F for ; Wed, 14 Aug 2024 20:21:21 +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=DYAN8fXpIDX9+PSKUATbbwS0hbvD/LD3aOg31XZDMpo=; b=Fn8HPsjG9VwOGoaUl+wyFeO8Zl L1RKS2XWrajmtyMhZ4SINORiVsFseff+fj435d92oaV1FAvOxA+ohAs9uE59h5LEP7T+emVcxoF/k FUd4Bn0bmJtImU5cU0ewJZs4rytWyNilAvfNuATX1luMHXufmVHxO4CuaLPuG42qqH5TfikBTWxUs zfdcsLNpWPZJEItcHfOU8cr5Iudfkaam7kJV++5MXwaN38fsPs7lmb6CN8059ovmf3m2xjCMN7JUN HXxxFZoE8ZGCDZfTXrrpZY10fRWjzXc/RdYPdNlYgX0Y9QxVmfc+vNRZkBz0uZQifx0IwNpTAtKEs +Wjgw3zA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seKUZ-000000089xt-2qCS; Wed, 14 Aug 2024 20:21:12 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seKRe-000000089Gf-2KfH for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 20:18:11 +0000 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-368440b073bso135965f8f.0 for ; Wed, 14 Aug 2024 13:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723666688; x=1724271488; 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=DYAN8fXpIDX9+PSKUATbbwS0hbvD/LD3aOg31XZDMpo=; b=zFxkHxKRQcXOw/SHzfpeefCB6we2/XaDNnjIPPxqteBx1cMEBJetUWyaJI2VlyEiUv 5OUc2fIF+Ror5z7y4vDnuwlhSTRqSOQxyGE6c7CGt/WMtpPne+FBj7iubHmG2hD9t1qv PLIvq0bQS5V3gGOZkoon3UgJf8weYF8IZz/HJEE93sWqkNXFHN0RlRpN/uF9JoR2qqQl 3ZC+RF62vdKFPhevCQNAaDHeQxbXzd7z/iY/Asd98UT4vqjw5tTe1ulnQXcR9dKFELaQ 5tnq0PrlvNYHc5tJ33Mqrxz4gGDXolEA2ECQIFpIzZBsjy38JAMYVH0+lmmIscso2pBN U4tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723666688; x=1724271488; 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=DYAN8fXpIDX9+PSKUATbbwS0hbvD/LD3aOg31XZDMpo=; b=wWzY04gqJzypIbwe6+PEq27p1H43TC9KeBMip4p7VzIctGCLsfDsSMO13exyhzMDhV 4ae2C3UTZ7bi9WRD/9U44x2T6u6ZYiA+Pw4ruoqS/yX2bB3aPbQLwGqmfNx099G1xgO4 kZ9FoyvYBTQS3GCf0fLP38XrZVbcv0lDKVH+zwGk33e/ySQNSJEMH1EE3I/xdDWN+qgW JQdif6ES7kmHjUWMqr8hQPR5NLnoII11ePbpkP/3KY2QfHK/Yxr+Fl8Fq7mE4PyRmdCy cSOZKTVSQGE5pqO9hci/xLgz9aVmb6xr1TkuJrb/6ea8o0sQUCcN7ZLWlde/EAVOWusw te0A== X-Forwarded-Encrypted: i=1; AJvYcCVgxo9nm9j1fp3fRxmSOWczx/4KU2WP4z6rnIg4xn1I8S7SnNho6L+yPPz9VJwS8cAPsiXh4CTdPInl+iuCxHh34Mer69NGIawgfstWVjoN6fl0t4E= X-Gm-Message-State: AOJu0YxYP6wmJ2/Ms3caE0ebb0uEJ/e5lYC7AWQOcxTRpQG0gCSkFoWP 6qGomjhTOtLxo9FJZoOfW6HSPsH1+FCXBTipi4JsE+OZnoc7K6JZU5+8jYsDR4U= X-Google-Smtp-Source: AGHT+IGmwY3kKAsbbIqdA1Qy/7Y86HNZhbTxTi95aWs5EkZQvNUDlulFUHDoGmkvah5120zCV84YGw== X-Received: by 2002:a5d:6405:0:b0:366:f455:e7c1 with SMTP id ffacd0b85a97d-37186c16564mr443264f8f.27.1723666688344; Wed, 14 Aug 2024 13:18:08 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36e4ebd3631sm13623519f8f.110.2024.08.14.13.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 13:18:07 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 22:17:50 +0200 Subject: [PATCH 4/7] thermal: of: Simplify thermal_of_for_each_cooling_maps() with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240814-b4-cleanup-h-of-node-put-thermal-v1-4-7a1381e1627e@linaro.org> References: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@linaro.org> In-Reply-To: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@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 X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1262; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=M6Xota0thM0mYn1zZ6Ux2xxXCKU4Y7eLR8l8l/rV8NM=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvRDzIdQaQJ8rUf7OgqZtPMHSf44hK/AD4TH4z 9HLy982xDCJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr0Q8wAKCRDBN2bmhouD 15CEEACH9zSrwPulXXxTiZk/Lc++xQoUbUrbSH83B4cknQVxa+LCM48SUEiW4GBIg1S/iEBT6/w a1dB468nxbZGX/EYemdV+u8JHk+2smNdmdxPeoyAStQxxfT5kHbjXz3hcBnWm0U6zCO1D6Xaa7H PYh8o3kq/rSVm67163yZlcm8uKq1C1BFHh8SzSo29rbTI7iUp6NlTTQ9slD9tS7q7dIWPnKtKxl CYhQVUe5uVx6abJavCp39qYant3rSvcrhwRvGLSmR6V3nofw543wFbRRkTS67CzCzPMr6zsoLAl 8ut5Nl+lGcRMcJhBQ7Sz532SI1z8WkgjkGG2pAGMedOeheZfCyRblUjejNGbZ5wEmaT/7bBLRjH hj8zLmIJLBF0VHV9/drTre03SBL5lfQGQss4QC+8SX9+PCpunnHUyh+5kKb6nO9pFXC4LP2KkpY z/xWltIXUXWJL/PSthxrDEwfg8IJrZOtnYIAw1dMYHdi/yCReViWn7j2+SmRYVHW3vYIlKrqsNf fUPDZEr3gRPsn/tUkM2mCJ2f50PoHifBu7szVGKuFt9fplMx0PvQbc5jHts9l9Kw5jlAYMea6X1 TUsfqajTEUkIWJs/J9rsoifr+hkFtcInxNRemFo1aLAf3qylMzUL/zjMsy+mpIWmwNfAAEDbzO1 vLQoWPt6VIWhhJQ== 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-20240814_131810_628748_CF3CC78E X-CRM114-Status: GOOD ( 12.86 ) 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. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Chen-Yu Tsai --- drivers/thermal/thermal_of.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index fb5472d6ffea..d277165746d5 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -375,7 +375,7 @@ static int thermal_of_for_each_cooling_maps(struct thermal_zone_device *tz, int (*action)(struct device_node *, int, int, struct thermal_zone_device *, struct thermal_cooling_device *)) { - struct device_node *tz_np, *cm_np, *child; + struct device_node *tz_np, *cm_np; int ret = 0; tz_np = thermal_of_zone_get_by_name(tz); @@ -388,12 +388,10 @@ static int thermal_of_for_each_cooling_maps(struct thermal_zone_device *tz, if (!cm_np) goto out; - for_each_child_of_node(cm_np, child) { + for_each_child_of_node_scoped(cm_np, child) { ret = thermal_of_for_each_cooling_device(tz_np, child, tz, cdev, action); - if (ret) { - of_node_put(child); + if (ret) break; - } } of_node_put(cm_np); From patchwork Wed Aug 14 20:17:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763924 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 63850C3DA4A for ; Wed, 14 Aug 2024 20:22:00 +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=iS8jaBQ+XPS+HrSzqaFJuxj2Miuibr1hkk4HXdd8vis=; b=pwyhLE6q6HygPZCrvrOW64x1u6 nkiVbVDlFnZoOYAje70spg05toiTeGSI9PbsTeJx4l806DORu7qo4xHrB8U0lM4XF+R4fXIQ2VrXP aNyBLyIz40FQncqEBWKYRyu9sI494IKn2goI7Z/8X4mBazffdwc/TOEhkq67OvCHiihm9mpS5uiwM 1x/n/3Pp7HONPFRH++XkQhSA1DCmr+jLsBjzq6n+Um+18AxK0MXTjk8hUt8jD8b+f0vSLICSMIOeN 32zquNjtRS4ssxba5W8uEonpxZiPY2lE9kHxOmuWcMEvX3z6stRohHt7chXHV/iRmAiXRNXSCSwvs HSDLn0sA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seKVB-00000008A37-0SWI; Wed, 14 Aug 2024 20:21:49 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seKRf-000000089Go-2UQV for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 20:18:13 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-428e3129851so1041795e9.3 for ; Wed, 14 Aug 2024 13:18:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723666690; x=1724271490; 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=iS8jaBQ+XPS+HrSzqaFJuxj2Miuibr1hkk4HXdd8vis=; b=Da+BIm0/Yvjjbg8ftG3UroOqnwwY7Pq5Zp00d+QcmA8LfNNXqfSWexthAVEBak7X+H wt0HeUE4jxL4YjSRqn46fi9cXhE9fksbsFwICFTbc573godTr+kq3xDkBuBraaZMK+c3 1UOk5jO6fCffqIdBPV7A706+jOTwV6ev6kZ+7+xKwIFPqXNdu7HXfR4/QBTulqdDqJX/ NH+AGeUg+SBYANLsv2T3phSpwAVFX8dvW6MXHHrJBe+oDOafMWHgGlU1x5Rt+ta5ZL2k OG+y/2rpiis9ByGEbUXHoLIdTsEYbEl6emvJ0LBLXRoWPO4NjS2ukiO01QgLUuno7+Ya Z6uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723666690; x=1724271490; 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=iS8jaBQ+XPS+HrSzqaFJuxj2Miuibr1hkk4HXdd8vis=; b=chGzDt1nt4UeR4RgZqvo6Xb6oLnhvoR0ABmaKHylaqK/Q0IJGpfiT+156MyUAPcyOQ xuy3Xs4vDPrzrcoD61DFMfGusdG5JiqYruHBUaSN8jpLCguUAsnMgw6BPsfb5ovrI7Hj MxrEdLOybeu5IrZ7tViOo1+X55XBimo34CIJxJL9W3s4MO1UExNrg3K/m4jIdi7Hp9kq NAtOZxaaRqVKpAR+fqf9EjKOsXAhAQgjaaI19w11De696J8ySzCA7QFCobqqu0C9rcIW bk1CkCGOESCawhGb0EwTLcAo4RKlqs61Fi4TwehtMqFzpoF+xbU+Crkadq5LawgTTIKW l1LQ== X-Forwarded-Encrypted: i=1; AJvYcCWAa0WIvbbRW5FSQ1Lk/D4fOJ1tiAhvmrroL3SB77NELInls2FoR+r2yCQcF15KbE8QFdmv1S5OrEAw25lwUpDRa0qZZdcZ9mpLwHjvjZ/2mXgIAP4= X-Gm-Message-State: AOJu0Yy6vFSrLqrxUU9H4jJGZX+300SFKb89qpAjKxkJHyR+FsYlhYqc Lpf4tmy6L56jPqA5AW5hi+NaIiU7cJdHS9Q4/LGR9+9Jvg3r6LcrggwSuD5YOtE= X-Google-Smtp-Source: AGHT+IFsLMIyu4uFm0/1NmefGh3pTOjHspg7ni39a5RRrIULetCOqFEEtE6l7XZ/TGGxfp+c31PvHw== X-Received: by 2002:adf:f341:0:b0:367:98e6:2a1b with SMTP id ffacd0b85a97d-3717775ed3fmr2326419f8f.4.1723666689920; Wed, 14 Aug 2024 13:18:09 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36e4ebd3631sm13623519f8f.110.2024.08.14.13.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 13:18:09 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 22:17:51 +0200 Subject: [PATCH 5/7] thermal: qcom-spmi-adc-tm5: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240814-b4-cleanup-h-of-node-put-thermal-v1-5-7a1381e1627e@linaro.org> References: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@linaro.org> In-Reply-To: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@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 X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1285; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=2Ohf+Waz1Uv9wtQt31iPhyooUXS97YnL8KjoPlEF1Fw=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvRDz4gsbX2oJh3LGRuALE91k2eaHcfy8c0zAl +KSZZ6MB5yJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr0Q8wAKCRDBN2bmhouD 12jvD/4vU8Pg3N25/ox/QWe50Am5C8y6qF9U2XuADTIEwRHGA1yeXaB2aQoyiOJpuu2/tFOj9Ng NFgeHa27zgl8O8Lm3gV+/0B0cpPv6BSTUlbscVbe0RZmZmfjPNu8j2SlVe1DT+cVujUocxUVRio nwE5QJHIHEhlJVIilweu7hT1loUd6XrsYg6Mu+54wbp2ew33JMGG/69C5FZau5sbIgIL2MUPWve yhuuCdl1K9adE6TzmiRrZenA8oWJH+Whj59x86R8gwlgCZCu2J4ErN4eS13wJOTWNtA5XqPkGV+ 8jfT6359HEESKIsgjIwE8qs5mac9oMgiwgkwqSXA8hXT3rrHAY71npS9ocSWp/4XUJy+Rp/Z1A8 UeprbsR04p/SgeQIMp5OAPkx5SVGO9h4P/VXnirEkIT89UM9+CqHSnf+Gz2bMEJ274MaE+9JCdK V0RYrvP2VUCmhrS1PsGNLhwhINe0/Ac7fugRryhBu/in7dt4McyJjxrxz1/jxsMgXx52xPINCs8 +RkotbesbQXqKl9pUHqaCDFuZIIgiWJa0D65disgmxhdxzDqklCNkP+w8mLcHn0pe0AgTIuhfzS nqrbxvcTPblQy1+Qvj56I3UFoRZOXxEp3+qoqXCxM1Fn85YM9qq8YSoAS1ENjFscfm6Edqm7qrR A6oUV4OvIB44QRw== 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-20240814_131811_673815_7F08C61B X-CRM114-Status: GOOD ( 13.02 ) 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. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Chen-Yu Tsai --- 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 7c9f4023babc..19cdb98c310e 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 Wed Aug 14 20:17:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763925 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 0BE9DC52D7F for ; Wed, 14 Aug 2024 20:22: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=xkjRZzLoJToCwZbViB8DmZ/xiQRM8hrpZD3XvSuNVwg=; b=ebMGlwtrEDTjL/HEzJk55jJiLP kq5zGrWI3BO71cKxL52cv3ZZ5/CUn99/DKgOae3x6z21E2dlSVMYqv0eMqAHtcQUg4PcRepg/bgp8 VbNABYMhxIhPLEkFI2i2xFvUge6KWv8jARC92BjRCRwTlkNP/oLOqZwig2eQvt9zkR1/1olPNIlqy gkHa4vjCp6xXprya+xj8i3EVNXDfGbz1YS9aow+jHZRHzFxdxUHQkOjwvd6sB8YcZYApDujWW9ugL xWEVkGUkdQgyJV+gwB+M5n84GkJqHMpsgaQM3MyRxLvusNmxeoHiZj9dQBrvgiQhj6yAx6cVK6BoT sJx5y2hg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seKVl-00000008AAI-3LTM; Wed, 14 Aug 2024 20:22:25 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seKRj-000000089HQ-0LVB for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 20:18:16 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-52efd08e6d9so283821e87.1 for ; Wed, 14 Aug 2024 13:18:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723666692; x=1724271492; 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=xkjRZzLoJToCwZbViB8DmZ/xiQRM8hrpZD3XvSuNVwg=; b=lSk2diLNnhXIlB01RdOy6790AJJG78+Q1XHXe0TIAFlyS5ILuh1apzAOlJTsHLoynE Q01kFLF3JxgK3AXhqNb6BDzfOrQvSOZHJUdoCIzvSyxw6ZDZk4QI1jQpSbkARoPlbsBv Dd2/3CtyNspsr6iPTTtawDQsep3lG1P3AWAYP6i/u0X5uahKNd6BScg970Dwzw8f+brj FNN4kasgwCT+x4ck4p1PdrUj1/AFsmaVSefd7EiCdc32iq8zdMb7J/FlQHbUcNDVhNcL 5d8Bl9FqrReat0RAOWWu9a4M9E3HBNP7R5FB7VQ1eHgP1XoaBAnsLY4poI7t5R3LVyZb X8tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723666692; x=1724271492; 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=xkjRZzLoJToCwZbViB8DmZ/xiQRM8hrpZD3XvSuNVwg=; b=kgIKkhN8j3m6KUZ4jY4mHNL+2eSjk38vG7//aQD9NJxdd6FnKyve8t5w7r/akBUp26 T8PZE00FWLJfBu9Wc4SBSc9xbXRF/h5MNwuYo/0ZT4+Y0mFTFVd5XfI4Cr0ZaxlN5QU8 YrobYx2EBSnWNslzKsZE0M7tZwkERuIdo634N7DAjR8OPwlOKF3JFJiZZK1HAJj0bKq/ QeFR62tjzDEggJXEgbpSEhKgtp+r2jTT1u++BxPfwDC9s3c3B6Jq4OfJPUnjPwHL7La+ 3xCcFUDoRevk+w9TOUW8q6r/zyTJ31cuBjm1B/cKxo+yzvgiCdF4U25qCK/BY8hKJ+2c bIpw== X-Forwarded-Encrypted: i=1; AJvYcCXxtpd9mEWz6XO4H/36P+rfP3ni6Eb81Th+hcoJw00qgQ03fFBb57aIt4NwnZnwNwI0GRH9OHw/ZL3ac008/zkxws2Y9sv+42ESZAUvPAA9sLt44cg= X-Gm-Message-State: AOJu0YxoC3CQqt7x+4qbvwb8DPdNcaRoWEkHZp9mZBnbBhsMLwZUc2mb W7a6n4yQQ5tc6ttVuGLP++Q8U7MDxbaFbCELW55OKQLOXfJV+xu7FUWN7EE2T5M= X-Google-Smtp-Source: AGHT+IFBLTnGcya0gyF2QoAkwGE5TeVPZhJdxyZd9UXhkVvIm94NnLeJ+A7P0NhL9HSJ7hPR3FSg7g== X-Received: by 2002:a05:6512:401f:b0:52c:daa7:8975 with SMTP id 2adb3069b0e04-532eda6bdbbmr2880373e87.18.1723666691633; Wed, 14 Aug 2024 13:18:11 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36e4ebd3631sm13623519f8f.110.2024.08.14.13.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 13:18:11 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 22:17:52 +0200 Subject: [PATCH 6/7] thermal: tegra: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240814-b4-cleanup-h-of-node-put-thermal-v1-6-7a1381e1627e@linaro.org> References: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@linaro.org> In-Reply-To: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@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 X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1312; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=YQ77G+F6IdQNQWI9oMD9x5sylTEBbYeJ2k7ilgFPfQ8=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvRD0Uv2gIpoxw3AgnRAtAC5oTD5MfWuAAy6MR qcBoFqy1iuJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr0Q9AAKCRDBN2bmhouD 19dHD/9eRslHl0yrXWMvonXIYEU5aEQSHMM0XgCRLTnVked6pf6HwBPQGeyaYpOayo+jBu1YaoN 9ggsn1t9lMMffIn1oBi2S4rrPBhHyyP8UrDhJDupL792vu/KFAs6/HLUK4ah9609D95mfv2ePtB 8XpC/8F6zROMEiF2VgkadRRC3JMHdQJuaALjSa1wkq6ZSdlnVgR6FNjrqcxyZvfT/vALKcWg0fP eJVPuxGSWYsM+eNaKHOSXQxmiPIl5aPLX9WNF8AarOA0QcE9ZespUnNU7zVt7H5Vd6oub82wQKS CPfDaz04mWXZGKo8SDcQiv1rIH5i9tVBVD45rhfVf+p6W9xrgtpM9R5nRiOp3l8ZlYUmjFOeKba 1VCvSMI/+FS79wS9DXlucXO2rLT/R00sYiw0/LZxfYYV4Fa/qiv1cMojSs8q1UBlrL2FU1afl4L /Mhsk+jpNgxZ6BurlyqyuTwF8m51/MAFUpqtJg3iETODr9Wr37h2CYbY6tN+TR/vzps87QYhXeL +bGDk90v/GXw/rApcyVhu4R9TBqQ4eaz5GwGMwrv8XnmIgTevChp5lW/X8s6JFqHf1lXbZsGeXi nYNqRcsj4LaLtiQkubKHuD3DD2Hu/geb+8TeewAzL0k5u1j7nPgeScyABlkiPWJime+1PMpB3La nRb2h2ztHHppy6w== 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-20240814_131815_175778_F1969176 X-CRM114-Status: GOOD ( 12.48 ) 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. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Chen-Yu Tsai --- 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 a023c948afbd..ff4eedb553fb 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 Wed Aug 14 20:17:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763926 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 099B7C3DA4A for ; Wed, 14 Aug 2024 20:23:14 +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=KkMza/iQJ0QUiOTZWS7zmA9N7fZVP+GD4cxhszqTjVw=; b=aV/mN5AdirT5EKFmIZmfNqcNSZ NUYJHYS5mnNIqvcgRZxJfjpsr8zn5v0vuRfyN7nMwSYYosN/PO5fDbCPYIGdCWztueVziB5iV8A8f x921bC93lTDdTQb2q4gk1jQW8qzziysYJbnlDHCwOq0UatCRB4Bgo4P8ep9s/5PQc026ZFBb0vh1+ yVuZ3GeXXlEKm+3t3BOApTqAqgiS9Omvt3fGrRyaDtcT1c2DSe5tLfMGjVwPkhvSgu31SW3AVaCOl aKuqtLe9x0819iTLqEKWI6WQpidhlK7M/F0J8iAabKM81DlwYm41jHQVG8MEUgnhvPrDVAUV4eJ7b tfhkTbJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seKWM-00000008ALu-2u9U; Wed, 14 Aug 2024 20:23:02 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seKRj-000000089HU-2448 for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 20:18:17 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-428e3129851so1041915e9.3 for ; Wed, 14 Aug 2024 13:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723666693; x=1724271493; 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=KkMza/iQJ0QUiOTZWS7zmA9N7fZVP+GD4cxhszqTjVw=; b=ZijgVFOkLud5Ic3MotE7OV3I3oP6A6Om/5k7jvnhbfAnPjti5CL2GW4/BLRKtZlduL Lh+vhv2ywh1I92ZxE7YNE1Vt3jIsgWqvZZCAtwuoS71EU/EsNjbCnUrWJQIDAtf2MrlK efUD3iGhloDOpcyRq+Y5eFzfBpmq8mCX+YTL53/ku0bdisstE/7OxdC60Mf5ZeRyObMk HLKOPlM0hTpVZsogd+tP49UTWHBvjkmHDrjvFFhVbF24nBLAeOZTgPzKnnrCD1XCWy+N Jt/SJ08lucpHBWzsKCUuRbsioK3XyIXxOe7pUmFx0R9fMU46/POIxzUOlkGtYxnPfdMW Ep9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723666693; x=1724271493; 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=KkMza/iQJ0QUiOTZWS7zmA9N7fZVP+GD4cxhszqTjVw=; b=avrzQUy2bf8RCWKmDXG9v7c9FqVZjQHP0lgR5u3CaXVCu8TwAwJyVr3R2znR/ubR7v kJkmIXy7hYhQMhiprWCRRYz25bE6fTMsR/AWkzI+LG92pPqe1RdkC3+JaJ2ogFjzraE4 NNd7BnWjNelns8dUHqtGRrW1CIkv6QSsfkuCoMKWJvYIuLINSiNv17I/Q+mvgpAmcb2v oMuyyeVmMoR66cqDKE/AN9TGFinxbUokKLozjouN4cVIuR8RCw2ZsPI85jwoY6MJrxa+ 3NGVQ09TLU5RQgOX2z4bZ9hF44mCOOE3U76/rC84MrLfEgeQ5HDQetU9ytncoX3xaQVQ tVvg== X-Forwarded-Encrypted: i=1; AJvYcCU748aV2NZS+1HuoDFNQdLIzD9olynkjexnWYdJnCZj2tcalzfgNXdYL18c+EGI2YCe9mIG5uwvtvmnluHOT211SCvk6SqIM8DvixEY/DgSnBLY+Hg= X-Gm-Message-State: AOJu0YzYVCNgdZGOCNey/HCLbzgUwjv+K3K+2zNXHkURX0LHVGMiaScL Lum445yJJB6FbzjnhsLxYsNgeh2U87nb498ltGR3Desh4m8KgExoYgw5monwg6M= X-Google-Smtp-Source: AGHT+IGnTWLywH9MaoyhJRh9e6rqTQpuA5DArTXIC0CU3PtawcT4ViUxduJrjccfNP+6pW3j7swlVg== X-Received: by 2002:adf:e702:0:b0:369:ba89:a577 with SMTP id ffacd0b85a97d-371777b1bd1mr2864629f8f.34.1723666693157; Wed, 14 Aug 2024 13:18:13 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36e4ebd3631sm13623519f8f.110.2024.08.14.13.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 13:18:12 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 22:17:53 +0200 Subject: [PATCH 7/7] thermal: sun8i: Use scoped device node handling to simplify error paths MIME-Version: 1.0 Message-Id: <20240814-b4-cleanup-h-of-node-put-thermal-v1-7-7a1381e1627e@linaro.org> References: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@linaro.org> In-Reply-To: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@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 X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1690; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=qjB1r7xWZkiqepaZBKt71uec8dzopsPxrHTPtf78T+A=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvRD1tu+OfU0AIMkIy7rwyVDG9h4CyZBJq2lx9 T9f0OzUoMWJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr0Q9QAKCRDBN2bmhouD 1+c6D/9L71ii7X8SXP+hER4rvtyMdzBnxiA9V6HcUp4+DoljLDog0tR7F9bq8L6vfBfgJrUClwB l1BVN5h89/Nq0ZXHFkTZysFdiBmTrSUJiaCbHRhA8EEEGmxZVyARP6yTAOxy5nSIP3RapG0kZPa sCn1XVWO6zFIg3hYsZga906bNygVn+vaw1eSkNWmdj1IyNlvXGoyncGt4gGBHszuA3V7NUwplXL xUFYvwGZoE6MDswhKkYs2Mzd/2444ochaXS8mooZDTpOefionTRgovxfXlcAoi+qGsdmEPe3WPG uumzRLm4iwQ4aUkhVSygpRVh9eK0Qt+adknlmqWQROyiW7i1rdhF5jkzVwONHNolQDQjUhp+qfV WAXfmTI1sx2pPmSgEtrnmvJCz7z+6qxfDxXqnzcMluf2pZjn6GMyh6zcmimIDnlfRgi+lf84E12 IMmZ7UEX7spYVxwaTsWizJd10bPP8LPk3tQiwBy7LrZ27d8NLlrb7LJbPp4ukO4P4jPCRrr1s1R E0D0QDeC9mZNZrhwTx+GSfood/gTRLj55h3tz78QkMXT9jMkWPnF8MYMXWbWpDbez5q+Ibb/L1x FomdxaFfQIkSN3Q6NRtv78555UJxK6REVC8guvyyfhFFFu5fI/+AnnVGddvsx8vv9gUrEVgoAr/ 8szxukJ5Iy1aydg== 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-20240814_131815_587158_03E0BB5D X-CRM114-Status: GOOD ( 14.43 ) 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. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Chen-Yu Tsai --- 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 3203d8bd13a8..22674790629a 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; }