linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] etherdevice: add is_zero_ether_addr_unaligned()
@ 2016-08-13  2:59 Petri Gynther
  2016-08-13  3:00 ` [PATCH 2/2] mwifiex: fix unaligned read in mwifiex_config_scan() Petri Gynther
  2016-08-13  4:11 ` [PATCH 1/2] etherdevice: add is_zero_ether_addr_unaligned() Joe Perches
  0 siblings, 2 replies; 9+ messages in thread
From: Petri Gynther @ 2016-08-13  2:59 UTC (permalink / raw)
  To: linux-wireless; +Cc: kvalo, davem, joe, akarwar, Petri Gynther

Add a generic routine to test if possibly unaligned to u16
Ethernet address is a zero address.

If CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is set, use
slightly faster generic routine is_zero_ether_addr(),
otherwise use byte accesses.

This is v2 of the original patch:
[PATCH] Modify is_zero_ether_addr() to handle byte-aligned addresses

Per Joe's suggestion -- instead of modifying is_zero_ether_addr() --
add is_zero_ether_addr_unaligned() and use it where needed.

Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Joe Perches <joe@perches.com>
Cc: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Petri Gynther <pgynther@google.com>
---
 include/linux/etherdevice.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 37ff4a6..f609691 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -105,6 +105,21 @@ static inline bool is_zero_ether_addr(const u8 *addr)
 }
 
 /**
+ * is_zero_ether_addr_unaligned - Determine if given Ethernet address is all zeros.
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Return true if the address is all zeroes.
+ */
+static inline bool is_zero_ether_addr_unaligned(const u8 *addr)
+{
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
+	return is_zero_ether_addr(addr);
+#else
+	return (addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]) == 0;
+#endif
+}
+
+/**
  * is_multicast_ether_addr - Determine if the Ethernet address is a multicast.
  * @addr: Pointer to a six-byte array containing the Ethernet address
  *
-- 
2.8.0.rc3.226.g39d4020


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

end of thread, other threads:[~2016-09-26 11:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-13  2:59 [PATCH 1/2] etherdevice: add is_zero_ether_addr_unaligned() Petri Gynther
2016-08-13  3:00 ` [PATCH 2/2] mwifiex: fix unaligned read in mwifiex_config_scan() Petri Gynther
2016-08-16 17:47   ` Petri Gynther
2016-09-08 16:10     ` Amitkumar Karwar
2016-09-08 18:01       ` Kalle Valo
2016-09-26 11:19   ` [2/2] " Kalle Valo
2016-08-13  4:11 ` [PATCH 1/2] etherdevice: add is_zero_ether_addr_unaligned() Joe Perches
2016-08-13  4:40   ` Petri Gynther
2016-08-13  4:59     ` Joe Perches

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