diff mbox

[4/4] drivers/net/fec: Don't mess with configured MAC addresses.

Message ID e7cec31bec3eb7dad56688c4390a59f99625ea83.1300724245.git.LW@KARO-electronics.de
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Lothar Waßmann March 22, 2011, 10 a.m. UTC
The FEC driver currently uses the MAC address assigned to the first
interface incremented by one for the second interface.

Change this to be able to configure distinct MAC addresses via
platform_data.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 drivers/net/fec.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

Comments

Shawn Guo March 22, 2011, 12:33 p.m. UTC | #1
On Tue, Mar 22, 2011 at 11:00:02AM +0100, Lothar Waßmann wrote:
> The FEC driver currently uses the MAC address assigned to the first
> interface incremented by one for the second interface.
> 
> Change this to be able to configure distinct MAC addresses via
> platform_data.
> 
> Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>

Acked-by: <shawn.guo@freescale.com>
diff mbox

Patch

diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 3666524..9d89e99 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -736,7 +736,7 @@  static void __inline__ fec_get_mac(struct net_device *ndev)
 {
 	struct fec_enet_private *fep = netdev_priv(ndev);
 	struct fec_platform_data *pdata = fep->pdev->dev.platform_data;
-	unsigned char *iap, tmpaddr[ETH_ALEN];
+	unsigned char iap[ETH_ALEN], tmpaddr[ETH_ALEN];
 
 	/*
 	 * try to get mac address in following order:
@@ -744,7 +744,10 @@  static void __inline__ fec_get_mac(struct net_device *ndev)
 	 * 1) module parameter via kernel command line in form
 	 *    fec.macaddr=0x00,0x04,0x9f,0x01,0x30,0xe0
 	 */
-	iap = macaddr;
+	if (fep->pdev->id == 0)
+		memcpy(iap, macaddr, ETH_ALEN);
+	else
+		memset(iap, 0, ETH_ALEN);
 
 	/*
 	 * 2) from flash or fuse (via platform data)
@@ -767,14 +770,10 @@  static void __inline__ fec_get_mac(struct net_device *ndev)
 			be32_to_cpu(readl(fep->hwp + FEC_ADDR_LOW));
 		*((unsigned short *) &tmpaddr[4]) =
 			be16_to_cpu(readl(fep->hwp + FEC_ADDR_HIGH) >> 16);
-		iap = &tmpaddr[0];
+		memcpy(iap, tmpaddr, ETH_ALEN);
 	}
 
 	memcpy(ndev->dev_addr, iap, ETH_ALEN);
-
-	/* Adjust MAC if using macaddr */
-	if (iap == macaddr)
-		 ndev->dev_addr[ETH_ALEN-1] = macaddr[ETH_ALEN-1] + fep->pdev->id;
 }
 
 /* ------------------------------------------------------------------------- */