[U-Boot] [PATCH 2/3] pci: pcie_fsl: reorder addr check function

Heiko Schocher hs at denx.de
Wed Oct 9 04:37:21 UTC 2019


reorder checks in fsl_pcie_addr_valid(). Check first
stuff, we also can check when we use driver for PCI devices.

Signed-off-by: Heiko Schocher <hs at denx.de>
---

 drivers/pci/pcie_fsl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pcie_fsl.c b/drivers/pci/pcie_fsl.c
index ada6e12e2f..05b2522dac 100644
--- a/drivers/pci/pcie_fsl.c
+++ b/drivers/pci/pcie_fsl.c
@@ -30,13 +30,13 @@ static int fsl_pcie_addr_valid(struct fsl_pcie *pcie, pci_dev_t bdf)
 	if (PCI_BUS(bdf) < bus->seq)
 		return -EINVAL;
 
-	if (PCI_BUS(bdf) > bus->seq && (!fsl_pcie_link_up(pcie) || pcie->mode))
+	if (PCI_BUS(bdf) == (bus->seq + 1) && (PCI_DEV(bdf) > 0))
 		return -EINVAL;
 
-	if (PCI_BUS(bdf) == bus->seq && (PCI_DEV(bdf) > 0 || PCI_FUNC(bdf) > 0))
+	if (PCI_BUS(bdf) > bus->seq && (!fsl_pcie_link_up(pcie) || pcie->mode))
 		return -EINVAL;
 
-	if (PCI_BUS(bdf) == (bus->seq + 1) && (PCI_DEV(bdf) > 0))
+	if (PCI_BUS(bdf) == bus->seq && (PCI_DEV(bdf) > 0 || PCI_FUNC(bdf) > 0))
 		return -EINVAL;
 
 	return 0;
-- 
2.21.0



More information about the U-Boot mailing list