Skip to contentSkip to conversation

b44: Truncate PHY address

PATCH Applied Michael Buesch 2 participants 2 messages Mar 25, 2008 – Mar 26, 2008

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

PATCH 1/1 b44: Truncate PHY address

Some ROMs on embedded devices store incorrect values for the PHY address of the ethernet device.
It looks like the number is sign-extended.
Truncate the value by applying the PHY-address mask to it. The patch was tested on a bcm47xx embedded system (where the bug triggers) and a bcm4400 PCI card.

---

Jeff, this is a bugfix for 2.6.25.

drivers/net/b44.c +5 -0
Index: wireless-testing/drivers/net/b44.c
===================================================================
@@ -2082,6 +2082,11 @@ static int __devinit b44_get_invariants(
 		addr = sdev->bus->sprom.et0mac;
 		bp->phy_addr = sdev->bus->sprom.et0phyaddr;
 	}
+	/* Some ROMs have buggy PHY addresses with the high
+	 * bits set (sign extension?). Truncate them to a
+	 * valid PHY address. */
+	bp->phy_addr &= 0x1F;
+
 	memcpy(bp->dev->dev_addr, addr, 6);
 
 	if (!is_valid_ether_addr(&bp->dev->dev_addr[0])){
Signature · 1 line
Greetings Michael.
Applied
#1 lore raw
Quoted 19 lines · Michael Buesch

Some ROMs on embedded devices store incorrect values for the PHY address of the ethernet device.
It looks like the number is sign-extended.
Truncate the value by applying the PHY-address mask to it. The patch was tested on a bcm47xx embedded system (where the bug triggers) and a bcm4400 PCI card.

---

Jeff, this is a bugfix for 2.6.25.

Index: wireless-testing/drivers/net/b44.c
===================================================================

drivers/net/b44.c static int __devinit b44_get_invariants( · line 2090

Quoted 9 lines
drivers/net/b44.c +5 -0
@@ -2082,6 +2082,11 @@ static int __devinit b44_get_invariants(
 		addr = sdev->bus->sprom.et0mac;
 		bp->phy_addr = sdev->bus->sprom.et0phyaddr;
 	}
+	/* Some ROMs have buggy PHY addresses with the high
+	 * bits set (sign extension?). Truncate them to a
+	 * valid PHY address. */
+	bp->phy_addr &= 0x1F;
+
 	memcpy(bp->dev->dev_addr, addr, 6);

applied