Message ID | 20240830020626.115933-3-zhangzekun11@huawei.com |
---|---|
State | Changes Requested |
Headers | show |
Series | Do some cleanup with use of __free() | expand |
Context | Check | Description |
---|---|---|
robh/checkpatch | success | |
robh/patch-applied | fail | build log |
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 --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);
__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(-)