* [PATCH 1/1] Driver: clk-qoriq.c: replace of_node_put with _free improves cleanup
@ 2024-08-20 1:35 David Hunter
2024-08-20 22:03 ` Stephen Boyd
0 siblings, 1 reply; 4+ messages in thread
From: David Hunter @ 2024-08-20 1:35 UTC (permalink / raw)
To: mturquette, sboyd
Cc: linux-clk, linux-kernel, javier.carrasco.cruz, shuah,
david.hunter.linux
Use the _free function to have automatic clean up instead of calling
another function, of_node_put. This prevents leaking reference counts.
The following commit has information on _free(device_node):
9448e55d032d99af8e23487f51a542d51b2f1a48
The code was able to compile without errors or warnings.
Signed-off-by: David Hunter <david.hunter.linux@gmail.com>
---
drivers/clk/clk-qoriq.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c
index 4dcde305944c..941a0372db4b 100644
--- a/drivers/clk/clk-qoriq.c
+++ b/drivers/clk/clk-qoriq.c
@@ -1065,11 +1065,8 @@ static void __init _clockgen_init(struct device_node *np, bool legacy);
static void __init legacy_init_clockgen(struct device_node *np)
{
if (!clockgen.node) {
- struct device_node *parent_np;
-
- parent_np = of_get_parent(np);
+ struct device_node __free(device_node) *parent_np = of_get_parent(np);
_clockgen_init(parent_np, true);
- of_node_put(parent_np);
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/1] Driver: clk-qoriq.c: replace of_node_put with _free improves cleanup
2024-08-20 1:35 [PATCH 1/1] Driver: clk-qoriq.c: replace of_node_put with _free improves cleanup David Hunter
@ 2024-08-20 22:03 ` Stephen Boyd
2024-08-21 1:07 ` [PATCH 1/1 V2] " David Hunter
0 siblings, 1 reply; 4+ messages in thread
From: Stephen Boyd @ 2024-08-20 22:03 UTC (permalink / raw)
To: David Hunter, mturquette
Cc: linux-clk, linux-kernel, javier.carrasco.cruz, shuah,
david.hunter.linux
Quoting David Hunter (2024-08-19 18:35:49)
> Use the _free function to have automatic clean up instead of calling
How about:
Use __free() to have automatic cleanup instead of calling
of_node_put() manually.
> another function, of_node_put. This prevents leaking reference counts.
Are there any leaking reference counts? I'd just omit that sentence
unless there is one.
>
> The following commit has information on _free(device_node):
>
> 9448e55d032d99af8e23487f51a542d51b2f1a48
>
> The code was able to compile without errors or warnings.
The rest of this can go below the triple dash ---
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/1 V2] Driver: clk-qoriq.c: replace of_node_put with _free improves cleanup
2024-08-20 22:03 ` Stephen Boyd
@ 2024-08-21 1:07 ` David Hunter
2024-08-28 0:03 ` Stephen Boyd
0 siblings, 1 reply; 4+ messages in thread
From: David Hunter @ 2024-08-21 1:07 UTC (permalink / raw)
To: sboyd
Cc: david.hunter.linux, javier.carrasco.cruz, linux-clk, linux-kernel,
mturquette, shuah
Use _free() to have automatic cleanup instead of calling of_node_put()
manually.
Compiled without errors or warnings.
Signed-off-by: David Hunter <david.hunter.linux@gmail.com>
---
The following commit has information on _free(device_node):
9448e55d032d99af8e23487f51a542d51b2f1a48
V1 --> V2
- Improved message body
- Use change log to give more information about _free()
---
drivers/clk/clk-qoriq.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c
index 4dcde305944c..941a0372db4b 100644
--- a/drivers/clk/clk-qoriq.c
+++ b/drivers/clk/clk-qoriq.c
@@ -1065,11 +1065,8 @@ static void __init _clockgen_init(struct device_node *np, bool legacy);
static void __init legacy_init_clockgen(struct device_node *np)
{
if (!clockgen.node) {
- struct device_node *parent_np;
-
- parent_np = of_get_parent(np);
+ struct device_node __free(device_node) *parent_np = of_get_parent(np);
_clockgen_init(parent_np, true);
- of_node_put(parent_np);
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/1 V2] Driver: clk-qoriq.c: replace of_node_put with _free improves cleanup
2024-08-21 1:07 ` [PATCH 1/1 V2] " David Hunter
@ 2024-08-28 0:03 ` Stephen Boyd
0 siblings, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2024-08-28 0:03 UTC (permalink / raw)
To: David Hunter
Cc: david.hunter.linux, javier.carrasco.cruz, linux-clk, linux-kernel,
mturquette, shuah
The subject should be
clk: clk-qoriq: Replace of_node_put() with __free()
Quoting David Hunter (2024-08-20 18:07:39)
> Use _free() to have automatic cleanup instead of calling of_node_put()
__free()
> manually.
>
> Compiled without errors or warnings.
>
> Signed-off-by: David Hunter <david.hunter.linux@gmail.com>
> ---
> The following commit has information on _free(device_node):
> 9448e55d032d99af8e23487f51a542d51b2f1a48
>
> V1 --> V2
> - Improved message body
> - Use change log to give more information about _free()
Please don't send the next version as a reply to the previous patch.
> ---
> drivers/clk/clk-qoriq.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c
> index 4dcde305944c..941a0372db4b 100644
> --- a/drivers/clk/clk-qoriq.c
> +++ b/drivers/clk/clk-qoriq.c
> @@ -1065,11 +1065,8 @@ static void __init _clockgen_init(struct device_node *np, bool legacy);
> static void __init legacy_init_clockgen(struct device_node *np)
> {
> if (!clockgen.node) {
> - struct device_node *parent_np;
> -
> - parent_np = of_get_parent(np);
> + struct device_node __free(device_node) *parent_np = of_get_parent(np);
It seems the __free() comes after the variable name declaration if my
grep skills are working today.
Also, please include linux/cleanup.h at the top of the file for __free().
> _clockgen_init(parent_np, true);
> - of_node_put(parent_np);
> }
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-08-28 0:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-20 1:35 [PATCH 1/1] Driver: clk-qoriq.c: replace of_node_put with _free improves cleanup David Hunter
2024-08-20 22:03 ` Stephen Boyd
2024-08-21 1:07 ` [PATCH 1/1 V2] " David Hunter
2024-08-28 0:03 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox