diff options
author | Joe Perches <joe@perches.com> | 2012-05-11 08:21:06 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-05-12 23:34:50 -0400 |
commit | e550ba1af9e7008ca8e22d85943cbdf0748c765c (patch) | |
tree | 42268db23599ffcd90ec1d57a80939bdb59e4807 /include | |
parent | f96a8a0b78548c0ec06b0b4b438db6ee895d67e9 (diff) |
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: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/etherdevice.h | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index afacf8576d0f..dc85c1d2173b 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h | |||
@@ -193,12 +193,12 @@ static inline unsigned long zap_last_2bytes(unsigned long value) | |||
193 | } | 193 | } |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * compare_ether_addr_64bits - Compare two Ethernet addresses | 196 | * ether_addr_equal_64bits - Compare two Ethernet addresses |
197 | * @addr1: Pointer to an array of 8 bytes | 197 | * @addr1: Pointer to an array of 8 bytes |
198 | * @addr2: Pointer to an other array of 8 bytes | 198 | * @addr2: Pointer to an other array of 8 bytes |
199 | * | 199 | * |
200 | * Compare two ethernet addresses, returns 0 if equal, non-zero otherwise. | 200 | * Compare two ethernet addresses, returns true if equal, false otherwise. |
201 | * Unlike memcmp(), it doesn't return a value suitable for sorting. | 201 | * |
202 | * The function doesn't need any conditional branches and possibly uses | 202 | * The function doesn't need any conditional branches and possibly uses |
203 | * word memory accesses on CPU allowing cheap unaligned memory reads. | 203 | * word memory accesses on CPU allowing cheap unaligned memory reads. |
204 | * arrays = { byte1, byte2, byte3, byte4, byte6, byte7, pad1, pad2} | 204 | * arrays = { byte1, byte2, byte3, byte4, byte6, byte7, pad1, pad2} |
@@ -206,45 +206,25 @@ static inline unsigned long zap_last_2bytes(unsigned long value) | |||
206 | * Please note that alignment of addr1 & addr2 is only guaranted to be 16 bits. | 206 | * Please note that alignment of addr1 & addr2 is only guaranted to be 16 bits. |
207 | */ | 207 | */ |
208 | 208 | ||
209 | static inline unsigned compare_ether_addr_64bits(const u8 addr1[6+2], | 209 | static inline bool ether_addr_equal_64bits(const u8 addr1[6+2], |
210 | const u8 addr2[6+2]) | 210 | const u8 addr2[6+2]) |
211 | { | 211 | { |
212 | #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS | 212 | #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS |
213 | unsigned long fold = ((*(unsigned long *)addr1) ^ | 213 | unsigned long fold = ((*(unsigned long *)addr1) ^ |
214 | (*(unsigned long *)addr2)); | 214 | (*(unsigned long *)addr2)); |
215 | 215 | ||
216 | if (sizeof(fold) == 8) | 216 | if (sizeof(fold) == 8) |
217 | return zap_last_2bytes(fold) != 0; | 217 | return zap_last_2bytes(fold) == 0; |
218 | 218 | ||
219 | fold |= zap_last_2bytes((*(unsigned long *)(addr1 + 4)) ^ | 219 | fold |= zap_last_2bytes((*(unsigned long *)(addr1 + 4)) ^ |
220 | (*(unsigned long *)(addr2 + 4))); | 220 | (*(unsigned long *)(addr2 + 4))); |
221 | return fold != 0; | 221 | return fold == 0; |
222 | #else | 222 | #else |
223 | return compare_ether_addr(addr1, addr2); | 223 | return ether_addr_equal(addr1, addr2); |
224 | #endif | 224 | #endif |
225 | } | 225 | } |
226 | 226 | ||
227 | /** | 227 | /** |
228 | * ether_addr_equal_64bits - Compare two Ethernet addresses | ||
229 | * @addr1: Pointer to an array of 8 bytes | ||
230 | * @addr2: Pointer to an other array of 8 bytes | ||
231 | * | ||
232 | * Compare two ethernet addresses, returns true if equal, false otherwise. | ||
233 | * | ||
234 | * The function doesn't need any conditional branches and possibly uses | ||
235 | * word memory accesses on CPU allowing cheap unaligned memory reads. | ||
236 | * arrays = { byte1, byte2, byte3, byte4, byte6, byte7, pad1, pad2} | ||
237 | * | ||
238 | * Please note that alignment of addr1 & addr2 is only guaranted to be 16 bits. | ||
239 | */ | ||
240 | |||
241 | static inline bool ether_addr_equal_64bits(const u8 addr1[6+2], | ||
242 | const u8 addr2[6+2]) | ||
243 | { | ||
244 | return !compare_ether_addr_64bits(addr1, addr2); | ||
245 | } | ||
246 | |||
247 | /** | ||
248 | * is_etherdev_addr - Tell if given Ethernet address belongs to the device. | 228 | * is_etherdev_addr - Tell if given Ethernet address belongs to the device. |
249 | * @dev: Pointer to a device structure | 229 | * @dev: Pointer to a device structure |
250 | * @addr: Pointer to a six-byte array containing the Ethernet address | 230 | * @addr: Pointer to a six-byte array containing the Ethernet address |
@@ -252,23 +232,23 @@ static inline bool ether_addr_equal_64bits(const u8 addr1[6+2], | |||
252 | * Compare passed address with all addresses of the device. Return true if the | 232 | * Compare passed address with all addresses of the device. Return true if the |
253 | * address if one of the device addresses. | 233 | * address if one of the device addresses. |
254 | * | 234 | * |
255 | * Note that this function calls compare_ether_addr_64bits() so take care of | 235 | * Note that this function calls ether_addr_equal_64bits() so take care of |
256 | * the right padding. | 236 | * the right padding. |
257 | */ | 237 | */ |
258 | static inline bool is_etherdev_addr(const struct net_device *dev, | 238 | static inline bool is_etherdev_addr(const struct net_device *dev, |
259 | const u8 addr[6 + 2]) | 239 | const u8 addr[6 + 2]) |
260 | { | 240 | { |
261 | struct netdev_hw_addr *ha; | 241 | struct netdev_hw_addr *ha; |
262 | int res = 1; | 242 | bool res = false; |
263 | 243 | ||
264 | rcu_read_lock(); | 244 | rcu_read_lock(); |
265 | for_each_dev_addr(dev, ha) { | 245 | for_each_dev_addr(dev, ha) { |
266 | res = compare_ether_addr_64bits(addr, ha->addr); | 246 | res = ether_addr_equal_64bits(addr, ha->addr); |
267 | if (!res) | 247 | if (res) |
268 | break; | 248 | break; |
269 | } | 249 | } |
270 | rcu_read_unlock(); | 250 | rcu_read_unlock(); |
271 | return !res; | 251 | return res; |
272 | } | 252 | } |
273 | #endif /* __KERNEL__ */ | 253 | #endif /* __KERNEL__ */ |
274 | 254 | ||