[PATCH v2 2/2] clocksource/drivers/timer-ti-dm: automate device_node cleanup in dmtimer_percpu_quirk_init()

Javier Carrasco posted 2 patches 3 weeks, 6 days ago
There is a newer version of this series
[PATCH v2 2/2] clocksource/drivers/timer-ti-dm: automate device_node cleanup in dmtimer_percpu_quirk_init()
Posted by Javier Carrasco 3 weeks, 6 days ago
Simplify the code and make it more robust by automating the node release
when it goes out of scope.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/clocksource/timer-ti-dm-systimer.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/timer-ti-dm-systimer.c b/drivers/clocksource/timer-ti-dm-systimer.c
index 23be1d21ce21..d1c144d6f328 100644
--- a/drivers/clocksource/timer-ti-dm-systimer.c
+++ b/drivers/clocksource/timer-ti-dm-systimer.c
@@ -686,15 +686,13 @@ subsys_initcall(dmtimer_percpu_timer_startup);
 
 static int __init dmtimer_percpu_quirk_init(struct device_node *np, u32 pa)
 {
-	struct device_node *arm_timer;
+	struct device_node *arm_timer __free(device_node) =
+		of_find_compatible_node(NULL, NULL, "arm,armv7-timer");
 
-	arm_timer = of_find_compatible_node(NULL, NULL, "arm,armv7-timer");
 	if (of_device_is_available(arm_timer)) {
 		pr_warn_once("ARM architected timer wrap issue i940 detected\n");
-		of_node_put(arm_timer);
 		return 0;
 	}
-	of_node_put(arm_timer);
 
 	if (pa == 0x4882c000)           /* dra7 dmtimer15 */
 		return dmtimer_percpu_timer_init(np, 0);

-- 
2.43.0
Re: [PATCH v2 2/2] clocksource/drivers/timer-ti-dm: automate device_node cleanup in dmtimer_percpu_quirk_init()
Posted by Krzysztof Kozlowski 3 weeks, 3 days ago
On 28/10/2024 18:06, Javier Carrasco wrote:
> Simplify the code and make it more robust by automating the node release
> when it goes out of scope.
> 
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
>  drivers/clocksource/timer-ti-dm-systimer.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/clocksource/timer-ti-dm-systimer.c b/drivers/clocksource/timer-ti-dm-systimer.c
> index 23be1d21ce21..d1c144d6f328 100644
> --- a/drivers/clocksource/timer-ti-dm-systimer.c
> +++ b/drivers/clocksource/timer-ti-dm-systimer.c
> @@ -686,15 +686,13 @@ subsys_initcall(dmtimer_percpu_timer_startup);
>  
>  static int __init dmtimer_percpu_quirk_init(struct device_node *np, u32 pa)
>  {
> -	struct device_node *arm_timer;
> +	struct device_node *arm_timer __free(device_node) =
> +		of_find_compatible_node(NULL, NULL, "arm,armv7-timer");
>  
> -	arm_timer = of_find_compatible_node(NULL, NULL, "arm,armv7-timer");
>  	if (of_device_is_available(arm_timer)) {
>  		pr_warn_once("ARM architected timer wrap issue i940 detected\n");
> -		of_node_put(arm_timer);


You just added this. Don't add code which is immediately removed. It's a
noop or wrong code.

Best regards,
Krzysztof