diff mbox series

[2/3] of: irq: Do some clean up with use of __free()

Message ID 20240830020626.115933-3-zhangzekun11@huawei.com
State Changes Requested
Headers show
Series Do some cleanup with use of __free() | expand

Checks

Context Check Description
robh/checkpatch success
robh/patch-applied fail build log

Commit Message

Zhang Zekun Aug. 30, 2024, 2:06 a.m. UTC
__free() provides a scoped of_node_put() functionality to put the
device_node automatically, and we don't need to call of_node_put()
directly. Let's simplify the code a bit with the use of __free().

Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
---
 drivers/of/irq.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Comments

Rob Herring (Arm) Aug. 30, 2024, 2:34 p.m. UTC | #1
On Thu, Aug 29, 2024 at 9:19 PM Zhang Zekun <zhangzekun11@huawei.com> wrote:
>
> __free() provides a scoped of_node_put() functionality to put the
> device_node automatically, and we don't need to call of_node_put()
> directly. Let's simplify the code a bit with the use of __free().
>
> Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
> ---
>  drivers/of/irq.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index 36351ad6115e..3291f1ffea49 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -341,7 +341,7 @@ EXPORT_SYMBOL_GPL(of_irq_parse_raw);
>   */
>  int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_args *out_irq)
>  {
> -       struct device_node *p;
> +       struct device_node *p __free(device_node) = NULL;

It is desired that the declaration and (real) assignment be together.
See discussions when adding the device_node cleanup support.

Rob
diff mbox series

Patch

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 36351ad6115e..3291f1ffea49 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -341,7 +341,7 @@  EXPORT_SYMBOL_GPL(of_irq_parse_raw);
  */
 int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_args *out_irq)
 {
-	struct device_node *p;
+	struct device_node *p __free(device_node) = NULL;
 	const __be32 *addr;
 	u32 intsize;
 	int i, res, addr_len;
@@ -374,10 +374,8 @@  int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
 		return -EINVAL;
 
 	/* Get size of interrupt specifier */
-	if (of_property_read_u32(p, "#interrupt-cells", &intsize)) {
-		res = -EINVAL;
-		goto out;
-	}
+	if (of_property_read_u32(p, "#interrupt-cells", &intsize))
+		return -EINVAL;
 
 	pr_debug(" parent=%pOF, intsize=%d\n", p, intsize);
 
@@ -389,17 +387,14 @@  int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
 						 (index * intsize) + i,
 						 out_irq->args + i);
 		if (res)
-			goto out;
+			return res;
 	}
 
 	pr_debug(" intspec=%d\n", *out_irq->args);
 
 
 	/* Check if there are any interrupt-map translations to process */
-	res = of_irq_parse_raw(addr_buf, out_irq);
- out:
-	of_node_put(p);
-	return res;
+	return of_irq_parse_raw(addr_buf, out_irq);
 }
 EXPORT_SYMBOL_GPL(of_irq_parse_one);