[PATCH 08/10] Input: i8042 - use cleanup facility for device_node

Javier Carrasco posted 10 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH 08/10] Input: i8042 - use cleanup facility for device_node
Posted by Javier Carrasco 1 month, 2 weeks ago
Use the '__free(device_node)' macro to automatically free the device
node, removing the need for explicit calls to 'of_node_put()' to
decrement its refcount.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/input/serio/i8042-sparcio.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h
index c2fda54dc384..8f38b6f4ae77 100644
--- a/drivers/input/serio/i8042-sparcio.h
+++ b/drivers/input/serio/i8042-sparcio.h
@@ -106,17 +106,13 @@ static struct platform_driver sparc_i8042_driver = {
 
 static bool i8042_is_mr_coffee(void)
 {
-	struct device_node *root;
+	struct device_node *root __free(device_node) = of_find_node_by_path("/");
 	const char *name;
 	bool is_mr_coffee;
 
-	root = of_find_node_by_path("/");
-
 	name = of_get_property(root, "name", NULL);
 	is_mr_coffee = name && !strcmp(name, "SUNW,JavaStation-1");
 
-	of_node_put(root);
-
 	return is_mr_coffee;
 }
 

-- 
2.43.0
Re: [PATCH 08/10] Input: i8042 - use cleanup facility for device_node
Posted by Dmitry Torokhov 1 month, 1 week ago
On Thu, Oct 10, 2024 at 11:25:58PM +0200, Javier Carrasco wrote:
> Use the '__free(device_node)' macro to automatically free the device
> node, removing the need for explicit calls to 'of_node_put()' to
> decrement its refcount.
> 
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
>  drivers/input/serio/i8042-sparcio.h | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h
> index c2fda54dc384..8f38b6f4ae77 100644
> --- a/drivers/input/serio/i8042-sparcio.h
> +++ b/drivers/input/serio/i8042-sparcio.h
> @@ -106,17 +106,13 @@ static struct platform_driver sparc_i8042_driver = {
>  
>  static bool i8042_is_mr_coffee(void)
>  {
> -	struct device_node *root;
> +	struct device_node *root __free(device_node) = of_find_node_by_path("/");
>  	const char *name;
>  	bool is_mr_coffee;

This temporary is no longer needed. I removed it and applied, thanks.

>  
> -	root = of_find_node_by_path("/");
> -
>  	name = of_get_property(root, "name", NULL);
>  	is_mr_coffee = name && !strcmp(name, "SUNW,JavaStation-1");
>  
> -	of_node_put(root);
> -
>  	return is_mr_coffee;
>  }
>  
> 
> -- 
> 2.43.0
> 

-- 
Dmitry