| From 22b72b6683c75f8c7a349f3dac5f1d107e81f8ae Mon Sep 17 00:00:00 2001 |
| From: Dan Carpenter <dan.carpenter@oracle.com> |
| Date: Wed, 9 Dec 2015 21:07:25 +0800 |
| Subject: [PATCH 4/7] PCI: altera: Fix loop in tlp_read_packet() |
| |
| TLP_LOOP is 500 and the "loop" variable was a u8 so "loop < TLP_LOOP" is |
| always true. We only need this condition to work if there is a problem so |
| it would have been easy to miss this in testing. |
| |
| Make it a normal for loop with "int i" instead of over thinking things and |
| making it complicated. |
| |
| Fixes: 6bb4dd154ae8 ("PCI: altera: Add Altera PCIe host controller driver") |
| Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> |
| Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> |
| Acked-by: Ley Foon Tan <lftan@altera.com> |
| --- |
| drivers/pci/host/pcie-altera.c | 4 ++-- |
| 1 file changed, 2 insertions(+), 2 deletions(-) |
| |
| diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c |
| index 5d018092a484..0ff6b0053e82 100644 |
| --- a/drivers/pci/host/pcie-altera.c |
| +++ b/drivers/pci/host/pcie-altera.c |
| @@ -176,7 +176,7 @@ static bool altera_pcie_valid_config(struct altera_pcie *pcie, |
| |
| static int tlp_read_packet(struct altera_pcie *pcie, u32 *value) |
| { |
| - u8 loop; |
| + int i; |
| bool sop = 0; |
| u32 ctrl; |
| u32 reg0, reg1; |
| @@ -185,7 +185,7 @@ static int tlp_read_packet(struct altera_pcie *pcie, u32 *value) |
| * Minimum 2 loops to read TLP headers and 1 loop to read data |
| * payload. |
| */ |
| - for (loop = 0; loop < TLP_LOOP; loop++) { |
| + for (i = 0; i < TLP_LOOP; i++) { |
| ctrl = cra_readl(pcie, RP_RXCPL_STATUS); |
| if ((ctrl & RP_RXCPL_SOP) || (ctrl & RP_RXCPL_EOP) || sop) { |
| reg0 = cra_readl(pcie, RP_RXCPL_REG0); |
| -- |
| 2.6.3 |
| |