diff options
Diffstat (limited to 'net/ethernet')
-rw-r--r-- | net/ethernet/eth.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index 6b2e454ae313..a7b417523e9b 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c | |||
@@ -359,10 +359,34 @@ struct net_device *alloc_etherdev_mq(int sizeof_priv, unsigned int queue_count) | |||
359 | } | 359 | } |
360 | EXPORT_SYMBOL(alloc_etherdev_mq); | 360 | EXPORT_SYMBOL(alloc_etherdev_mq); |
361 | 361 | ||
362 | char *print_mac(char *buf, const u8 *addr) | 362 | static size_t _format_mac_addr(char *buf, int buflen, |
363 | const unsigned char *addr, int len) | ||
363 | { | 364 | { |
364 | sprintf(buf, MAC_FMT, | 365 | int i; |
365 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); | 366 | char *cp = buf; |
367 | |||
368 | for (i = 0; i < len; i++) { | ||
369 | cp += scnprintf(cp, buflen - (cp - buf), "%02x", addr[i]); | ||
370 | if (i == len - 1) | ||
371 | break; | ||
372 | cp += strlcpy(cp, ":", buflen - (cp - buf)); | ||
373 | } | ||
374 | return cp - buf; | ||
375 | } | ||
376 | |||
377 | ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len) | ||
378 | { | ||
379 | size_t l; | ||
380 | |||
381 | l = _format_mac_addr(buf, PAGE_SIZE, addr, len); | ||
382 | l += strlcpy(buf + l, "\n", PAGE_SIZE - l); | ||
383 | return ((ssize_t) l); | ||
384 | } | ||
385 | EXPORT_SYMBOL(sysfs_format_mac); | ||
386 | |||
387 | char *print_mac(char *buf, const unsigned char *addr) | ||
388 | { | ||
389 | _format_mac_addr(buf, MAC_BUF_SIZE, addr, ETH_ALEN); | ||
366 | return buf; | 390 | return buf; |
367 | } | 391 | } |
368 | EXPORT_SYMBOL(print_mac); | 392 | EXPORT_SYMBOL(print_mac); |