OSDN Git Service

net: dsa: b53: Utilize common helpers for u64/MAC
authorFlorian Fainelli <f.fainelli@gmail.com>
Thu, 5 Jan 2017 19:08:58 +0000 (11:08 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 6 Jan 2017 20:51:29 +0000 (15:51 -0500)
Utilize the two functions recently introduced: u64_to_ether() and
ether_to_u64() instead of our own versions.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/b53/b53_common.c
drivers/net/dsa/b53/b53_priv.h

index 947adda..d5370c2 100644 (file)
@@ -1137,7 +1137,7 @@ static int b53_arl_op(struct b53_device *dev, int op, int port,
        int ret;
 
        /* Convert the array into a 64-bit MAC */
-       mac = b53_mac_to_u64(addr);
+       mac = ether_addr_to_u64(addr);
 
        /* Perform a read for the given MAC and VID */
        b53_write48(dev, B53_ARLIO_PAGE, B53_MAC_ADDR_IDX, mac);
index f192a67..1f4b07b 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/mutex.h>
 #include <linux/phy.h>
+#include <linux/etherdevice.h>
 #include <net/dsa.h>
 
 #include "b53_regs.h"
@@ -325,25 +326,6 @@ struct b53_arl_entry {
        u8 is_static:1;
 };
 
-static inline void b53_mac_from_u64(u64 src, u8 *dst)
-{
-       unsigned int i;
-
-       for (i = 0; i < ETH_ALEN; i++)
-               dst[ETH_ALEN - 1 - i] = (src >> (8 * i)) & 0xff;
-}
-
-static inline u64 b53_mac_to_u64(const u8 *src)
-{
-       unsigned int i;
-       u64 dst = 0;
-
-       for (i = 0; i < ETH_ALEN; i++)
-               dst |= (u64)src[ETH_ALEN - 1 - i] << (8 * i);
-
-       return dst;
-}
-
 static inline void b53_arl_to_entry(struct b53_arl_entry *ent,
                                    u64 mac_vid, u32 fwd_entry)
 {
@@ -352,14 +334,14 @@ static inline void b53_arl_to_entry(struct b53_arl_entry *ent,
        ent->is_valid = !!(fwd_entry & ARLTBL_VALID);
        ent->is_age = !!(fwd_entry & ARLTBL_AGE);
        ent->is_static = !!(fwd_entry & ARLTBL_STATIC);
-       b53_mac_from_u64(mac_vid, ent->mac);
+       u64_to_ether_addr(mac_vid, ent->mac);
        ent->vid = mac_vid >> ARLTBL_VID_S;
 }
 
 static inline void b53_arl_from_entry(u64 *mac_vid, u32 *fwd_entry,
                                      const struct b53_arl_entry *ent)
 {
-       *mac_vid = b53_mac_to_u64(ent->mac);
+       *mac_vid = ether_addr_to_u64(ent->mac);
        *mac_vid |= (u64)(ent->vid & ARLTBL_VID_MASK) << ARLTBL_VID_S;
        *fwd_entry = ent->port & ARLTBL_DATA_PORT_ID_MASK;
        if (ent->is_valid)