linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Hunter <david.hunter.linux@gmail.com>
To: bhelgaas@google.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: David Hunter <david.hunter.linux@gmail.com>,
	julia.lawall@inria.fr, skhan@linuxfoundation.org,
	javier.carrasco.cruz@gmail.com
Subject: [PATCH] of.c: replace of_node_put with __free improves cleanup
Date: Fri, 19 Jul 2024 18:38:05 -0400	[thread overview]
Message-ID: <20240719223805.102929-1-david.hunter.linux@gmail.com> (raw)

The use of the __free function allows the cleanup to be based on scope
instead of on another function called later. This makes the cleanup
automatic and less susceptible to errors later.

This code was compiled without errors or warnings.

Signed-off-by: David Hunter <david.hunter.linux@gmail.com>
---
 drivers/pci/of.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pci/of.c b/drivers/pci/of.c
index b908fe1ae951..8b150982f5cd 100644
--- a/drivers/pci/of.c
+++ b/drivers/pci/of.c
@@ -616,16 +616,14 @@ int devm_of_pci_bridge_init(struct device *dev, struct pci_host_bridge *bridge)
 
 void of_pci_remove_node(struct pci_dev *pdev)
 {
-	struct device_node *np;
+	struct device_node *np __free(device_node) = pci_device_to_OF_node(pdev);
 
-	np = pci_device_to_OF_node(pdev);
 	if (!np || !of_node_check_flag(np, OF_DYNAMIC))
 		return;
 	pdev->dev.of_node = NULL;
 
 	of_changeset_revert(np->data);
 	of_changeset_destroy(np->data);
-	of_node_put(np);
 }
 
 void of_pci_make_dev_node(struct pci_dev *pdev)
-- 
2.34.1


             reply	other threads:[~2024-07-19 22:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-19 22:38 David Hunter [this message]
2024-08-01 23:55 ` [PATCH] of.c: replace of_node_put with __free improves cleanup Bjorn Helgaas
2024-08-07 10:47   ` Jonathan Cameron
2024-08-07 16:18     ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240719223805.102929-1-david.hunter.linux@gmail.com \
    --to=david.hunter.linux@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=julia.lawall@inria.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).