Skip to contentSkip to conversation

METH: fix MAC address handling

PATCH Applied Thomas Bogendoerfer 2 participants 4 messages Jan 5, 2008 – Jan 7, 2008

Subsystems (3)
lore
Share & tools
lore

Thomas Bogendoerfer

author maintainer
#0 lore raw

PATCH 1/1 METH: fix MAC address handling

meth didn't set a valid mac address during probing, but later during open. Newer kernel refuse to open device with 00:00:00:00:00:00 as mac address -> dead ethernet. This patch sets the mac address in the probe function and uses only the mac address from the netdevice struct when setting up the hardware.

---

 drivers/net/meth.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
drivers/net/meth.c +7 -3
index 0c89b02..cdaa8fc 100644
@@ -95,11 +95,14 @@ static inline void load_eaddr(struct net_device *dev)
 {
 	int i;
 	DECLARE_MAC_BUF(mac);
+	u64 macaddr;
 
-	for (i = 0; i < 6; i++)
-		dev->dev_addr[i] = o2meth_eaddr[i];
 	DPRINTK("Loading MAC Address: %s\n", print_mac(mac, dev->dev_addr));
-	mace->eth.mac_addr = (*(unsigned long*)o2meth_eaddr) >> 16;
+	macaddr = 0;
+	for (i = 0; i < 6; i++)
+		macaddr |= dev->dev_addr[i] << ((5 - i) * 8);
+
+	mace->eth.mac_addr = macaddr;
 }
 
 /*
@@ -794,6 +797,7 @@ static int __init meth_probe(struct platform_device *pdev)
 #endif
 	dev->irq	     = MACE_ETHERNET_IRQ;
 	dev->base_addr	     = (unsigned long)&mace->eth;
+	memcpy(dev->dev_addr, o2meth_eaddr, 6);
 
 	priv = netdev_priv(dev);
 	spin_lock_init(&priv->meth_lock);
maintainer Applied
#1 lore raw

From: Thomas Bogendoerfer <[email protected]>
Date: Sat, 5 Jan 2008 23:48:42 +0100 (CET)

Quoted 7 lines

meth didn't set a valid mac address during probing, but later during open. Newer kernel refuse to open device with 00:00:00:00:00:00 as mac address -> dead ethernet. This patch sets the mac address in the probe function and uses only the mac address from the netdevice struct when setting up the hardware.

Applied, thanks.

Quoted 4 lines
drivers/net/meth.c +1 -2
+	u64 macaddr;
 
-	for (i = 0; i < 6; i++)
-		dev->dev_addr[i] = o2meth_eaddr[i];

drivers/net/meth.c static inline void load_eaddr(struct net_device *dev) · line 108

Quoted 10 lines
drivers/net/meth.c +5 -1
 	DPRINTK("Loading MAC Address: %s\n", print_mac(mac, dev->dev_addr));
-	mace->eth.mac_addr = (*(unsigned long*)o2meth_eaddr) >> 16;
+	macaddr = 0;
+	for (i = 0; i < 6; i++)
+		macaddr |= dev->dev_addr[i] << ((5 - i) * 8);
+
+	mace->eth.mac_addr = macaddr;
 }
 
 /*

Can you double-check that this conversion is equivalent.

I know that this whole driver is full of assumptions about the endianness of the system this chip is found on, so I'm only interested in if the transformation is equivalent and the driver will keep working properly.

Thanks.

author maintainer
#2 lore raw
Quoted 13 lines · David Miller
Quoted 13 lines
drivers/net/meth.c +6 -3
+	u64 macaddr;
 
-	for (i = 0; i < 6; i++)
-		dev->dev_addr[i] = o2meth_eaddr[i];
 	DPRINTK("Loading MAC Address: %s\n", print_mac(mac, dev->dev_addr));
-	mace->eth.mac_addr = (*(unsigned long*)o2meth_eaddr) >> 16;
+	macaddr = 0;
+	for (i = 0; i < 6; i++)
+		macaddr |= dev->dev_addr[i] << ((5 - i) * 8);
+
+	mace->eth.mac_addr = macaddr;
 }
Quoted 3 lines
Quoted 1 line

/*

Can you double-check that this conversion is equivalent.

yes, I did.

Quoted 4 lines

I know that this whole driver is full of assumptions about the endianness of the system this chip is found on, so I'm only interested in if the transformation is equivalent and the driver will keep working properly.

I've tested the driver and it's still working :-)

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]
maintainer
#3 lore raw

From: [email protected] (Thomas Bogendoerfer)
Date: Sun, 6 Jan 2008 12:38:16 +0100

Quoted 7 lines · David Miller
Quoted 4 lines

I know that this whole driver is full of assumptions about the endianness of the system this chip is found on, so I'm only interested in if the transformation is equivalent and the driver will keep working properly.

I've tested the driver and it's still working :-)

Great :)