Skip to content

Commit ff01b91

Browse files
RoelKluindavem330
authored andcommitted
cassini/sungem: limit reaches -1, but 0 tested
while (limit--) if (test()) break; if (limit <= 0) goto test_failed; In the last iteration, limit is decremented after the test to 0. If just thereafter test() succeeds and a break occurs, the goto still occurs because limit is 0. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 46578a6 commit ff01b91

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎drivers/net/cassini.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ static int cas_reset_mii_phy(struct cas *cp)
806806

807807
cas_phy_write(cp, MII_BMCR, BMCR_RESET);
808808
udelay(100);
809-
while (limit--) {
809+
while (--limit) {
810810
val = cas_phy_read(cp, MII_BMCR);
811811
if ((val & BMCR_RESET) == 0)
812812
break;
@@ -979,7 +979,7 @@ static void cas_phy_init(struct cas *cp)
979979
writel(val, cp->regs + REG_PCS_MII_CTRL);
980980

981981
limit = STOP_TRIES;
982-
while (limit-- > 0) {
982+
while (--limit > 0) {
983983
udelay(10);
984984
if ((readl(cp->regs + REG_PCS_MII_CTRL) &
985985
PCS_MII_RESET) == 0)

‎drivers/net/sungem_phy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static int reset_one_mii_phy(struct mii_phy* phy, int phy_id)
7979

8080
udelay(100);
8181

82-
while (limit--) {
82+
while (--limit) {
8383
val = __phy_read(phy, phy_id, MII_BMCR);
8484
if ((val & BMCR_RESET) == 0)
8585
break;

0 commit comments

Comments
 (0)