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 <kv...@codeaurora.org>
Cc: David S. Miller <da...@davemloft.net>
Cc: Joe Perches <j...@perches.com>
Cc: Amitkumar Karwar <akar...@marvell.com>
Signed-off-by: Petri Gynther <pgynt...@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

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to