diff options
author | David S. Miller <davem@davemloft.net> | 2013-07-16 20:09:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-07-16 20:09:22 -0400 |
commit | ae8e9c5a1a7889315229a741fd48a5dd0bc2964c (patch) | |
tree | 6ea199fad466af8253da9ae617ce112bb182ee43 /net | |
parent | 52fe29e4bb614367c108b717c6d7fe5953eb7af3 (diff) |
net: Fix sysfs_format_mac() code duplication.
It's just a duplicate implementation of "%*phC". Thanks to Joe
Perches for showing that we had exactly this support in the
lib/vsprintf.c code already.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ethernet/eth.c | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index 5359560926bc..be1f64d35358 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c | |||
@@ -401,27 +401,8 @@ struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs, | |||
401 | } | 401 | } |
402 | EXPORT_SYMBOL(alloc_etherdev_mqs); | 402 | EXPORT_SYMBOL(alloc_etherdev_mqs); |
403 | 403 | ||
404 | static size_t _format_mac_addr(char *buf, int buflen, | ||
405 | const unsigned char *addr, int len) | ||
406 | { | ||
407 | int i; | ||
408 | char *cp = buf; | ||
409 | |||
410 | for (i = 0; i < len; i++) { | ||
411 | cp += scnprintf(cp, buflen - (cp - buf), "%02x", addr[i]); | ||
412 | if (i == len - 1) | ||
413 | break; | ||
414 | cp += scnprintf(cp, buflen - (cp - buf), ":"); | ||
415 | } | ||
416 | return cp - buf; | ||
417 | } | ||
418 | |||
419 | ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len) | 404 | ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len) |
420 | { | 405 | { |
421 | size_t l; | 406 | return scnprintf(buf, PAGE_SIZE, "%*phC\n", len, addr); |
422 | |||
423 | l = _format_mac_addr(buf, PAGE_SIZE, addr, len); | ||
424 | l += scnprintf(buf + l, PAGE_SIZE - l, "\n"); | ||
425 | return (ssize_t)l; | ||
426 | } | 407 | } |
427 | EXPORT_SYMBOL(sysfs_format_mac); | 408 | EXPORT_SYMBOL(sysfs_format_mac); |