From 484d772d96bf4bf1a8f7a332135d6152814db2ff Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 7 Jun 2014 19:49:45 +0200 Subject: [PATCH] backports: add ether_addr_copy() This is needed by the rsi driver. Signed-off-by: Hauke Mehrtens --- backport/backport-include/linux/etherdevice.h | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/backport/backport-include/linux/etherdevice.h b/backport/backport-include/linux/etherdevice.h index 8d09e1f26379..cc2ee0a613b0 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 */ -- 2.30.2