public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] firmware: qcom: scm: Use __cleanup() for device_node pointers
@ 2025-11-17 16:22 Kathiravan Thirumoorthy
  2025-11-17 17:04 ` Dmitry Baryshkov
  2025-11-18 11:38 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Kathiravan Thirumoorthy @ 2025-11-17 16:22 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio
  Cc: linux-arm-msm, linux-kernel, Kathiravan Thirumoorthy

Make use of the __cleanup() attribute for device_node pointers to simplify
resource management and remove explicit of_node_put() calls.

Signed-off-by: Kathiravan Thirumoorthy <kathiravan.thirumoorthy@oss.qualcomm.com>
---
 drivers/firmware/qcom/qcom_scm.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index e777b7cb9b127944fe112f453cae9cbc40c06cae..7c1fffa8e7ad48b294b90e7e63f726d0ba7d55e1 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -1746,7 +1746,7 @@ EXPORT_SYMBOL_GPL(qcom_scm_gpu_init_regs);
 
 static int qcom_scm_find_dload_address(struct device *dev, u64 *addr)
 {
-	struct device_node *tcsr;
+	struct device_node *tcsr __free(device_node) = NULL;
 	struct device_node *np = dev->of_node;
 	struct resource res;
 	u32 offset;
@@ -1757,7 +1757,6 @@ static int qcom_scm_find_dload_address(struct device *dev, u64 *addr)
 		return 0;
 
 	ret = of_address_to_resource(tcsr, 0, &res);
-	of_node_put(tcsr);
 	if (ret)
 		return ret;
 
@@ -2020,17 +2019,12 @@ static const struct of_device_id qcom_scm_qseecom_allowlist[] __maybe_unused = {
 
 static bool qcom_scm_qseecom_machine_is_allowed(void)
 {
-	struct device_node *np;
-	bool match;
+	struct device_node *np __free(device_node) = of_find_node_by_path("/");
 
-	np = of_find_node_by_path("/");
 	if (!np)
 		return false;
 
-	match = of_match_node(qcom_scm_qseecom_allowlist, np);
-	of_node_put(np);
-
-	return match;
+	return of_match_node(qcom_scm_qseecom_allowlist, np);
 }
 
 static void qcom_scm_qseecom_free(void *data)

---
base-commit: 0c1c7a6a83feaf2cf182c52983ffe330ffb50280
change-id: 20251117-scm_cleanup_of_node_put-6c915216b1bf

Best regards,
-- 
Kathiravan Thirumoorthy <kathiravan.thirumoorthy@oss.qualcomm.com>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-18 11:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-17 16:22 [PATCH] firmware: qcom: scm: Use __cleanup() for device_node pointers Kathiravan Thirumoorthy
2025-11-17 17:04 ` Dmitry Baryshkov
2025-11-18 11:38 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox