From: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
To: davem@davemloft.net
Cc: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>,
joe@perches.com, dan.carpenter@oracle.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] etherdevice: Add ether_addr_copy_unaligned
Date: Sun, 19 Apr 2015 23:39:37 +0200 [thread overview]
Message-ID: <1429479577-3977-1-git-send-email-mateusz.kulikowski@gmail.com> (raw)
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
next reply other threads:[~2015-04-19 21:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-19 21:39 Mateusz Kulikowski [this message]
2015-04-20 18:19 ` [PATCH] etherdevice: Add ether_addr_copy_unaligned David Miller
2015-04-21 20:06 ` Mateusz Kulikowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1429479577-3977-1-git-send-email-mateusz.kulikowski@gmail.com \
--to=mateusz.kulikowski@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).