Skip to contentSkip to conversation

Fix crash scenario when TSEC has no PHY

PATCH New Ben Warren 2 participants 2 messages Oct 26, 2006

lore
Share & tools
lore

Ben Warren

author
#0 lore raw

PATCH 1/1 Fix crash scenario when TSEC has no PHY

This fixes the case where either no PHY is attached to a TSEC (e.g. a switch is connected via RMII) or if the PHY is defective/incorrectly configured. Previous behavior was crash.

---
 drivers/tsec.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/tsec.c +6 -3
index 770517b..400e593 100644
@@ -313,7 +313,8 @@ static int init_phy(struct eth_device *d
 	 * PHY */
 	curphy = get_phy_info(dev);
 
-	if (NULL == curphy) {
+	if (curphy == NULL) {
+		priv->phyinfo = NULL;
 		printf("%s: No PHY found\n", dev->name);
 
 		return 0;
@@ -661,7 +662,8 @@ static void startup_tsec(struct eth_devi
 	rtx.txbd[TX_BUF_CNT - 1].status |= TXBD_WRAP;
 
 	/* Start up the PHY */
-	phy_run_commands(priv, priv->phyinfo->startup);
+	if(priv->phyinfo)
+		phy_run_commands(priv, priv->phyinfo->startup);
 	adjust_link(dev);
 
 	/* Enable Transmit and Receive */
@@ -765,7 +767,8 @@ static void tsec_halt(struct eth_device 
 	regs->maccfg1 &= ~(MACCFG1_TX_EN | MACCFG1_RX_EN);
 
 	/* Shut down the PHY, as needed */
-	phy_run_commands(priv, priv->phyinfo->shutdown);
+	if(priv->phyinfo)
+		phy_run_commands(priv, priv->phyinfo->shutdown);
 }
 
 struct phy_info phy_info_M88E1011S = {
Signature · 1 line
1.4.1
#1 lore raw

PATCH 1/1 Fix crash scenario when TSEC has no PHY

Quoted 3 lines · In message <[email protected]> you wrote:

This fixes the case where either no PHY is attached to a TSEC (e.g. a switch is connected via RMII) or if the PHY is defective/incorrectly configured. Previous behavior was crash.

Thanks, applied.

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Technology is dominated by those who manage what they do  not  under-
stand.