]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/core/net-sysfs.c
Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block
[linux-2.6-omap-h63xx.git] / net / core / net-sysfs.c
index 6628e457ddc0f1179e3e5fc42e965eaf19b9b283..7635d3f7272324f06866754ffd22df48408fc455 100644 (file)
@@ -18,6 +18,8 @@
 #include <linux/wireless.h>
 #include <net/iw_handler.h>
 
+#include "net-sysfs.h"
+
 #ifdef CONFIG_SYSFS
 static const char fmt_hex[] = "%#x\n";
 static const char fmt_long_hex[] = "%#lx\n";
@@ -93,17 +95,6 @@ NETDEVICE_SHOW(type, fmt_dec);
 NETDEVICE_SHOW(link_mode, fmt_dec);
 
 /* use same locking rules as GIFHWADDR ioctl's */
-static ssize_t format_addr(char *buf, const unsigned char *addr, int len)
-{
-       int i;
-       char *cp = buf;
-
-       for (i = 0; i < len; i++)
-               cp += sprintf(cp, "%02x%c", addr[i],
-                             i == (len - 1) ? '\n' : ':');
-       return cp - buf;
-}
-
 static ssize_t show_address(struct device *dev, struct device_attribute *attr,
                            char *buf)
 {
@@ -112,7 +103,7 @@ static ssize_t show_address(struct device *dev, struct device_attribute *attr,
 
        read_lock(&dev_base_lock);
        if (dev_isalive(net))
-           ret = format_addr(buf, net->dev_addr, net->addr_len);
+               ret = sysfs_format_mac(buf, net->dev_addr, net->addr_len);
        read_unlock(&dev_base_lock);
        return ret;
 }
@@ -122,7 +113,7 @@ static ssize_t show_broadcast(struct device *dev,
 {
        struct net_device *net = to_net_dev(dev);
        if (dev_isalive(net))
-               return format_addr(buf, net->broadcast, net->addr_len);
+               return sysfs_format_mac(buf, net->broadcast, net->addr_len);
        return -EINVAL;
 }
 
@@ -245,9 +236,8 @@ static ssize_t netstat_show(const struct device *d,
        struct net_device_stats *stats;
        ssize_t ret = -EINVAL;
 
-       if (offset > sizeof(struct net_device_stats) ||
-           offset % sizeof(unsigned long) != 0)
-               WARN_ON(1);
+       WARN_ON(offset > sizeof(struct net_device_stats) ||
+                       offset % sizeof(unsigned long) != 0);
 
        read_lock(&dev_base_lock);
        if (dev_isalive(dev) && dev->get_stats &&