lkml.org 
[lkml]   [2015]   [Apr]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] etherdevice: Add ether_addr_copy_unaligned
Date
Some drivers require copying unaligned ethernet addresses.
Using memcpy() causes checkpatch warnings and may cause
regressions (someone will "fix" alignment of packed structure)

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
---
include/linux/etherdevice.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 606563e..681874f 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -244,6 +244,22 @@ static inline void ether_addr_copy(u8 *dst, const u8 *src)
}

/**
+ * ether_addr_copy_unaligned - Copy unaligned Ethernet address
+ * @dst: Pointer to a six-byte array Ethernet address destination
+ * @src: Pointer to a six-byte array Ethernet address source
+ *
+ * Please note: Use only when any Ethernet address may not be u16 aligned.
+ */
+static inline void ether_addr_copy_unaligned(u8 *dst, const u8 *src)
+{
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
+ ether_addr_copy(dst, src);
+#else
+ memcpy(dst, src, ETH_ALEN);
+#endif
+}
+
+/**
* eth_hw_addr_inherit - Copy dev_addr from another net_device
* @dst: pointer to net_device to copy dev_addr to
* @src: pointer to net_device to copy dev_addr from
--
1.8.4.1


\
 
 \ /
  Last update: 2015-04-20 00:21    [W:0.039 / U:0.788 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site