Skip to contentSkip to conversation

soc: qcom: Use __cleanup() for device_node pointers

PATCH NAK Kathiravan Thirumoorthy 4 participants 38 messages Nov 17, 2025 – Nov 18, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover soc: qcom: Use __cleanup() for device_node pointers

This trivial series replaces remaining explicit of_node_put() calls by using the __cleanup() attribute on device_node pointers to simplify the code and make it consistent throughout drivers/soc/qcom/.

---
Kathiravan Thirumoorthy (10):
soc: qcom: aoss: Use __cleanup() for device_node pointers
soc: qcom: gsbi: Use __cleanup() for device_node pointers
soc: qcom: pd-mapper: Use __cleanup() for device_node pointers
soc: qcom: rpm-proc: Use __cleanup() for device_node pointers
soc: qcom: rpm_master_stats: Use __cleanup() for device_node pointers
soc: qcom: smem: Use __cleanup() for device_node pointers
soc: qcom: smp2p: Use __cleanup() for device_node pointers
soc: qcom: smsm: Use __cleanup() for device_node pointers
soc: qcom: spm: Use __cleanup() for device_node pointers
soc: qcom: ubwc: Use __cleanup() for device_node pointers

 drivers/soc/qcom/qcom_aoss.c        |  3 +--
 drivers/soc/qcom/qcom_gsbi.c        |  3 +--
 drivers/soc/qcom/qcom_pd_mapper.c   |  3 +--
 drivers/soc/qcom/rpm-proc.c         |  3 +--
 drivers/soc/qcom/rpm_master_stats.c |  3 +--
 drivers/soc/qcom/smem.c             |  3 +--
 drivers/soc/qcom/smp2p.c            |  3 +--
 drivers/soc/qcom/smsm.c             | 10 +++-------
 drivers/soc/qcom/spm.c              |  5 ++---
 drivers/soc/qcom/ubwc_config.c      |  3 +--
 10 files changed, 13 insertions(+), 26 deletions(-)

---
base-commit: 0f2995693867bfb26197b117cd55624ddc57582f
change-id: 20251114-cleanup_node_put-b351c3468b53

Best regards,

Signature · 1 line
Kathiravan Thirumoorthy <[email protected]>
#1 lore raw

PATCH 1/10 soc: qcom: aoss: Use __cleanup() for device_node pointers

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

---
 drivers/soc/qcom/qcom_aoss.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/qcom_aoss.c +1 -2
index a543ab9bee6c4efcbd7026c44af9731176d4d60c..cc9882009bcac7eae8db74815563cdf1cd9a5aa6 100644
@@ -447,8 +447,8 @@ static void qmp_cooling_devices_remove(struct qmp *qmp)
  */
 struct qmp *qmp_get(struct device *dev)
 {
+	struct device_node *np __free(device_node) = NULL;
 	struct platform_device *pdev;
-	struct device_node *np;
 	struct qmp *qmp;
 
 	if (!dev || !dev->of_node)
@@ -459,7 +459,6 @@ struct qmp *qmp_get(struct device *dev)
 		return ERR_PTR(-ENODEV);
 
 	pdev = of_find_device_by_node(np);
-	of_node_put(np);
 	if (!pdev)
 		return ERR_PTR(-EINVAL);
 
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH 01/10] soc: qcom: aoss: Use __cleanup() for device_node pointers

Quoted 8 lines · Konrad Dybcio
Quoted 5 lines · Kathiravan Thirumoorthy

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

---

This is obviously wrong and not helpful patch.

Best regards,
Krzysztof

#4 lore raw

Re: [PATCH 01/10] soc: qcom: aoss: Use __cleanup() for device_node pointers

Quoted 11 lines · Krzysztof Kozlowski
Quoted 8 lines · Konrad Dybcio
Quoted 5 lines · Kathiravan Thirumoorthy

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

---

This is obviously wrong and not helpful patch.

Describing why it is wrong would be helpful (or having a pointer to an explanation). Bear in mind people who read email archives and find this very brief note.

Signature · 2 lines
With best wishes
Dmitry
#5 lore raw

Re: [PATCH 01/10] soc: qcom: aoss: Use __cleanup() for device_node pointers

Quoted 9 lines · Dmitry Baryshkov
Quoted 8 lines · Krzysztof Kozlowski
Quoted 7 lines · Konrad Dybcio
Quoted 5 lines · Kathiravan Thirumoorthy

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

---

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

This is obviously wrong and not helpful patch.

Describing why it is wrong would be helpful (or having a pointer to an explanation). Bear in mind people who read email archives and find this very brief note.

I gave some rationale in other patches, but summarizing:
1. It is against cleanup.h - author did not bother to read it - which clearly asks for constructor with declaration. This was discussed many times in the list, including many bugs and explicit checkpatch warning (on LKML) because people don't bother to read cleanup.h.

2. It makes simple get+put code complicated, not simpler.

3. It grows the scope of OF reference without benefits.

4. This driver was already reviewed and simplified so author should go back and think why this was left alone (would save a lot of trouble).

Best regards,
Krzysztof

#6 lore raw

Re: [PATCH 01/10] soc: qcom: aoss: Use __cleanup() for device_node pointers

Quoted 24 lines · Krzysztof Kozlowski
Quoted 9 lines · Dmitry Baryshkov
Quoted 8 lines · Krzysztof Kozlowski
Quoted 7 lines · Konrad Dybcio
Quoted 5 lines · Kathiravan Thirumoorthy

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

---

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

This is obviously wrong and not helpful patch.

Describing why it is wrong would be helpful (or having a pointer to an explanation). Bear in mind people who read email archives and find this very brief note.

I gave some rationale in other patches, but summarizing:
1. It is against cleanup.h - author did not bother to read it - which clearly asks for constructor with declaration. This was discussed many times in the list, including many bugs and explicit checkpatch warning (on LKML) because people don't bother to read cleanup.h.

Quoted 6 lines

2. It makes simple get+put code complicated, not simpler.

3. It grows the scope of OF reference without benefits.

4. This driver was already reviewed and simplified so author should go back and think why this was left alone (would save a lot of trouble).

Thanks!

Signature · 2 lines
With best wishes
Dmitry
#7 lore raw

Re: [PATCH 01/10] soc: qcom: aoss: Use __cleanup() for device_node pointers

Quoted 19 lines · Dmitry Baryshkov
Quoted 18 lines · Krzysztof Kozlowski
Quoted 16 lines · Dmitry Baryshkov
Quoted 11 lines · Krzysztof Kozlowski
Quoted 8 lines · Konrad Dybcio
Quoted 5 lines · Kathiravan Thirumoorthy

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

---

This is obviously wrong and not helpful patch.

Describing why it is wrong would be helpful (or having a pointer to an explanation). Bear in mind people who read email archives and find this very brief note.

Quoted 5 lines
Quoted 5 lines

I gave some rationale in other patches, but summarizing:
1. It is against cleanup.h - author did not bother to read it - which clearly asks for constructor with declaration. This was discussed many times in the list, including many bugs and explicit checkpatch warning (on LKML) because people don't bother to read cleanup.h.

Looks like I didn't read it either.. now that I did, I see that _free(x) = NULL is somewhat of an anti-pattern, but none of these patches seem to introduce any bugs related to it

Quoted 1 line
Quoted 1 line

2. It makes simple get+put code complicated, not simpler.

Here I tend to disagree..

Quoted 1 line
Quoted 1 line

3. It grows the scope of OF reference without benefits.

This makes sense

Ultimately as you've noticed, this is mostly a cosmetic change and I don't mind it going either way

Konrad

Quoted 5 lines
Quoted 2 lines

4. This driver was already reviewed and simplified so author should go back and think why this was left alone (would save a lot of trouble).

Thanks!

#8 lore raw

Re: [PATCH 01/10] soc: qcom: aoss: Use __cleanup() for device_node pointers

Quoted 20 lines · Konrad Dybcio
Quoted 19 lines · Dmitry Baryshkov
Quoted 18 lines · Krzysztof Kozlowski
Quoted 16 lines · Dmitry Baryshkov
Quoted 11 lines · Krzysztof Kozlowski
Quoted 8 lines · Konrad Dybcio
Quoted 5 lines · Kathiravan Thirumoorthy

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

---

This is obviously wrong and not helpful patch.

Describing why it is wrong would be helpful (or having a pointer to an explanation). Bear in mind people who read email archives and find this very brief note.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

I gave some rationale in other patches, but summarizing:
1. It is against cleanup.h - author did not bother to read it - which clearly asks for constructor with declaration. This was discussed many times in the list, including many bugs and explicit checkpatch warning (on LKML) because people don't bother to read cleanup.h.

Looks like I didn't read it either.. now that I did, I see that _free(x) = NULL is somewhat of an anti-pattern, but none of these

True

Quoted 1 line

patches seem to introduce any bugs related to it

True

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

2. It makes simple get+put code complicated, not simpler.

Here I tend to disagree..

of_get and immediate of_put is really obvious and easy to read. It is really a common pattern.

OTOH code like:

	struct device_node *np = of_parse_whatever_which_is_get()
	...
	bunch of code here where np is actually used.
	...
	... more code
	return;

is not simple. The lifecycle of this variable becomes very long and where it is acquired - at beginning - causes question - why do you need to acquire it there?

That's why cleanup.h has VERY specific syntax different than rest of kernel.

If contributor does not know this syntax, don't send the patches. They are wrong.

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

3. It grows the scope of OF reference without benefits.

This makes sense

Ultimately as you've noticed, this is mostly a cosmetic change and I don't mind it going either way

It is not cosmetic. It is anti-pattern.

Anti-patterns, even without introducing bugs, make the code WORSE to maintain. Worse code is not cosmetic.

Best regards,
Krzysztof

#9 lore raw

Re: [PATCH 01/10] soc: qcom: aoss: Use __cleanup() for device_node pointers

In reply to Krzysztof Kozlowski
Quoted 9 lines · Krzysztof Kozlowski
Quoted 8 lines · Dmitry Baryshkov
Quoted 7 lines · Krzysztof Kozlowski
Quoted 6 lines · Konrad Dybcio
Quoted 5 lines · Kathiravan Thirumoorthy

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

---

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line

This is obviously wrong and not helpful patch.

Describing why it is wrong would be helpful (or having a pointer to an explanation). Bear in mind people who read email archives and find this very brief note.

I gave some rationale in other patches, but summarizing:
1. It is against cleanup.h - author did not bother to read it - which clearly asks for constructor with declaration.

Thanks for pointing this out. I understood that w/o NULL initialization we will be freeing some dangling pointers but looks like there are other cases also. I agree that I overlooked the details in cleanup.h.Apologies for the oversight and for taking up everyone’s time. Will take care of this going forward!

Quoted 13 lines

This was discussed many
times in the list, including many bugs and explicit checkpatch warning (on LKML) because people don't bother to read cleanup.h.

2. It makes simple get+put code complicated, not simpler.

3. It grows the scope of OF reference without benefits.

4. This driver was already reviewed and simplified so author should go back and think why this was left alone (would save a lot of trouble).

Best regards,
Krzysztof

#10 lore raw

Re: [PATCH 01/10] soc: qcom: aoss: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy
Quoted 13 lines · Kathiravan Thirumoorthy

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

---
 drivers/soc/qcom/qcom_aoss.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/qcom_aoss.c +0 -0
index a543ab9bee6c4efcbd7026c44af9731176d4d60c..cc9882009bcac7eae8db74815563cdf1cd9a5aa6 100644

drivers/soc/qcom/qcom_aoss.c static void qmp_cooling_devices_remove(struct qmp *qmp) · line 450

Quoted 4 lines
drivers/soc/qcom/qcom_aoss.c +1 -0
@@ -447,8 +447,8 @@ static void qmp_cooling_devices_remove(struct qmp *qmp)
  */
 struct qmp *qmp_get(struct device *dev)
 {
+	struct device_node *np __free(device_node) = NULL;

NAK, same reasons

Best regards,
Krzysztof

#11 lore raw

PATCH 2/10 soc: qcom: gsbi: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/qcom_gsbi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/qcom_gsbi.c +1 -2
index a25d1de592f060bbf6e084bd412e3a1ef47558f4..4a195c39e223c1f4cda1becf4542d4c8a79ad688 100644
@@ -124,8 +124,8 @@ static const struct of_device_id tcsr_dt_match[] __maybe_unused = {
 
 static int gsbi_probe(struct platform_device *pdev)
 {
+	struct device_node *tcsr_node __free(device_node) = NULL;
 	struct device_node *node = pdev->dev.of_node;
-	struct device_node *tcsr_node;
 	const struct of_device_id *match;
 	void __iomem *base;
 	struct gsbi_info *gsbi;
@@ -154,7 +154,6 @@ static int gsbi_probe(struct platform_device *pdev)
 			else
 				dev_warn(&pdev->dev, "no matching TCSR\n");
 
-			of_node_put(tcsr_node);
 		}
 	}
 
Signature · 1 line
2.34.1
#13 lore raw

Re: [PATCH 02/10] soc: qcom: gsbi: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy
Quoted 13 lines · Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/qcom_gsbi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/qcom_gsbi.c +0 -0
index a25d1de592f060bbf6e084bd412e3a1ef47558f4..4a195c39e223c1f4cda1becf4542d4c8a79ad688 100644

drivers/soc/qcom/qcom_gsbi.c static const struct of_device_id tcsr_dt_match[] __maybe_unused = { · line 127

Quoted 4 lines
drivers/soc/qcom/qcom_gsbi.c +1 -0
@@ -124,8 +124,8 @@ static const struct of_device_id tcsr_dt_match[] __maybe_unused = {
 
 static int gsbi_probe(struct platform_device *pdev)
 {
+	struct device_node *tcsr_node __free(device_node) = NULL;

NAK. Read first how cleanup.h is supposed to look like and why this wasn't changed with my patches before.

Quoted 7 lines
drivers/soc/qcom/qcom_gsbi.c +0 -1
 	struct device_node *node = pdev->dev.of_node;
-	struct device_node *tcsr_node;
 	const struct of_device_id *match;
 	void __iomem *base;
 	struct gsbi_info *gsbi;

drivers/soc/qcom/qcom_gsbi.c static int gsbi_probe(struct platform_device *pdev) · line 159

Quoted 7 lines
drivers/soc/qcom/qcom_gsbi.c +0 -1
@@ -154,7 +154,6 @@ static int gsbi_probe(struct platform_device *pdev)
 			else
 				dev_warn(&pdev->dev, "no matching TCSR\n");
 
-			of_node_put(tcsr_node);
 		}
 	}
 

Best regards,
Krzysztof

#14 lore raw

PATCH 3/10 soc: qcom: pd-mapper: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/qcom_pd_mapper.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/qcom_pd_mapper.c +1 -2
index 1bcbe69688d2bc2559a1395929e5cd74d9a7a764..5713029d6527c84e8ba410cebb67bc268c6b3721 100644
@@ -612,10 +612,10 @@ static void qcom_pdm_stop(struct qcom_pdm_data *data)
 
 static struct qcom_pdm_data *qcom_pdm_start(void)
 {
+	struct device_node *root __free(device_node) = NULL;
 	const struct qcom_pdm_domain_data * const *domains;
 	const struct of_device_id *match;
 	struct qcom_pdm_data *data;
-	struct device_node *root;
 	int ret, i;
 
 	root = of_find_node_by_path("/");
@@ -623,7 +623,6 @@ static struct qcom_pdm_data *qcom_pdm_start(void)
 		return ERR_PTR(-ENODEV);
 
 	match = of_match_node(qcom_pdm_domains, root);
-	of_node_put(root);
 	if (!match) {
 		pr_notice("PDM: no support for the platform, userspace daemon might be required.\n");
 		return ERR_PTR(-ENODEV);
Signature · 1 line
2.34.1
#16 lore raw

Re: [PATCH 03/10] soc: qcom: pd-mapper: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy
Quoted 13 lines · Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/qcom_pd_mapper.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/qcom_pd_mapper.c +0 -0
index 1bcbe69688d2bc2559a1395929e5cd74d9a7a764..5713029d6527c84e8ba410cebb67bc268c6b3721 100644

drivers/soc/qcom/qcom_pd_mapper.c static void qcom_pdm_stop(struct qcom_pdm_data *data) · line 615

Quoted 4 lines
drivers/soc/qcom/qcom_pd_mapper.c +1 -0
@@ -612,10 +612,10 @@ static void qcom_pdm_stop(struct qcom_pdm_data *data)
 
 static struct qcom_pdm_data *qcom_pdm_start(void)
 {
+	struct device_node *root __free(device_node) = NULL;

NAK

Best regards,
Krzysztof

#17 lore raw

PATCH 4/10 soc: qcom: rpm-proc: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/rpm-proc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/rpm-proc.c +1 -2
index 2466d0400c2e9a539e0b1009ee1bfefc3bd1b589..6f0c9f2558b06323c1100caa4544872badc22599 100644
@@ -9,15 +9,14 @@
 
 static int rpm_proc_probe(struct platform_device *pdev)
 {
+	struct device_node *edge_node __free(device_node) = NULL;
 	struct qcom_smd_edge *edge = NULL;
 	struct device *dev = &pdev->dev;
-	struct device_node *edge_node;
 	int ret;
 
 	edge_node = of_get_child_by_name(dev->of_node, "smd-edge");
 	if (edge_node) {
 		edge = qcom_smd_register_edge(dev, edge_node);
-		of_node_put(edge_node);
 		if (IS_ERR(edge))
 			return dev_err_probe(dev, PTR_ERR(edge),
 					     "Failed to register smd-edge\n");
Signature · 1 line
2.34.1
#19 lore raw

Re: [PATCH 04/10] soc: qcom: rpm-proc: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy
Quoted 13 lines · Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/rpm-proc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/rpm-proc.c +0 -0
index 2466d0400c2e9a539e0b1009ee1bfefc3bd1b589..6f0c9f2558b06323c1100caa4544872badc22599 100644

drivers/soc/qcom/rpm-proc.c line 12

Quoted 4 lines
drivers/soc/qcom/rpm-proc.c +1 -0
@@ -9,15 +9,14 @@
 
 static int rpm_proc_probe(struct platform_device *pdev)
 {
+	struct device_node *edge_node __free(device_node) = NULL;

NAK, stop with this pattern.

You are not simplifying anything here!

Best regards,
Krzysztof

#20 lore raw

PATCH 5/10 soc: qcom: rpm_master_stats: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/rpm_master_stats.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/rpm_master_stats.c +1 -2
index c7788337e1647da386e874bcb87313e8f07241df..06a1d3fe5e9b4295018b0e5cbcf738c0e9e83c3b 100644
@@ -67,9 +67,9 @@ DEFINE_SHOW_ATTRIBUTE(master_stats);
 
 static int master_stats_probe(struct platform_device *pdev)
 {
+	struct device_node *msgram_np __free(device_node) = NULL;
 	struct device *dev = &pdev->dev;
 	struct master_stats_data *data;
-	struct device_node *msgram_np;
 	struct dentry *dent, *root;
 	struct resource res;
 	int count, i, ret;
@@ -98,7 +98,6 @@ static int master_stats_probe(struct platform_device *pdev)
 		 * shared resource.
 		 */
 		ret = of_address_to_resource(msgram_np, 0, &res);
-		of_node_put(msgram_np);
 		if (ret < 0) {
 			debugfs_remove_recursive(root);
 			return ret;
Signature · 1 line
2.34.1
#22 lore raw

Re: [PATCH 05/10] soc: qcom: rpm_master_stats: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy
Quoted 13 lines · Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/rpm_master_stats.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/rpm_master_stats.c +0 -0
index c7788337e1647da386e874bcb87313e8f07241df..06a1d3fe5e9b4295018b0e5cbcf738c0e9e83c3b 100644

drivers/soc/qcom/rpm_master_stats.c DEFINE_SHOW_ATTRIBUTE(master_stats); · line 70

Quoted 4 lines
drivers/soc/qcom/rpm_master_stats.c +1 -0
@@ -67,9 +67,9 @@ DEFINE_SHOW_ATTRIBUTE(master_stats);
 
 static int master_stats_probe(struct platform_device *pdev)
 {
+	struct device_node *msgram_np __free(device_node) = NULL;

NAK, stop with this pattern.

You are not simplifying anything here!

Best regards,
Krzysztof

#23 lore raw

PATCH 6/10 soc: qcom: smem: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/smem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/smem.c +1 -2
index fef840b5457407a85051ded0e835430dbebfe8bb..6c3a08e1afe824402f6fbb84c9695ee57eda230b 100644
@@ -1100,8 +1100,8 @@ static int qcom_smem_map_global(struct qcom_smem *smem, u32 size)
 static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
 				 struct smem_region *region)
 {
+	struct device_node *np __free(device_node) = NULL;
 	struct device *dev = smem->dev;
-	struct device_node *np;
 	struct resource r;
 	int ret;
 
@@ -1112,7 +1112,6 @@ static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
 	}
 
 	ret = of_address_to_resource(np, 0, &r);
-	of_node_put(np);
 	if (ret)
 		return ret;
 
Signature · 1 line
2.34.1
#25 lore raw

Re: [PATCH 06/10] soc: qcom: smem: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy
Quoted 13 lines · Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/smem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/smem.c +0 -0
index fef840b5457407a85051ded0e835430dbebfe8bb..6c3a08e1afe824402f6fbb84c9695ee57eda230b 100644

drivers/soc/qcom/smem.c static int qcom_smem_map_global(struct qcom_smem *smem, u32 size) · line 1103

Quoted 4 lines
drivers/soc/qcom/smem.c +1 -0
@@ -1100,8 +1100,8 @@ static int qcom_smem_map_global(struct qcom_smem *smem, u32 size)
 static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
 				 struct smem_region *region)
 {
+	struct device_node *np __free(device_node) = NULL;

Absolutely none of your patches is correct. ZERO. You did not understand how cleanup.h works but decided to send all of this.

Best regards,
Krzysztof

#26 lore raw

PATCH 7/10 soc: qcom: smp2p: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/smp2p.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/smp2p.c +1 -2
index cb515c2340c107e92ece1bb8cd3854abf9f03e4a..2e22eb4728b7412685138fc86e55058b047bcb75 100644
@@ -501,7 +501,7 @@ static int qcom_smp2p_alloc_outbound_item(struct qcom_smp2p *smp2p)
 
 static int smp2p_parse_ipc(struct qcom_smp2p *smp2p)
 {
-	struct device_node *syscon;
+	struct device_node *syscon __free(device_node) = NULL;
 	struct device *dev = smp2p->dev;
 	const char *key;
 	int ret;
@@ -513,7 +513,6 @@ static int smp2p_parse_ipc(struct qcom_smp2p *smp2p)
 	}
 
 	smp2p->ipc_regmap = syscon_node_to_regmap(syscon);
-	of_node_put(syscon);
 	if (IS_ERR(smp2p->ipc_regmap))
 		return PTR_ERR(smp2p->ipc_regmap);
 
Signature · 1 line
2.34.1
#28 lore raw

Re: [PATCH 07/10] soc: qcom: smp2p: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy
Quoted 13 lines · Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/smp2p.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/smp2p.c +0 -0
index cb515c2340c107e92ece1bb8cd3854abf9f03e4a..2e22eb4728b7412685138fc86e55058b047bcb75 100644

drivers/soc/qcom/smp2p.c static int qcom_smp2p_alloc_outbound_item(struct qcom_smp2p *smp2p) · line 504

Quoted 5 lines
drivers/soc/qcom/smp2p.c +1 -1
@@ -501,7 +501,7 @@ static int qcom_smp2p_alloc_outbound_item(struct qcom_smp2p *smp2p)
 
 static int smp2p_parse_ipc(struct qcom_smp2p *smp2p)
 {
-	struct device_node *syscon;
+	struct device_node *syscon __free(device_node) = NULL;

NAK, stop with this pattern.

You are not simplifying anything here!

Best regards,
Krzysztof

#29 lore raw

PATCH 8/10 soc: qcom: smsm: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/smsm.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/soc/qcom/smsm.c +3 -7
index 021e9d1f61dc5200514c5a239d52be97f7e82825..5600712f9185bba8c82da431cfb9f21f1bc44761 100644
@@ -397,7 +397,7 @@ static int smsm_parse_mbox(struct qcom_smsm *smsm, unsigned int host_id)
  */
 static int smsm_parse_ipc(struct qcom_smsm *smsm, unsigned host_id)
 {
-	struct device_node *syscon;
+	struct device_node *syscon __free(device_node) = NULL;
 	struct device_node *node = smsm->dev->of_node;
 	struct smsm_host *host = &smsm->hosts[host_id];
 	char key[16];
@@ -409,7 +409,6 @@ static int smsm_parse_ipc(struct qcom_smsm *smsm, unsigned host_id)
 		return 0;
 
 	host->ipc_regmap = syscon_node_to_regmap(syscon);
-	of_node_put(syscon);
 	if (IS_ERR(host->ipc_regmap))
 		return PTR_ERR(host->ipc_regmap);
 
@@ -509,8 +508,8 @@ static int smsm_get_size_info(struct qcom_smsm *smsm)
 
 static int qcom_smsm_probe(struct platform_device *pdev)
 {
-	struct device_node *local_node;
-	struct device_node *node;
+	struct device_node *local_node __free(device_node) = NULL;
+	struct device_node *node __free(device_node) = NULL;
 	struct smsm_entry *entry;
 	struct qcom_smsm *smsm;
 	u32 *intr_mask;
@@ -640,12 +639,10 @@ static int qcom_smsm_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, smsm);
-	of_node_put(local_node);
 
 	return 0;
 
 unwind_interfaces:
-	of_node_put(node);
 	for (id = 0; id < smsm->num_entries; id++)
 		if (smsm->entries[id].domain)
 			irq_domain_remove(smsm->entries[id].domain);
@@ -655,7 +652,6 @@ static int qcom_smsm_probe(struct platform_device *pdev)
 	for (id = 0; id < smsm->num_hosts; id++)
 		mbox_free_channel(smsm->hosts[id].mbox_chan);
 
-	of_node_put(local_node);
 	return ret;
 }
 
Signature · 1 line
2.34.1
#31 lore raw

Re: [PATCH 08/10] soc: qcom: smsm: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy
Quoted 13 lines · Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/smsm.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/soc/qcom/smsm.c +0 -0
index 021e9d1f61dc5200514c5a239d52be97f7e82825..5600712f9185bba8c82da431cfb9f21f1bc44761 100644

drivers/soc/qcom/smsm.c static int smsm_parse_mbox(struct qcom_smsm *smsm, unsigned int host_id) · line 400

Quoted 5 lines
drivers/soc/qcom/smsm.c +1 -1
@@ -397,7 +397,7 @@ static int smsm_parse_mbox(struct qcom_smsm *smsm, unsigned int host_id)
  */
 static int smsm_parse_ipc(struct qcom_smsm *smsm, unsigned host_id)
 {
-	struct device_node *syscon;
+	struct device_node *syscon __free(device_node) = NULL;

NAK, stop with this pattern.

You are not simplifying anything here!

Best regards,
Krzysztof

#32 lore raw

PATCH 9/10 soc: qcom: spm: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/spm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/soc/qcom/spm.c +2 -3
index f75659fff2874fb6a29c48ceee862b05b1ba5802..a87a8593a8b7fb2c62b14eaa9c96f46fc5eba877 100644
@@ -391,7 +391,8 @@ static int spm_get_cpu(struct device *dev)
 	bool found;
 
 	for_each_possible_cpu(cpu) {
-		struct device_node *cpu_node, *saw_node;
+		struct device_node *cpu_node __free(device_node) = NULL;
+		struct device_node *saw_node __free(device_node) = NULL;
 
 		cpu_node = of_cpu_device_node_get(cpu);
 		if (!cpu_node)
@@ -399,8 +400,6 @@ static int spm_get_cpu(struct device *dev)
 
 		saw_node = of_parse_phandle(cpu_node, "qcom,saw", 0);
 		found = (saw_node == dev->of_node);
-		of_node_put(saw_node);
-		of_node_put(cpu_node);
 
 		if (found)
 			return cpu;
Signature · 1 line
2.34.1
#34 lore raw

Re: [PATCH 09/10] soc: qcom: spm: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy
Quoted 13 lines · Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/spm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/soc/qcom/spm.c +0 -0
index f75659fff2874fb6a29c48ceee862b05b1ba5802..a87a8593a8b7fb2c62b14eaa9c96f46fc5eba877 100644

drivers/soc/qcom/spm.c static int spm_get_cpu(struct device *dev) · line 396

Quoted 7 lines
drivers/soc/qcom/spm.c +2 -1
@@ -391,7 +391,8 @@ static int spm_get_cpu(struct device *dev)
 	bool found;
 
 	for_each_possible_cpu(cpu) {
-		struct device_node *cpu_node, *saw_node;
+		struct device_node *cpu_node __free(device_node) = NULL;
+		struct device_node *saw_node __free(device_node) = NULL;
 

This is getting ridicilous. NAK, stop with this pattern.

You are not simplifying anything here!

Best regards,
Krzysztof

#35 lore raw

PATCH 10/10 soc: qcom: ubwc: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/ubwc_config.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/ubwc_config.c +1 -2
index 1c09796163b09a19e387c18886966514cc19b209..1e7717aba5236050d8e736fb0891534b02203aae 100644
@@ -301,15 +301,14 @@ static const struct of_device_id qcom_ubwc_configs[] __maybe_unused = {
 
 const struct qcom_ubwc_cfg_data *qcom_ubwc_config_get_data(void)
 {
+	struct device_node *root __free(device_node) = NULL;
 	const struct of_device_id *match;
-	struct device_node *root;
 
 	root = of_find_node_by_path("/");
 	if (!root)
 		return ERR_PTR(-ENODEV);
 
 	match = of_match_node(qcom_ubwc_configs, root);
-	of_node_put(root);
 	if (!match) {
 		pr_err("Couldn't find UBWC config data for this platform!\n");
 		return ERR_PTR(-EINVAL);
Signature · 1 line
2.34.1
#37 lore raw

Re: [PATCH 10/10] soc: qcom: ubwc: Use __cleanup() for device_node pointers

In reply to Kathiravan Thirumoorthy
Quoted 13 lines · Kathiravan Thirumoorthy

Apply the __cleanup() attribute to device_node pointers to simplify resource management and remove explicit of_node_put() calls.

---
 drivers/soc/qcom/ubwc_config.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/ubwc_config.c +0 -0
index 1c09796163b09a19e387c18886966514cc19b209..1e7717aba5236050d8e736fb0891534b02203aae 100644

drivers/soc/qcom/ubwc_config.c static const struct of_device_id qcom_ubwc_configs[] __maybe_unused = { · line 305

Quoted 5 lines
drivers/soc/qcom/ubwc_config.c +1 -0
@@ -301,15 +301,14 @@ static const struct of_device_id qcom_ubwc_configs[] __maybe_unused = {
 
 const struct qcom_ubwc_cfg_data *qcom_ubwc_config_get_data(void)
 {
+	struct device_node *root __free(device_node) = NULL;
 	const struct of_device_id *match;

You are writing worse code than it was before. The code was like that intentionally.

Best regards,
Krzysztof