Skip to contentSkip to conversation

MIIPHYBB: Return 0xFFFF if the PHY is not asserting TA.

PATCH New Richard Retanubun 2 participants 2 messages Jul 2, 2009 – Jul 21, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIIPHYBB: Return 0xFFFF if the PHY is not asserting TA.

From d4c7dd98ac9a3f6fc4949079b84d7d811376cf3d Mon Sep 17 00:00:00 2001
From: Richard Retanubun <[email protected]>
Date: Thu, 2 Jul 2009 13:12:03 -0400
Subject: [PATCH] MIIPHYBB: Return 0xFFFF if the PHY is not asserting TA.

This patch sets the returned value to 0xFFFF if the PHY does not exist and does not assert Transfer Acknowledge. A NULL check for the value pointer is also added for buffer overflow protection.

Without this patch 'mii info' will show 'phantom' devices because the value will be not be initialized and return with some random value.

---
  drivers/net/phy/miiphybb.c |    7 +++++++
  1 files changed, 7 insertions(+), 0 deletions(-)
drivers/net/phy/miiphybb.c +7 -0
index e3c163a..b77c917 100644
@@ -127,6 +127,11 @@ int bb_miiphy_read (char *devname, unsigned char addr,
  	volatile ioport_t *iop = ioport_addr ((immap_t *) CONFIG_SYS_IMMR, MDIO_PORT);
  #endif
 
+	if (value == NULL) {
+		puts("NULL value pointer\n");
+		return (-1);
+	}
+
  	miiphy_pre (1, addr, reg);
 
  	/* tri-state our MDIO I/O pin so we can read */
@@ -145,6 +150,8 @@ int bb_miiphy_read (char *devname, unsigned char addr,
  			MDC (1);
  			MIIDELAY;
  		}
+		/* There is no PHY, set value to 0xFFFF and return */
+		*value = 0xFFFF;
  		return (-1);
  	}
 
Signature · 1 line
1.6.2.4
Applied
#1 lore raw

PATCH 1/1 MIIPHYBB: Return 0xFFFF if the PHY is not asserting TA.

Richard,

Quoted 35 lines · Richard Retanubun

From d4c7dd98ac9a3f6fc4949079b84d7d811376cf3d Mon Sep 17 00:00:00 2001
From: Richard Retanubun <[email protected]>
Date: Thu, 2 Jul 2009 13:12:03 -0400
Subject: [PATCH] MIIPHYBB: Return 0xFFFF if the PHY is not asserting TA.

This patch sets the returned value to 0xFFFF if the PHY does not exist and does not assert Transfer Acknowledge. A NULL check for the value pointer is also added for buffer overflow protection.

Without this patch 'mii info' will show 'phantom' devices because the value will be not be initialized and return with some random value.

---
 drivers/net/phy/miiphybb.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/net/phy/miiphybb.c +5 -0
index e3c163a..b77c917 100644
@@ -127,6 +127,11 @@ int bb_miiphy_read (char *devname, unsigned char 
 addr,
     volatile ioport_t *iop = ioport_addr ((immap_t *) 
 CONFIG_SYS_IMMR, MDIO_PORT);
 #endif
 
+    if (value == NULL) {
+        puts("NULL value pointer\n");
+        return (-1);
+    }
+
     miiphy_pre (1, addr, reg);
     /* tri-state our MDIO I/O pin so we can read */

drivers/net/phy/miiphybb.c int bb_miiphy_read (char *devname, unsigned char · line 157

Quoted 8 lines
drivers/net/phy/miiphybb.c +2 -0
@@ -145,6 +150,8 @@ int bb_miiphy_read (char *devname, unsigned char 
 addr,
             MDC (1);
             MIIDELAY;
         }
+        /* There is no PHY, set value to 0xFFFF and return */
+        *value = 0xFFFF;
         return (-1);
     }

Applied to net repo. Please add SOB next time and send e-mail as plain text.

regards,
Ben