From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: "Xiaowei Song" <songxiaowei@hisilicon.com>,
"Binghui Wang" <wangbinghui@hisilicon.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Rob Herring" <robh@kernel.org>,
"Jonathan Cameron" <Jonathan.Cameron@Huawei.com>,
"Bjorn Helgaas" <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Javier Carrasco <javier.carrasco.cruz@gmail.com>
Subject: [PATCH 2/2] PCI: kirin: use for_each_available_child_of_node_scoped()
Date: Sat, 06 Jul 2024 17:07:47 +0200 [thread overview]
Message-ID: <20240706-pcie-kirin-dev_err_probe-v1-2-56df797fb8ee@gmail.com> (raw)
In-Reply-To: <20240706-pcie-kirin-dev_err_probe-v1-0-56df797fb8ee@gmail.com>
The scoped version of the macro automatically decrements the child node
refcount on early exits, removing the need for the `goto` and
`of_node_put()`.
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
drivers/pci/controller/dwc/pcie-kirin.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
index da8091f6b22b..ac0aacb11489 100644
--- a/drivers/pci/controller/dwc/pcie-kirin.c
+++ b/drivers/pci/controller/dwc/pcie-kirin.c
@@ -447,7 +447,7 @@ static long kirin_pcie_get_resource(struct kirin_pcie *kirin_pcie,
struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
- struct device_node *child, *node = dev->of_node;
+ struct device_node *node = dev->of_node;
void __iomem *apb_base;
int ret;
@@ -472,17 +472,13 @@ static long kirin_pcie_get_resource(struct kirin_pcie *kirin_pcie,
return ret;
/* Parse OF children */
- for_each_available_child_of_node(node, child) {
+ for_each_available_child_of_node_scoped(node, child) {
ret = kirin_pcie_parse_port(kirin_pcie, pdev, child);
if (ret)
- goto put_node;
+ return ret;
}
return 0;
-
-put_node:
- of_node_put(child);
- return ret;
}
static void kirin_pcie_sideband_dbi_w_mode(struct kirin_pcie *kirin_pcie,
--
2.40.1
prev parent reply other threads:[~2024-07-06 15:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-06 15:07 [PATCH 0/2] PCI: kirin: cleanup (dev_err_probe() and scoped loop) Javier Carrasco
2024-07-06 15:07 ` [PATCH 1/2] PCI: kirin: use dev_err_probe() in probe error paths Javier Carrasco
2024-07-06 19:47 ` Christophe JAILLET
2024-07-06 20:12 ` Javier Carrasco
2024-07-07 6:53 ` Krzysztof Wilczyński
2024-07-07 12:19 ` Javier Carrasco
2024-07-06 15:07 ` Javier Carrasco [this message]
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=20240706-pcie-kirin-dev_err_probe-v1-2-56df797fb8ee@gmail.com \
--to=javier.carrasco.cruz@gmail.com \
--cc=Jonathan.Cameron@Huawei.com \
--cc=bhelgaas@google.com \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=robh@kernel.org \
--cc=songxiaowei@hisilicon.com \
--cc=wangbinghui@hisilicon.com \
/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