diff mbox series

[v3,2/2] Input: sparcspkr - use cleanup facility for device_node

Message ID 20241021-input_automate_of_node_put-v3-2-cc73f636e1bc@gmail.com (mailing list archive)
State New, archived
Headers show
Series input: automate of_node_put() calls for device_node | expand

Commit Message

Javier Carrasco Oct. 21, 2024, 8:28 p.m. UTC
Use the 'free(device_node)' macro to simplify the code by automatically
freeing the device node, which removes the need for explicit calls to
'of_node_put()'.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/input/misc/sparcspkr.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Chen-Yu Tsai Oct. 22, 2024, 4:57 a.m. UTC | #1
On Tue, Oct 22, 2024 at 4:28 AM Javier Carrasco
<javier.carrasco.cruz@gmail.com> wrote:
>
> Use the 'free(device_node)' macro to simplify the code by automatically
> freeing the device node, which removes the need for explicit calls to
> 'of_node_put()'.
>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>

Not sure why I received this patch, but given my recent experience
with the cleanup stuff,

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

> ---
>  drivers/input/misc/sparcspkr.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c
> index e484d79b5597..8d7303fc13bc 100644
> --- a/drivers/input/misc/sparcspkr.c
> +++ b/drivers/input/misc/sparcspkr.c
> @@ -182,7 +182,6 @@ static int bbc_beep_probe(struct platform_device *op)
>  {
>         struct sparcspkr_state *state;
>         struct bbc_beep_info *info;
> -       struct device_node *dp;
>         int err;
>
>         state = devm_kzalloc(&op->dev, sizeof(*state), GFP_KERNEL);
> @@ -193,13 +192,12 @@ static int bbc_beep_probe(struct platform_device *op)
>         state->event = bbc_spkr_event;
>         spin_lock_init(&state->lock);
>
> -       dp = of_find_node_by_path("/");
> +       struct device_node *dp __free(device_node) = of_find_node_by_path("/");
>         if (!dp)
>                 return -ENODEV;
>
>         info = &state->u.bbc;
>         info->clock_freq = of_getintprop_default(dp, "clock-frequency", 0);
> -       of_node_put(dp);
>         if (!info->clock_freq)
>                 return -ENODEV;
>
>
> --
> 2.43.0
>
diff mbox series

Patch

diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c
index e484d79b5597..8d7303fc13bc 100644
--- a/drivers/input/misc/sparcspkr.c
+++ b/drivers/input/misc/sparcspkr.c
@@ -182,7 +182,6 @@  static int bbc_beep_probe(struct platform_device *op)
 {
 	struct sparcspkr_state *state;
 	struct bbc_beep_info *info;
-	struct device_node *dp;
 	int err;
 
 	state = devm_kzalloc(&op->dev, sizeof(*state), GFP_KERNEL);
@@ -193,13 +192,12 @@  static int bbc_beep_probe(struct platform_device *op)
 	state->event = bbc_spkr_event;
 	spin_lock_init(&state->lock);
 
-	dp = of_find_node_by_path("/");
+	struct device_node *dp __free(device_node) = of_find_node_by_path("/");
 	if (!dp)
 		return -ENODEV;
 
 	info = &state->u.bbc;
 	info->clock_freq = of_getintprop_default(dp, "clock-frequency", 0);
-	of_node_put(dp);
 	if (!info->clock_freq)
 		return -ENODEV;