Skip to content

Commit 7ef3275

Browse files
committed
Nuvoton: netsocket correction of judgment errors
1 parent f3f69b8 commit 7ef3275

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,14 @@ static int reset_phy(void)
7878
mdio_write(CONFIG_PHY_ADDR, MII_BMCR, BMCR_RESET);
7979

8080
delayCnt = 2000;
81-
while(delayCnt-- > 0) {
81+
while(delayCnt > 0) {
82+
delayCnt--;
8283
if((mdio_read(CONFIG_PHY_ADDR, MII_BMCR) & BMCR_RESET) == 0)
8384
break;
8485

8586
}
8687

87-
if(delayCnt == -1) {
88+
if(delayCnt == 0) {
8889
NU_DEBUGF(("Reset phy failed\n"));
8990
return(-1);
9091
}
@@ -99,13 +100,14 @@ static int reset_phy(void)
99100
mdio_write(CONFIG_PHY_ADDR, MII_BMCR, reg | BMCR_ANRESTART);
100101

101102
delayCnt = 200000;
102-
while(delayCnt-- > 0) {
103+
while(delayCnt > 0) {
104+
delayCnt--;
103105
if((mdio_read(CONFIG_PHY_ADDR, MII_BMSR) & (BMSR_ANEGCOMPLETE | BMSR_LSTATUS))
104106
== (BMSR_ANEGCOMPLETE | BMSR_LSTATUS))
105107
break;
106108
}
107109

108-
if(delayCnt == -1) {
110+
if(delayCnt == 0) {
109111
NU_DEBUGF(("AN failed. Set to 100 FULL\n"));
110112
EMAC->CTL |= (EMAC_CTL_OPMODE_Msk | EMAC_CTL_FUDUP_Msk);
111113
return(-1);

features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ static int reset_phy(void)
7878
mdio_write(CONFIG_PHY_ADDR, MII_BMCR, BMCR_RESET);
7979

8080
delayCnt = 2000;
81-
while(delayCnt-- > 0) {
81+
while(delayCnt > 0) {
82+
delayCnt--;
8283
if((mdio_read(CONFIG_PHY_ADDR, MII_BMCR) & BMCR_RESET) == 0)
8384
break;
8485

@@ -99,7 +100,8 @@ static int reset_phy(void)
99100
mdio_write(CONFIG_PHY_ADDR, MII_BMCR, reg | BMCR_ANRESTART);
100101

101102
delayCnt = 200000;
102-
while(delayCnt-- > 0) {
103+
while(delayCnt > 0) {
104+
delayCnt--;
103105
if((mdio_read(CONFIG_PHY_ADDR, MII_BMSR) & (BMSR_ANEGCOMPLETE | BMSR_LSTATUS))
104106
== (BMSR_ANEGCOMPLETE | BMSR_LSTATUS))
105107
break;

0 commit comments

Comments
 (0)