netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] etherdevice: Add ether_addr_copy_unaligned
@ 2015-04-19 21:39 Mateusz Kulikowski
  2015-04-20 18:19 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Mateusz Kulikowski @ 2015-04-19 21:39 UTC (permalink / raw)
  To: davem; +Cc: Mateusz Kulikowski, joe, dan.carpenter, netdev, linux-kernel

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] etherdevice: Add ether_addr_copy_unaligned
  2015-04-19 21:39 [PATCH] etherdevice: Add ether_addr_copy_unaligned Mateusz Kulikowski
@ 2015-04-20 18:19 ` David Miller
  2015-04-21 20:06   ` Mateusz Kulikowski
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2015-04-20 18:19 UTC (permalink / raw)
  To: mateusz.kulikowski; +Cc: joe, dan.carpenter, netdev, linux-kernel

From: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
Date: Sun, 19 Apr 2015 23:39:37 +0200

> 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>

I'd rather see something like this submitted in a patch series alongside
some actual uses.

So I'm tossing this for now.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] etherdevice: Add ether_addr_copy_unaligned
  2015-04-20 18:19 ` David Miller
@ 2015-04-21 20:06   ` Mateusz Kulikowski
  0 siblings, 0 replies; 3+ messages in thread
From: Mateusz Kulikowski @ 2015-04-21 20:06 UTC (permalink / raw)
  To: David Miller; +Cc: joe, dan.carpenter, netdev, linux-kernel

On 20.04.2015 20:19, David Miller wrote:
(...)
> I'd rather see something like this submitted in a patch series alongside
> some actual uses.
> 
> So I'm tossing this for now.
> 
Ok;

I'll add it to a series where I need it (rtl8192e)

Regards,
Mateusz

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-21 20:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-19 21:39 [PATCH] etherdevice: Add ether_addr_copy_unaligned Mateusz Kulikowski
2015-04-20 18:19 ` David Miller
2015-04-21 20:06   ` Mateusz Kulikowski

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).