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: 819324 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AE971C2321 for ; Wed, 14 Aug 2024 20:18:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723666686; cv=none; b=A3drHiQY35idORgYcuXATslXkM6MmdzXkpFlolth//J360vJwlarH6QzjdoP/53I+77l9tdISkfrgHyC5Qza8GLI5xlSdwSiO8AEAzUIbUV/lj4k43MTMllTgQoB+Y/VP7hBPyLUYAS1gXD+BG4NtGUBdtiSmOqWNolTSCmb7TA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723666686; c=relaxed/simple; bh=Jfl9CCDjoTMAykhligO10CdduRTjKmS0DGo6xlPScyg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=r7QCg7FaEYPnBhOdcQpQasUvPhFjvxK/+7dHF5qlGGyAHQO5YVKz2kUJf+WX/X3Gi6ZPQbDXbHirNbGwm+3mJDprKWkd6EeiUoziub6AHhOu7F+VAgiJMSYOK887kyz759vLUdhnzKpjqVWahEfw4z0td3ZkQugvCWoBHzeb6Qw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ve2o9I55; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ve2o9I55" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4280bca3960so1098525e9.3 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=vger.kernel.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=ve2o9I55gH0kUVjpF8TLMxc/sUWRd9OvMkI52fKkKT1XjjIbFUYCiAtABVV6S9KT29 Grzbb9G772GMMZ0N2DdokcTT2X7wnJXwwp0xPjwI8Dkr57RG8Nu9gYTU6gYQ4EqGTrkm /B7LWj/TrRmpTmhENmAmaxSYT0j+ESNPoaph0RHBm+KgWZpP8Rxg1ttUA+TTyCQGqrYq qGUhVa9ZQXsqbMET5rUHmxpHoER01XE2lopVOtkYfbCqgMMq8Oh/wH3+iVQsrorj3bTf BVnDW0Wh1muRRdLAlnb4Z9UhdZpMZjYtdkYc1sPUGqqu/+HbaaH8V69IEqpUoElt5Enr 1msA== 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=qBP52Mrn6enW9V5FWAhY3XXx5uG3Qf7sSb/p1ewHB8QcifB36fSwcsIP4etxtLrSfu rJUkGnAJJ3gspvI7e8nzvAy6q1dOr8Pan+yw2penP3mVoUMH4QhHjx4Z63XEI4d85/fw /taK7hMdIxfZhm3BN7tWW/8lNh57J3XJLgE5lTL9wdP1KPTQ2FqY+G4yXc29H/lU0tWH BqTYA6I/dg7uS/yGN4LllRQi+h6fo9EhcU0T/xp5bJC+RQmyX85qKlnSfFVhULnLSXFI IewhzCm+vyVe7nrgheDn/CsdwiPu2QsGrPIlbGLLFCBJyrImOVeAZIKrEwEE599dK4qZ ReiA== X-Gm-Message-State: AOJu0YyIYVXxerJvVtuJiz4yskb9aVBkWG7pUR3Pq0Nu4iVYj9qnOZ2s 1Ni2EWrxlXQ+J83jI9rAGayQgzWiND96k+nTNgpNutHXQJ3ttpiflMw8NMgPPXg= 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() Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 819980 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3836B1C3F3B for ; Wed, 14 Aug 2024 20:18:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723666687; cv=none; b=DNSjrNk6bIsk4WchjBTYcVIUm9+Iq+Ekn80277K0ZGdZyL41vbpIltcUibNZ2ano9Rflrr6bMezAjqGPS3oVsFuwftllKXqtZo4LnVR58d6W/N7QkJwWM5MrGOyRfiQz8J+wTmGU/v2DvSEn0ET2/FCmx8q0OFAtM6BQyF4gvSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723666687; c=relaxed/simple; bh=ACTPT/WKeh8vPrxZG+9k9m7syH9ZC+yY+13QhJEgNj0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WA020jLp4Y9vnwx393LX/BciYi4XykhhgYLWQaeC9W6DM8V+0tP1dbfT6I1MaaJvLH2I9qOBq/Ij9pe+Ardat9mSXouwIiGvKJThud51TkA3UkkuY8wXv7qn0FlegIRuYSm8dKrh8xQKYw1/A3J/DjNXnTAs3PDdIcKdDLmwvCk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=E9W6aCqk; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="E9W6aCqk" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-42816ca797fso1052365e9.2 for ; Wed, 14 Aug 2024 13:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723666685; x=1724271485; darn=vger.kernel.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=E9W6aCqkGZEm0RfP6TgcCoU4LhrUvca1IrM/R7EsKzXNflgMUHpXyOHaGzHAmh+5Dy jmbMmfsEqjpA/s8IT3y3dLrRRS0dp9SFbFIrmEXA7S1qzaoJcGbhsGw4F8ncxL3LVLaR e7+vq817WtsggEwyVAjknYw8rqyBTDBTy3iMr6Yvowkz9HGZ8YtLPa/OhEzxdAsbW2UX VqGlwmjnEvqwQQlkP431s/k+h1LxgKTuUJMbRx9YYLxLsYeb7Cn8NeoUKSuhcrmYwm/c ItJKeykgF97iJe+kvNib4pliSpG/oKQpGHujSTubkz9a2+8iiFjWkDoIVQoA2K8yU8Zk 18Qg== 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=v/0k6kegqcGHeXQZb085W7mXrNEi7ocQU8WkeUC5hM879re24VXTuLQfFDs+CbSqHd M+fQvl5ua16eY3vgoNziqWa4p9CSwZE0ztZQPmPHhZnh2NWdwj4Yr19NSmCxPdAfpVtC o7ooE1+N7fZ1kQFXeK6cAiBpSzYf4CBeuqNPUKQ81n0TFaFgV03UxDwWRElHWh+v1AVD Azf2Shah/YE68QArWd2KBfFQG+vlwtOWQnNk2WHRmFFNa8kU3X1dg3o/idD/+LcH0F8k BFCdv7e/Z4rfvQI7NoX5rRo2Yi/1rUZg5T/oh2o8fgdJV2pSZ8Bi9CbPORj6gUVxuxsb QOlg== X-Gm-Message-State: AOJu0YwqK7bdNI+dEbHCgJnvN+/G0C2injDq6EiDgSkThmtXfNT31smG 0wLcHwAGBlT2XUEZ3n37UdPuEiAxO98I70RWDu+9BocGx4KtVhJMHtJ9sNcz33Y= 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() Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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 --- 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: 819323 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 431621C689B for ; Wed, 14 Aug 2024 20:18:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723666690; cv=none; b=WeGUjso0NzpMioSn+8NqE73VJIJlGxrGKJwa/xr24WP+Dv7+4Waph/knjYS9gg7e3In9KcFA/qjthzG1C2cc3OBaZemnCI2oTy5rrjefOFkxnjAonrTaOKUxj4s7Xg/xYuNVx7HE23Z7+PsX6llTOL0QkmVz9owr4sANHOVWg2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723666690; c=relaxed/simple; bh=RFZ0W2aEzyo7qvNEznMOi4x7fvkwhw23R+553GKFwnw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NtvuqqVycQmnbnbP0GMtli9eYX35olU/4ebnvqNo3V3nwW95DTHthp2RGw6lGbIaJNGI++6mZR1HFa+92E364dudOrtSVzHe6sabosOjtSq3gFaxex6BUA7GOgN82aOhmf45naXUrI3Ob3CbAyDXzlnbSNK1yExoA7VllAkXgGY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ISNCN99A; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ISNCN99A" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-42812945633so1234735e9.0 for ; Wed, 14 Aug 2024 13:18:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723666687; x=1724271487; darn=vger.kernel.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=ISNCN99AKrnEpMGCfEg3xmo3tUnu8mNqpYgT/q53yvAeaqJx3FVVIrli4V0HdTsGjK KyeTLcWPi/tGeeq6v9NPsLCl/pv6bjk/So2mAFWSjEWiW45+SGMDO5/4X7uPtj5zWc1n tPNljGn79JXEZo/FHezZlqYOOoGNnh5ung3rvP1DMDY4RKwPS0yZRvkbBcK7FrYwEOT0 2dz+quocV/OurX7A3Fhcv/g5AecrM7eYnhLdYhYvOn7OM2aGgj4+K7LFtodFjogF1wO6 /JaEVsgCn3mhNiGYIX/iYCxXge/gl5p0zCd31/bUmov/P0ilPIAJXsLfKtuwbb/QbRKK 09cQ== 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=mPPFB9WvQNKsZXrHR6bLKF0KFPGemeTD9/wC0RHwQZfbMb71Qgtrt8x192p4bepgcD UR6ZYjwkAG7xT6naOb9uddtCh+r9mR+LwSVU5P86EKewYza3c7b6JKTwb/MKaYMJwlYF moHuCAiJYIlVUbIjV7NT+cy2v/tcjYspcjn2mGJ8UgH1sweH+wEoWBGk5z42QArcCHdg nuS7KNeFfFxtHNjPWW0/nOmaKL3/fH+Ml1MgZ48wIrPfIp+cFR1W+U9JDXBgt+cLL7eS 5hi2XPJfKxdFU/LzTLphUu2C63n6VBnKchXevlTHrIenHSbnT02xyHwttE7sNzRfoAYY ywCg== X-Gm-Message-State: AOJu0Yzh7WgVyM7s3m9TmG5FRa5i6yB9iABoaIlJoerchQFVSKllMqO9 cBeZh5U3x7gQS8NLFYg6IEC1CWL50ic0WJUrJeC+efM4AsyokDODxnmLJCoi9o8= 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() Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 819979 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D8B71C7B8B for ; Wed, 14 Aug 2024 20:18:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723666691; cv=none; b=ZSs+xqwPKQPOvrpvwSCY3Ylui+vifu+P6qS6oohkV9MdGjZ5Zf/nZk/x7IHPQeHxJFVjSOCIDA3d24FBnGT+LE7wGwZHsCetKeEDEqnHpswx1tuUSsR7E1rALKML5OpUqGFWOF942wIh66h5A6aVvfTRHyfC3+lYg+cxEe/8ceg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723666691; c=relaxed/simple; bh=M6Xota0thM0mYn1zZ6Ux2xxXCKU4Y7eLR8l8l/rV8NM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=daYCRIOCAc9JmvK81i+EHlV6t2WZxtTjfibyGhq0HagEwaHgBz5LkcGwFVTqYXV/g4t9aNkG6Aw4WP0M1JajPn/fJIfM3pTRhO9GMtjyqw5LmoULbb1COaixDRFE5sVR/MIgbQg9xUbRb/t13G9jZ0wlOEj3ioajj5pd2KWb1c4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=NL/4gfqv; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NL/4gfqv" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-37182eee02dso115026f8f.1 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=vger.kernel.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=NL/4gfqvqMsnjuaqARPIECdSdhSYdB1/dTTQ8axRrpsnusLfL6q/GAHicYb5yI+52H N1fwzdMDZRmyyJjsdSnEYROYpLv8gtKe5/TNEqfyv1UQwGSmGyNrvOFAHS5oaY8Fv9jv iS4dlWRtOI1gnqK99CBxh5QgA80LDJFWLYDgEylmAPCv/kiuNEBS1kJgRO1Jyg8/Zn8S r158O2O3b5ub8+Al1cfDuNNSkCAPOfyKHLniqlunSy5nyOH01AU76yn5QFyfN/scimlp ImaOjGS1ku/ZGsdxL7f2/v/AUqj9pjq/JsMfDBNYm2RyGxHBYr8i8trZnVCWrCgeJgUX 3HSA== 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=S9dd22Ri+2Yn4vZnP1BM1KbzA75N+LfKVQDA2aFY3sONE1TuuT6mYdRsrqPsbESJkf bx71jRv7D09CVatYyIASSows8ksru2iAvbHBFAOuZBJzANvb50otTa1qbrkegHlACFhS omNijMZrQMqLKJeKMTxdM3ZJ8hsMASN60hjixcjrejxMbnBm34m33lu0M5NWRSXYuyIU QEVMvpYAiieMMl+bOHVlrC/aIKAbzrP2611sIb3Y4gd1rHDyzvEr0XrXYEDhhb8HiyXz DjSHVD2JswVlobYl9mzoOGq/eRt1G0yIilXicDRKfV03rrbA6yPoP5EZ/txMNZELFzdm gDxQ== X-Gm-Message-State: AOJu0Yy3o2Q/KVy9Uo9qKKJUXcivERaqALQ/07cTbZh0lkusbEGnq4eW ooxD+t9LSoIbjRMzuTi7c6I7iCLJr9u6YEhOF4kz9QR4Hdhbv7aghnjUZCntbBs= 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 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- 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: 819322 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB5D91C824A for ; Wed, 14 Aug 2024 20:18:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723666694; cv=none; b=EN8LcByksmX3qsk0vkBn3ONcpij/t/kGBP5rwwzKD8yQUZGNIMCqv8SB30d8t6dgMzk/Kyj03WlZlNF2U/bVNB6A0Ncq+/Ipw6z+wODiY8jiPGsdJGbuO31Ral0eoq1JmFghimf95vTZxzrF6WNUVqgjn/bwkPe+BAcLgL9Tv2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723666694; c=relaxed/simple; bh=2Ohf+Waz1Uv9wtQt31iPhyooUXS97YnL8KjoPlEF1Fw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=vF2J9lzcNVOWfcD3H0fqAxR8EmGfEhq6SGJ4l+HuTy3XwCk+HzY+vjuteBDQidmW8K9RUKshswNCOYMkRjYCPUkEJAdVktIHIlmLYx3d7x/8RaO+QZcXc5TnxUBcjfb79LlbiEVm2FsVVC3BtaDIf5xtkydBPw1s8Fn9gh1uom8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=c0EWNg2y; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="c0EWNg2y" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3684bea9728so136358f8f.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=vger.kernel.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=c0EWNg2yeMWeAIhfHOfiv199ajt/4CHHnA8OPrKmmjwoHUvs9od4Jt4+87TzaZ7Iud Hbq2iojxrmkYJvAtndkjyZuVfLBukTkn3dq5neLEqJsUnXhdw+HawWPzhtehrZqKgjwy bzohgB3gHEC1UH/YjK3pfS5RXos5sr6JJhKWggwDF9cw8rIjYcYasJgshl68x91Mf0/D QYO5iqt5c6HlGv7INxZ8Y2gv9nEtXgvhZzhAVxr6CPiQudO1LCuYodk0ij1JFfL8AVQc bcJY0AyRVnEjQmA1An6XJEr9QxTD9E0w1nJs7nPuNecJMu5//AbUna/bQFZWy6DDxpAL ptxA== 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=I915bFMuBUXegsz+H/OjnGXOtgyqmTLToILkQcKryPSBfZuhNRjtYOlX5LnansvXSW 327ejj1yMLFVzt8yGeboN3JgreEjkDibgSGjZvXo8KktvOxggdLJtG8Km3NhiuWMROGN AmGeV5MexfCa1OBhndiGuw/7/HpFsrdtUH0r6hxZW5pphfrqwHla1FbZ1hjGAU86AAq8 XGYR1+uXk718PceHOZ8GnH2rty16CoQX/TvZF18CRF2UNS4jUlOOTjSH6/sBNOnbzFJK 4ZJDydwWqL5X5mElih8n7GoW7BswXCKRUvy4/DuT1o8+zdbGk5VmQ1gbQ6o17xnWP2OH dY0g== X-Gm-Message-State: AOJu0YxGklpR0XRWMcVhnHZik4s8SNFSQ/f26vNFGP3xWdq1BiMRFWb2 AjFAHu7/ixLW2QIeD5WTUmGZh9n1l3Q5wXUkOufs45QEvmcdG82aDrrHrT8TnyWNLa9c23DUMVI I 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 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 819978 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4514C1C8FCD for ; Wed, 14 Aug 2024 20:18:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723666696; cv=none; b=REjHURfxITYjzFLCToFpOWQDhfsk/65PWaC0xKXfFlIsTg5rPs4+EKx9b7VtNj3NfF0C7Su0dtdj0G09DM1FvdIeWgJuMg/BxICJQBXowJeGL+XQn0oRBMdwmYBesyDvrsnEZ2p2elh0dTStZpaRPCbrCjyFpgDphS2OzlA8bIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723666696; c=relaxed/simple; bh=YQ77G+F6IdQNQWI9oMD9x5sylTEBbYeJ2k7ilgFPfQ8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NQTA3CvBKMZCHSABsa0c4JifBGAvB2xioypsagGB5qHLUiVKn+Gz5QvWMDg4SMavGYzELLcjY0Q3YU/BrX4tKoXwwox7mEJVyiRjv/6ECxfJJ77DWoFsXdGjc4PcZD1UUCTZO40/wwDcsBTfkNyV+P6ePpz54e3WUxx3bpfpJDs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=CFohQz2r; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="CFohQz2r" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-52ef95ec938so217578e87.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=1723666692; x=1724271492; darn=vger.kernel.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=CFohQz2r6/xhEowlDfk/AnHpdJJjNFZg3OuUAy9hf6JuVBxlGJ/eHs7LzxMc/6IB9s Ri267SAQ/ZOdzkuN3MC7F9l63v66TNyYPe3rkjOw66XO4/LHAvss04FajC+hUISXBuJd JamB7XQ3nfQ7zyfR+VelC9YoXlPBwHSuI1vXvg5I6fChp8UK5lWKQYmBLExQjXwzTUzu ibvWGJc6rOjGRGfV132ilHHL/x4bVpew/PjlXhgwtj565O+KgpHa/tDDVbn+ahzbbz0T yox7UOcDTQwl16R87dOUnSr6cY5CPsZhdXwTsk+MxlYC9N8FeQq/SyErP8hssvF9RFwF gXWQ== 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=Xb26LexxrDulTIOLlZHunJknDA3rNnYHx8dNry8rj09g/UL7cglNQXJhC0nYy6wkm8 JMID5fNPYYxd64oM0C0ID2xe44MBXhayDA7/X2MaGg+ckXAtSy9LNbyINSJYGNiZHEsD 9Xw5PXOYXAXO9QYs5A51xhmJkCBD9Dhtfgm7ySZi1D26O9dgMxG1sy621aE+bgrl1rF3 z1yLm9j848HrxeJyRTx94X+gplmdQKDNdMqSshRwp5CtDp+thN3A12+RYE98fqpWWBqc CZvNgLy/TI02Jqe8tf3Ra63VXPfZsmiV6gEhcst3r1pfPS7s39uD+ZmiXWoTHjRVJDDz i71w== X-Gm-Message-State: AOJu0YwWwNNlU3EDWYCi2sm3v0FMzdDsfkL9ehfR+YaWy8ypLOcLzIL0 WZSuwNIfX1dxD2M4FWE0ydJOQfkZ5LVdJvbRumqgvjhKKDsNtzLq9sohS1I2KYo= 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 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. 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 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: 819321 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0E721C9DD3 for ; Wed, 14 Aug 2024 20:18:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723666696; cv=none; b=V4MrQOuQVVbDgWb3wwIUjlp+DLAZpXV/7tEQCqMxYFMUU9PxUrqiqoJb3IgFly6pN658BrdRA/f9uLkNSo6OFSC2sGQFSwlv2Xy0znbNsaKRM9xtNVNnkJ/IsAJZKQkxbhyYU5aQMAnw50fSAL9d5leAlodlY9BTkvyTM852iSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723666696; c=relaxed/simple; bh=qjB1r7xWZkiqepaZBKt71uec8dzopsPxrHTPtf78T+A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mpbFeSoh5ftKqA7ojO3N4i+LyKaBehKVsPKh7xCZRw3HKVEhEAzQt9uq7en/KkRYsGto7KA1tpB9I3gguYoNB3u6nEypKgWj8BIqGzSZ9aiQXwq0H1GpFfoKSFSMJuhRWwuh/YSmrhGy+U/3h6jK857gzhR5QO8v17ImPoEhZlw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=qvg0l7ga; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qvg0l7ga" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-42816ca797fso1052835e9.2 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=vger.kernel.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=qvg0l7gah/aSSQEQzeV0Tz0yB01+9NpwgychFuBe7kAcnohwfSW/fYIrtyrWm9O0rb ELEY7i7fOzIKw5BEtQClnV+jeOwSaDZql+rWuzHnhdaJujphJHauLSlwPkRMVHMYXhKT h/4v+RH3HGcn702MFjF2Ffc8BWxsN6ed5XKAzSc73VGyMebg1WiimMG+YEaPn5KthmMS dsys4P8UJvaAWVEk5ZJbVgO7LwVukwTeumbUYHKzlunzuZ+7NNampu0rG5S8my/I+XzH /5XibjPV85C8+PK7BJ2NO6B8URQAUU5ZpPiAGICbv7nIpD7i+wy1rn++UlOc7eaDqgQy uLEA== 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=JrbR+hQ/2PlTerJzCrl0byUsgZFndMJOXGmAyhkCM3oM3q29+GIy1B5T/kif2c4zhc T+sPTQTXjUQSCxVV+a+kDQ1eLOgGLHpWFFWyIhQyYtWpqP59H793cahqwYLLpuUx6Bvd NzaSgJjRMm4hJCRUxTGEDe+auJa7NRJEP2ApdFnpcogp4zR6EPHYEQgfUh9PU41JJRQW KPW9l5ctNC0atKAX3Gz0ihhe6YtaaJ61tvwRNQw9pLQNmHtm4Ow2tdWcyDP1/bTPk30G lwE9VbnlDeoRShngpUVmGt09G2ddpbQsTfFuoV/4HNtFfvNA7DVuojghcXmN53vDFejC cBQA== X-Gm-Message-State: AOJu0Yz/iq5XeyeNTP+AZF41R4tB4t/00JgmG3OAQ1hZbHZwp6Gp0T68 mxqw5NQhGveD2rJ86Kw3leayX2OkGLoTd9UlSRHQm+WIFop1Lcx7O7lY2RZmajY= 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 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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; }