From: "Sherry Sun (OSS)" <sherry.sun@oss•nxp.com>
To: hongxing.zhu@nxp•com, l.stach@pengutronix•de, Frank.Li@nxp•com,
bhelgaas@google•com, lpieralisi@kernel•org,
kwilczynski@kernel•org, mani@kernel•org, robh@kernel•org,
s.hauer@pengutronix•de, kernel@pengutronix•de,
festevam@gmail•com, will@kernel•org
Cc: imx@lists•linux.dev, linux-pci@vger•kernel.org,
linux-arm-kernel@lists•infradead.org,
linux-kernel@vger•kernel.org, sherry.sun@nxp•com
Subject: [PATCH 1/2] PCI: host-generic: Simplify return value handling in pci_host_common_parse_port(s)
Date: Fri, 22 May 2026 11:43:43 +0800 [thread overview]
Message-ID: <20260522034344.1147775-2-sherry.sun@oss.nxp.com> (raw)
In-Reply-To: <20260522034344.1147775-1-sherry.sun@oss.nxp.com>
From: Sherry Sun <sherry.sun@nxp•com>
The pci_host_common_parse_port() shouldn't check the RC-level binding.
That's a policy decision that belongs to the caller, not this common
helper.
Simplify pci_host_common_parse_port() to only parses properties from the
Root Port(and its children) without checking the RC node. Also change
pci_host_common_parse_ports() to return 0 when no ports are found, since
it is not an error.
So now both functions won't return failure for "property not found" or
"port not found", they purely returns 0 on success and a negative error
code on real failures.
Signed-off-by: Sherry Sun <sherry.sun@nxp•com>
---
drivers/pci/controller/pci-host-common.c | 29 ++++--------------------
1 file changed, 5 insertions(+), 24 deletions(-)
diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c
index 67455caaf9e6..7ce5a939e3d9 100644
--- a/drivers/pci/controller/pci-host-common.c
+++ b/drivers/pci/controller/pci-host-common.c
@@ -108,8 +108,7 @@ static int pci_host_common_parse_perst(struct device *dev,
* dependencies and the driver may fail to operate if required resources
* are missing.
*
- * Return: 0 on success, -ENODEV if PERST# found in RC node (legacy binding
- * should be used), Other negative error codes on failure.
+ * Return: 0 on success, negative error codes on failure.
*/
static int pci_host_common_parse_port(struct device *dev,
struct pci_host_bridge *bridge,
@@ -128,22 +127,6 @@ static int pci_host_common_parse_port(struct device *dev,
if (ret)
return ret;
- /*
- * 1. PERST# found in RP or its child nodes - list is not empty,
- * continue
- *
- * 2. PERST# not found in RP/children, but found in RC node -
- * return -ENODEV to fallback legacy binding
- *
- * 3. PERST# not found anywhere - list is empty, continue (optional
- * PERST#)
- */
- if (list_empty(&port->perst)) {
- if (of_property_present(dev->of_node, "reset-gpios") ||
- of_property_present(dev->of_node, "reset-gpio"))
- return -ENODEV;
- }
-
INIT_LIST_HEAD(&port->list);
list_add_tail(&port->list, &bridge->ports);
@@ -158,13 +141,11 @@ static int pci_host_common_parse_port(struct device *dev,
* Iterate through child nodes of the host bridge and parse Root Port
* properties (currently only reset GPIOs).
*
- * Return: 0 on success, -ENODEV if no ports found or PERST# found in RC
- * node (legacy binding should be used), Other negative error codes on
- * failure.
+ * Return: 0 on success, negative error codes on failure.
*/
int pci_host_common_parse_ports(struct device *dev, struct pci_host_bridge *bridge)
{
- int ret = -ENODEV;
+ int ret = 0;
for_each_available_child_of_node_scoped(dev->of_node, of_port) {
if (!of_node_is_type(of_port, "pci"))
@@ -174,8 +155,8 @@ int pci_host_common_parse_ports(struct device *dev, struct pci_host_bridge *brid
goto err_cleanup;
}
- if (ret)
- return ret;
+ if (list_empty(&bridge->ports))
+ return 0;
return devm_add_action_or_reset(dev, pci_host_common_delete_ports,
&bridge->ports);
--
2.37.1
next prev parent reply other threads:[~2026-05-22 3:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 3:43 [PATCH 0/2] PCI: imx6: Improve PERST# fallback logic Sherry Sun (OSS)
2026-05-22 3:43 ` Sherry Sun (OSS) [this message]
2026-05-22 6:05 ` [PATCH 1/2] PCI: host-generic: Simplify return value handling in pci_host_common_parse_port(s) Hongxing Zhu
2026-05-22 6:20 ` Sherry Sun
2026-05-22 3:43 ` [PATCH 2/2] PCI: imx6: Add imx_pcie_perst_found() to inspect the parsed result Sherry Sun (OSS)
2026-05-22 6:05 ` Hongxing Zhu
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=20260522034344.1147775-2-sherry.sun@oss.nxp.com \
--to=sherry.sun@oss$(echo .)nxp.com \
--cc=Frank.Li@nxp$(echo .)com \
--cc=bhelgaas@google$(echo .)com \
--cc=festevam@gmail$(echo .)com \
--cc=hongxing.zhu@nxp$(echo .)com \
--cc=imx@lists$(echo .)linux.dev \
--cc=kernel@pengutronix$(echo .)de \
--cc=kwilczynski@kernel$(echo .)org \
--cc=l.stach@pengutronix$(echo .)de \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-pci@vger$(echo .)kernel.org \
--cc=lpieralisi@kernel$(echo .)org \
--cc=mani@kernel$(echo .)org \
--cc=robh@kernel$(echo .)org \
--cc=s.hauer@pengutronix$(echo .)de \
--cc=sherry.sun@nxp$(echo .)com \
--cc=will@kernel$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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