From patchwork Wed Oct 9 04:37:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Schocher X-Patchwork-Id: 1173578 X-Patchwork-Delegate: priyanka.jain@nxp.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46p1gZ16BNz9sDQ for ; Wed, 9 Oct 2019 15:38:34 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id D8BDEC21F9E; Wed, 9 Oct 2019 04:38:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 71C3FC21E2F; Wed, 9 Oct 2019 04:38:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7A927C21F02; Wed, 9 Oct 2019 04:37:46 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by lists.denx.de (Postfix) with ESMTPS id 1F0FAC21F6A for ; Wed, 9 Oct 2019 04:37:46 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 46p1fd6qc1z1rSBt; Wed, 9 Oct 2019 06:37:45 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 46p1fd6crgz1qqkL; Wed, 9 Oct 2019 06:37:45 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id hfgr2CtyrAHg; Wed, 9 Oct 2019 06:37:45 +0200 (CEST) X-Auth-Info: 4SP6CP09zNBFnT4+RvHXxMwTA3qof2AXXDZccWN4j9k= Received: from mail-internal.denx.de (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Wed, 9 Oct 2019 06:37:45 +0200 (CEST) Received: from pollux.denx.de (pollux [192.168.1.1]) by mail-internal.denx.de (Postfix) with ESMTP id 1CFF0180714; Wed, 9 Oct 2019 06:37:29 +0200 (CEST) Received: by pollux.denx.de (Postfix, from userid 515) id 1B46F1A00A0; Wed, 9 Oct 2019 06:37:29 +0200 (CEST) From: Heiko Schocher To: U-Boot Mailing List Date: Wed, 9 Oct 2019 06:37:21 +0200 Message-Id: <20191009043722.3413717-3-hs@denx.de> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191009043722.3413717-1-hs@denx.de> References: <20191009043722.3413717-1-hs@denx.de> MIME-Version: 1.0 Cc: Hou Zhiqiang Subject: [U-Boot] [PATCH 2/3] pci: pcie_fsl: reorder addr check function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- 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;