Subject: [PATCH] Only config/restart ANEG the first time ethernet is used.

From: Joakim Tjernlund <[email-masked]>
Date: Tue, 18 Dec 2007 16:21:19 +0100

---
 drivers/qe/uec.c |   27 +++++++++++++--------------
 1 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/qe/uec.c b/drivers/qe/uec.c
index 4908798..db19290 100644
--- a/drivers/qe/uec.c
+++ b/drivers/qe/uec.c
@@ -1123,6 +1123,14 @@ static int uec_init(struct eth_device* dev, bd_t *bd)
 			printf("%s: Cannot initialize PHY, aborting.\n", dev->name);
 			return err;
 		}
+		curphy = uec->mii_info->phyinfo;
+		if (curphy->config_aneg) {
+			err = curphy->config_aneg(uec->mii_info);
+			if (err) {
+				printf("%s: Can't negotiate PHY\n", dev->name);
+				return err;
+			}
+		}
 
 		uec->the_first_run = 1;
 	}
@@ -1135,15 +1143,12 @@ static int uec_init(struct eth_device* dev, bd_t *bd)
 	}
 	uec_set_mac_address(uec, dev->enetaddr);
 
-	curphy = uec->mii_info->phyinfo;
-
-	if (curphy->config_aneg) {
-		err = curphy->config_aneg(uec->mii_info);
-		if (err) {
-			printf("%s: Can't negotiate PHY\n", dev->name);
-			return err;
-		}
+	err = uec_open(uec, COMM_DIR_RX_AND_TX);
+	if (err) {
+		printf("%s: cannot enable UEC device\n", dev->name);
+		return 1;
 	}
+	curphy = uec->mii_info->phyinfo;
 
 	/* Give PHYs up to 5 sec to report a link */
 	i = 50;
@@ -1156,12 +1161,6 @@ static int uec_init(struct eth_device* dev, bd_t *bd)
 		printf("warning: %s: timeout on PHY link\n", dev->name);

-	err = uec_open(uec, COMM_DIR_RX_AND_TX);
-	if (err) {
-		printf("%s: cannot enable UEC device\n", dev->name);
-		return 1;
-	}
-
 	phy_change(dev);
 
 	return !uec->mii_info->link; /* return 0 if there is a link */
-- 
1.5.3.7