]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
net: Provide a function to get the current MAC address
authorJoe Hershberger <joe.hershberger@ni.com>
Sun, 22 Mar 2015 22:09:00 +0000 (17:09 -0500)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 8 Sep 2015 19:47:30 +0000 (21:47 +0200)
The current implementation exposes the eth_device struct to code that
needs to access the MAC address.  Add a wrapper function for this to
abstract away the pointer for this operation.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/mips/mach-au1x00/au1x00_eth.c
arch/powerpc/cpu/mpc8260/ether_fcc.c
arch/powerpc/cpu/mpc85xx/ether_fcc.c
arch/powerpc/cpu/mpc8xx/scc.c
include/net.h
net/net.c

index 39c5b6bc4a8fcb896b3efc7e780379ddb1d6f87d..a47f08832973a2d71bdfd5cd6a1fdc30bcaa84c6 100644 (file)
@@ -238,7 +238,7 @@ static int au1x00_init(struct eth_device* dev, bd_t * bd){
        }
 
        /* Put mac addr in little endian */
-#define ea eth_get_dev()->enetaddr
+#define ea eth_get_ethaddr()
        *mac_addr_high  =       (ea[5] <<  8) | (ea[4]      ) ;
        *mac_addr_low   =       (ea[3] << 24) | (ea[2] << 16) |
                (ea[1] <<  8) | (ea[0]      ) ;
index f9f15b59e539cba75c143cb486a0a01a1b43a35f..f777ba14cc6aefd5589671946bbc438457a4f96b 100644 (file)
@@ -299,7 +299,7 @@ static int fec_init(struct eth_device* dev, bd_t *bis)
      * it unique by setting a few bits in the upper byte of the
      * non-static part of the address.
      */
-#define ea eth_get_dev()->enetaddr
+#define ea eth_get_ethaddr()
     pram_ptr->fen_paddrh = (ea[5] << 8) + ea[4];
     pram_ptr->fen_paddrm = (ea[3] << 8) + ea[2];
     pram_ptr->fen_paddrl = (ea[1] << 8) + ea[0];
index 166dc9ed1767e79508cc7443ece792535110c343..58d4bfbecc9021f4ecfe0d3c98a6551526af4103 100644 (file)
@@ -338,7 +338,7 @@ static int fec_init(struct eth_device* dev, bd_t *bis)
      * it unique by setting a few bits in the upper byte of the
      * non-static part of the address.
      */
-#define ea eth_get_dev()->enetaddr
+#define ea eth_get_ethaddr()
     pram_ptr->fen_paddrh = (ea[5] << 8) + ea[4];
     pram_ptr->fen_paddrm = (ea[3] << 8) + ea[2];
     pram_ptr->fen_paddrl = (ea[1] << 8) + ea[0];
index 251966b4a07153ca799c476a07b87cfbf6217d25..66e4014f7586d4bb7731b9978d54f24f6f62b6c1 100644 (file)
@@ -339,7 +339,7 @@ static int scc_init (struct eth_device *dev, bd_t * bis)
        pram_ptr->sen_gaddr3 = 0x0;     /* Group Address Filter 3 (unused) */
        pram_ptr->sen_gaddr4 = 0x0;     /* Group Address Filter 4 (unused) */
 
-#define ea eth_get_dev()->enetaddr
+#define ea eth_get_ethaddr()
        pram_ptr->sen_paddrh = (ea[5] << 8) + ea[4];
        pram_ptr->sen_paddrm = (ea[3] << 8) + ea[2];
        pram_ptr->sen_paddrl = (ea[1] << 8) + ea[0];
index e9515c80328eac4fcffd0fe5df599818fdaa68f0..cd3f6f0ae9cf3a4b7524e055bb0beabd63c8e6fe 100644 (file)
@@ -111,6 +111,14 @@ struct eth_device *eth_get_dev(void)
 {
        return eth_current;
 }
+
+static inline unsigned char *eth_get_ethaddr(void)
+{
+       if (eth_current)
+               return eth_current->enetaddr;
+       return NULL;
+}
+
 extern struct eth_device *eth_get_dev_by_name(const char *devname);
 extern struct eth_device *eth_get_dev_by_index(int index); /* get dev @ index */
 extern int eth_get_dev_index(void);            /* get the device index */
index cd3bc931874fa065a8fab4e1aaa2017806f2798a..f98877db7926cb8d7a13334c43fa403c80a4453c 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -275,7 +275,7 @@ static void NetInitLoop(void)
                env_changed_id = env_id;
        }
        if (eth_get_dev())
-               memcpy(NetOurEther, eth_get_dev()->enetaddr, 6);
+               memcpy(NetOurEther, eth_get_ethaddr(), 6);
 
        return;
 }