Skip to content

Commit 28e43a5

Browse files
RoelKluinRoland Dreier
authored andcommitted
RDMA/nes: Fix off-by-one bugs in reset_adapter_ne020() and init_serdes()
With a postfix increment, i is incremented one past 10K/5K before the loop ends, so the error messages will be displayed too soon if the test succeeds on the last iteration. Fix the comparisons to be > instead of >=. Signed-off-by: Roel Kluin <[email protected]> Signed-off-by: Roland Dreier <[email protected]>
1 parent 210af91 commit 28e43a5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/infiniband/hw/nes/nes_hw.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -667,15 +667,15 @@ static unsigned int nes_reset_adapter_ne020(struct nes_device *nesdev, u8 *OneG_
667667
i = 0;
668668
while (((nes_read32(nesdev->regs+NES_SOFTWARE_RESET) & 0x00000040) == 0) && i++ < 10000)
669669
mdelay(1);
670-
if (i >= 10000) {
670+
if (i > 10000) {
671671
nes_debug(NES_DBG_INIT, "Did not see full soft reset done.\n");
672672
return 0;
673673
}
674674

675675
i = 0;
676676
while ((nes_read_indexed(nesdev, NES_IDX_INT_CPU_STATUS) != 0x80) && i++ < 10000)
677677
mdelay(1);
678-
if (i >= 10000) {
678+
if (i > 10000) {
679679
printk(KERN_ERR PFX "Internal CPU not ready, status = %02X\n",
680680
nes_read_indexed(nesdev, NES_IDX_INT_CPU_STATUS));
681681
return 0;
@@ -701,7 +701,7 @@ static unsigned int nes_reset_adapter_ne020(struct nes_device *nesdev, u8 *OneG_
701701
i = 0;
702702
while (((nes_read32(nesdev->regs+NES_SOFTWARE_RESET) & 0x00000040) == 0) && i++ < 10000)
703703
mdelay(1);
704-
if (i >= 10000) {
704+
if (i > 10000) {
705705
nes_debug(NES_DBG_INIT, "Did not see port soft reset done.\n");
706706
return 0;
707707
}
@@ -711,7 +711,7 @@ static unsigned int nes_reset_adapter_ne020(struct nes_device *nesdev, u8 *OneG_
711711
while (((u32temp = (nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_STATUS0)
712712
& 0x0000000f)) != 0x0000000f) && i++ < 5000)
713713
mdelay(1);
714-
if (i >= 5000) {
714+
if (i > 5000) {
715715
nes_debug(NES_DBG_INIT, "Serdes 0 not ready, status=%x\n", u32temp);
716716
return 0;
717717
}
@@ -722,7 +722,7 @@ static unsigned int nes_reset_adapter_ne020(struct nes_device *nesdev, u8 *OneG_
722722
while (((u32temp = (nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_STATUS1)
723723
& 0x0000000f)) != 0x0000000f) && i++ < 5000)
724724
mdelay(1);
725-
if (i >= 5000) {
725+
if (i > 5000) {
726726
nes_debug(NES_DBG_INIT, "Serdes 1 not ready, status=%x\n", u32temp);
727727
return 0;
728728
}
@@ -792,7 +792,7 @@ static int nes_init_serdes(struct nes_device *nesdev, u8 hw_rev, u8 port_count,
792792
while (((u32temp = (nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_STATUS0)
793793
& 0x0000000f)) != 0x0000000f) && i++ < 5000)
794794
mdelay(1);
795-
if (i >= 5000) {
795+
if (i > 5000) {
796796
nes_debug(NES_DBG_PHY, "Init: serdes 0 not ready, status=%x\n", u32temp);
797797
return 1;
798798
}
@@ -815,7 +815,7 @@ static int nes_init_serdes(struct nes_device *nesdev, u8 hw_rev, u8 port_count,
815815
while (((u32temp = (nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_STATUS1)
816816
& 0x0000000f)) != 0x0000000f) && (i++ < 5000))
817817
mdelay(1);
818-
if (i >= 5000) {
818+
if (i > 5000) {
819819
printk("%s: Init: serdes 1 not ready, status=%x\n", __func__, u32temp);
820820
/* return 1; */
821821
}

0 commit comments

Comments
 (0)