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); }