]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/core/net-sysfs.c
cris: types: use <asm-generic/int-*.h> for the cris architecture
[linux-2.6-omap-h63xx.git] / net / core / net-sysfs.c
index 6628e457ddc0f1179e3e5fc42e965eaf19b9b283..4e7b847347f792da742c93315b0b074512d11886 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";
@@ -85,6 +87,7 @@ static ssize_t netdev_store(struct device *dev, struct device_attribute *attr,
        return ret;
 }
 
+NETDEVICE_SHOW(dev_id, fmt_hex);
 NETDEVICE_SHOW(addr_len, fmt_dec);
 NETDEVICE_SHOW(iflink, fmt_dec);
 NETDEVICE_SHOW(ifindex, fmt_dec);
@@ -93,17 +96,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 +104,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 +114,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;
 }
 
@@ -219,6 +211,7 @@ static ssize_t store_tx_queue_len(struct device *dev,
 
 static struct device_attribute net_class_attributes[] = {
        __ATTR(addr_len, S_IRUGO, show_addr_len, NULL),
+       __ATTR(dev_id, S_IRUGO, show_dev_id, NULL),
        __ATTR(iflink, S_IRUGO, show_iflink, NULL),
        __ATTR(ifindex, S_IRUGO, show_ifindex, NULL),
        __ATTR(features, S_IRUGO, show_features, NULL),
@@ -245,9 +238,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 &&