PCI: mobiveil: Fix the valid check for inbound and outbound windows
authorHou Zhiqiang <Zhiqiang.Hou@nxp.com>
Fri, 5 Jul 2019 09:56:47 +0000 (17:56 +0800)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Mon, 8 Jul 2019 11:39:09 +0000 (12:39 +0100)
In program_ib/ob_windows() check the window index from the function
parameter instead of the total number of initialized windows to
determine if the specified window is valid.

Fixes: 9af6bcb11e12 ("PCI: mobiveil: Add Mobiveil PCIe Host Bridge IP driver")
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Minghuan Lian <Minghuan.Lian@nxp.com>
Reviewed-by: Subrahmanya Lingappa <l.subrahmanya@mobiveil.co.in>
drivers/pci/controller/pcie-mobiveil.c

index ccf9bb1008e19558cd7349ec248cfe6834a0afb9..76653d9464860d5aac406b7c1c0898588a891e75 100644 (file)
@@ -458,7 +458,7 @@ static void program_ib_windows(struct mobiveil_pcie *pcie, int win_num,
        u32 value;
        u64 size64 = ~(size - 1);
 
-       if ((pcie->ib_wins_configured + 1) > pcie->ppio_wins) {
+       if (win_num >= pcie->ppio_wins) {
                dev_err(&pcie->pdev->dev,
                        "ERROR: max inbound windows reached !\n");
                return;
@@ -491,7 +491,7 @@ static void program_ob_windows(struct mobiveil_pcie *pcie, int win_num,
 {
        u64 size64 = ~(size - 1);
 
-       if ((pcie->ob_wins_configured + 1) > pcie->apio_wins) {
+       if (win_num >= pcie->apio_wins) {
                dev_err(&pcie->pdev->dev,
                        "ERROR: max outbound windows reached !\n");
                return;