Commit ff01b916 authored by Roel Kluin's avatar Roel Kluin Committed by David S. Miller

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: default avatarRoel Kluin <roel.kluin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 46578a69
...@@ -806,7 +806,7 @@ static int cas_reset_mii_phy(struct cas *cp) ...@@ -806,7 +806,7 @@ static int cas_reset_mii_phy(struct cas *cp)
cas_phy_write(cp, MII_BMCR, BMCR_RESET); cas_phy_write(cp, MII_BMCR, BMCR_RESET);
udelay(100); udelay(100);
while (limit--) { while (--limit) {
val = cas_phy_read(cp, MII_BMCR); val = cas_phy_read(cp, MII_BMCR);
if ((val & BMCR_RESET) == 0) if ((val & BMCR_RESET) == 0)
break; break;
...@@ -979,7 +979,7 @@ static void cas_phy_init(struct cas *cp) ...@@ -979,7 +979,7 @@ static void cas_phy_init(struct cas *cp)
writel(val, cp->regs + REG_PCS_MII_CTRL); writel(val, cp->regs + REG_PCS_MII_CTRL);
limit = STOP_TRIES; limit = STOP_TRIES;
while (limit-- > 0) { while (--limit > 0) {
udelay(10); udelay(10);
if ((readl(cp->regs + REG_PCS_MII_CTRL) & if ((readl(cp->regs + REG_PCS_MII_CTRL) &
PCS_MII_RESET) == 0) PCS_MII_RESET) == 0)
......
...@@ -79,7 +79,7 @@ static int reset_one_mii_phy(struct mii_phy* phy, int phy_id) ...@@ -79,7 +79,7 @@ static int reset_one_mii_phy(struct mii_phy* phy, int phy_id)
udelay(100); udelay(100);
while (limit--) { while (--limit) {
val = __phy_read(phy, phy_id, MII_BMCR); val = __phy_read(phy, phy_id, MII_BMCR);
if ((val & BMCR_RESET) == 0) if ((val & BMCR_RESET) == 0)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment