diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2014-06-07 19:49:45 +0200 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2014-06-07 20:35:01 +0200 |
commit | 484d772d96bf4bf1a8f7a332135d6152814db2ff (patch) | |
tree | dc5273f4df356b5977e20c1c4b0091055eaacb5d | |
parent | 7f9ad2765e3ad201b592d9491d4707234129d0c2 (diff) |
backports: add ether_addr_copy()
This is needed by the rsi driver.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r-- | backport/backport-include/linux/etherdevice.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/backport/backport-include/linux/etherdevice.h b/backport/backport-include/linux/etherdevice.h index 8d09e1f2..cc2ee0a6 100644 --- a/backport/backport-include/linux/etherdevice.h +++ b/backport/backport-include/linux/etherdevice.h @@ -148,6 +148,29 @@ static inline bool ether_addr_equal_unaligned(const u8 *addr1, const u8 *addr2) return memcmp(addr1, addr2, ETH_ALEN) == 0; #endif } + +/** + * ether_addr_copy - Copy an Ethernet address + * @dst: Pointer to a six-byte array Ethernet address destination + * @src: Pointer to a six-byte array Ethernet address source + * + * Please note: dst & src must both be aligned to u16. + */ +#define ether_addr_copy LINUX_BACKPORT(ether_addr_copy) +static inline void ether_addr_copy(u8 *dst, const u8 *src) +{ +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) + *(u32 *)dst = *(const u32 *)src; + *(u16 *)(dst + 4) = *(const u16 *)(src + 4); +#else + u16 *a = (u16 *)dst; + const u16 *b = (const u16 *)src; + + a[0] = b[0]; + a[1] = b[1]; + a[2] = b[2]; +#endif +} #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0) */ #endif /* _BACKPORT_LINUX_ETHERDEVICE_H */ |