Commit e550ba1a authored by Joe Perches's avatar Joe Perches Committed by David S. Miller

etherdevice: Remove now unused compare_ether_addr_64bits

Move and invert the logic from the otherwise unused
compare_ether_addr_64bits to ether_addr_equal_64bits.

Neaten the logic in is_etherdev_addr.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f96a8a0b
...@@ -193,12 +193,12 @@ static inline unsigned long zap_last_2bytes(unsigned long value) ...@@ -193,12 +193,12 @@ static inline unsigned long zap_last_2bytes(unsigned long value)
} }
/** /**
* compare_ether_addr_64bits - Compare two Ethernet addresses * ether_addr_equal_64bits - Compare two Ethernet addresses
* @addr1: Pointer to an array of 8 bytes * @addr1: Pointer to an array of 8 bytes
* @addr2: Pointer to an other array of 8 bytes * @addr2: Pointer to an other array of 8 bytes
* *
* Compare two ethernet addresses, returns 0 if equal, non-zero otherwise. * Compare two ethernet addresses, returns true if equal, false otherwise.
* Unlike memcmp(), it doesn't return a value suitable for sorting. *
* The function doesn't need any conditional branches and possibly uses * The function doesn't need any conditional branches and possibly uses
* word memory accesses on CPU allowing cheap unaligned memory reads. * word memory accesses on CPU allowing cheap unaligned memory reads.
* arrays = { byte1, byte2, byte3, byte4, byte6, byte7, pad1, pad2} * arrays = { byte1, byte2, byte3, byte4, byte6, byte7, pad1, pad2}
...@@ -206,44 +206,24 @@ static inline unsigned long zap_last_2bytes(unsigned long value) ...@@ -206,44 +206,24 @@ static inline unsigned long zap_last_2bytes(unsigned long value)
* Please note that alignment of addr1 & addr2 is only guaranted to be 16 bits. * Please note that alignment of addr1 & addr2 is only guaranted to be 16 bits.
*/ */
static inline unsigned compare_ether_addr_64bits(const u8 addr1[6+2], static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
const u8 addr2[6+2]) const u8 addr2[6+2])
{ {
#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
unsigned long fold = ((*(unsigned long *)addr1) ^ unsigned long fold = ((*(unsigned long *)addr1) ^
(*(unsigned long *)addr2)); (*(unsigned long *)addr2));
if (sizeof(fold) == 8) if (sizeof(fold) == 8)
return zap_last_2bytes(fold) != 0; return zap_last_2bytes(fold) == 0;
fold |= zap_last_2bytes((*(unsigned long *)(addr1 + 4)) ^ fold |= zap_last_2bytes((*(unsigned long *)(addr1 + 4)) ^
(*(unsigned long *)(addr2 + 4))); (*(unsigned long *)(addr2 + 4)));
return fold != 0; return fold == 0;
#else #else
return compare_ether_addr(addr1, addr2); return ether_addr_equal(addr1, addr2);
#endif #endif
} }
/**
* ether_addr_equal_64bits - Compare two Ethernet addresses
* @addr1: Pointer to an array of 8 bytes
* @addr2: Pointer to an other array of 8 bytes
*
* Compare two ethernet addresses, returns true if equal, false otherwise.
*
* The function doesn't need any conditional branches and possibly uses
* word memory accesses on CPU allowing cheap unaligned memory reads.
* arrays = { byte1, byte2, byte3, byte4, byte6, byte7, pad1, pad2}
*
* Please note that alignment of addr1 & addr2 is only guaranted to be 16 bits.
*/
static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
const u8 addr2[6+2])
{
return !compare_ether_addr_64bits(addr1, addr2);
}
/** /**
* is_etherdev_addr - Tell if given Ethernet address belongs to the device. * is_etherdev_addr - Tell if given Ethernet address belongs to the device.
* @dev: Pointer to a device structure * @dev: Pointer to a device structure
...@@ -252,23 +232,23 @@ static inline bool ether_addr_equal_64bits(const u8 addr1[6+2], ...@@ -252,23 +232,23 @@ static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
* Compare passed address with all addresses of the device. Return true if the * Compare passed address with all addresses of the device. Return true if the
* address if one of the device addresses. * address if one of the device addresses.
* *
* Note that this function calls compare_ether_addr_64bits() so take care of * Note that this function calls ether_addr_equal_64bits() so take care of
* the right padding. * the right padding.
*/ */
static inline bool is_etherdev_addr(const struct net_device *dev, static inline bool is_etherdev_addr(const struct net_device *dev,
const u8 addr[6 + 2]) const u8 addr[6 + 2])
{ {
struct netdev_hw_addr *ha; struct netdev_hw_addr *ha;
int res = 1; bool res = false;
rcu_read_lock(); rcu_read_lock();
for_each_dev_addr(dev, ha) { for_each_dev_addr(dev, ha) {
res = compare_ether_addr_64bits(addr, ha->addr); res = ether_addr_equal_64bits(addr, ha->addr);
if (!res) if (res)
break; break;
} }
rcu_read_unlock(); rcu_read_unlock();
return !res; return res;
} }
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment