Skip to content

Commit 7f52f31

Browse files
Dan Carpenterbjorn-helgaas
authored andcommitted
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>
1 parent 3845d29 commit 7f52f31

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/pci/host/pcie-altera.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static bool altera_pcie_valid_config(struct altera_pcie *pcie,
166166

167167
static int tlp_read_packet(struct altera_pcie *pcie, u32 *value)
168168
{
169-
u8 loop;
169+
int i;
170170
bool sop = 0;
171171
u32 ctrl;
172172
u32 reg0, reg1;
@@ -175,7 +175,7 @@ static int tlp_read_packet(struct altera_pcie *pcie, u32 *value)
175175
* Minimum 2 loops to read TLP headers and 1 loop to read data
176176
* payload.
177177
*/
178-
for (loop = 0; loop < TLP_LOOP; loop++) {
178+
for (i = 0; i < TLP_LOOP; i++) {
179179
ctrl = cra_readl(pcie, RP_RXCPL_STATUS);
180180
if ((ctrl & RP_RXCPL_SOP) || (ctrl & RP_RXCPL_EOP) || sop) {
181181
reg0 = cra_readl(pcie, RP_RXCPL_REG0);

0 commit comments

Comments
 (0)