net: Fix sysfs_format_mac() code duplication.
authorDavid S. Miller <davem@davemloft.net>
Wed, 17 Jul 2013 00:09:15 +0000 (17:09 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 17 Jul 2013 00:09:22 +0000 (17:09 -0700)
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>
net/ethernet/eth.c

index 5359560926bcf8f17f87c94474fd96cda1f1d6e2..be1f64d35358fbfbf61d84683c52e4d6fb423f34 100644 (file)
@@ -401,27 +401,8 @@ struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
 }
 EXPORT_SYMBOL(alloc_etherdev_mqs);
 
-static size_t _format_mac_addr(char *buf, int buflen,
-                              const unsigned char *addr, int len)
-{
-       int i;
-       char *cp = buf;
-
-       for (i = 0; i < len; i++) {
-               cp += scnprintf(cp, buflen - (cp - buf), "%02x", addr[i]);
-               if (i == len - 1)
-                       break;
-               cp += scnprintf(cp, buflen - (cp - buf), ":");
-       }
-       return cp - buf;
-}
-
 ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len)
 {
-       size_t l;
-
-       l = _format_mac_addr(buf, PAGE_SIZE, addr, len);
-       l += scnprintf(buf + l, PAGE_SIZE - l, "\n");
-       return (ssize_t)l;
+       return scnprintf(buf, PAGE_SIZE, "%*phC\n", len, addr);
 }
 EXPORT_SYMBOL(sysfs_format_mac);