and changed files
[powerpc.git] / net / core / net-sysfs.c
index 44db095..b21307b 100644 (file)
@@ -2,7 +2,7 @@
  * net-sysfs.c - network device class and attributes
  *
  * Copyright (c) 2003 Stephen Hemminger <shemminger@osdl.org>
- * 
+ *
  *     This program is free software; you can redistribute it and/or
  *     modify it under the terms of the GNU General Public License
  *     as published by the Free Software Foundation; either version
@@ -23,7 +23,7 @@ static const char fmt_long_hex[] = "%#lx\n";
 static const char fmt_dec[] = "%d\n";
 static const char fmt_ulong[] = "%lu\n";
 
-static inline int dev_isalive(const struct net_device *dev) 
+static inline int dev_isalive(const struct net_device *dev)
 {
        return dev->reg_state <= NETREG_REGISTERED;
 }
@@ -265,7 +265,7 @@ static ssize_t netstat_show(const struct device *d,
 
        read_lock(&dev_base_lock);
        if (dev_isalive(dev) && dev->get_stats &&
-           (stats = (*dev->get_stats)(dev))) 
+           (stats = (*dev->get_stats)(dev)))
                ret = sprintf(buf, fmt_ulong,
                              *(unsigned long *)(((u8 *) stats) + offset));
 
@@ -340,7 +340,7 @@ static struct attribute_group netstat_group = {
        .attrs  = netstat_attrs,
 };
 
-#ifdef WIRELESS_EXT
+#ifdef CONFIG_WIRELESS_EXT
 /* helper function that does all the locking etc for wireless stats */
 static ssize_t wireless_show(struct device *d, char *buf,
                             ssize_t (*format)(const struct iw_statistics *,
@@ -349,11 +349,11 @@ static ssize_t wireless_show(struct device *d, char *buf,
        struct net_device *dev = to_net_dev(d);
        const struct iw_statistics *iw = NULL;
        ssize_t ret = -EINVAL;
-       
+
        read_lock(&dev_base_lock);
        if (dev_isalive(dev)) {
-               if(dev->wireless_handlers &&
-                  dev->wireless_handlers->get_wireless_stats)
+               if (dev->wireless_handlers &&
+                   dev->wireless_handlers->get_wireless_stats)
                        iw = dev->wireless_handlers->get_wireless_stats(dev);
                if (iw != NULL)
                        ret = (*format)(iw, buf);
@@ -412,25 +412,30 @@ static int netdev_uevent(struct device *d, char **envp,
                         int num_envp, char *buf, int size)
 {
        struct net_device *dev = to_net_dev(d);
-       int i = 0;
-       int n;
+       int retval, len = 0, i = 0;
 
        /* pass interface to uevent. */
-       envp[i++] = buf;
-       n = snprintf(buf, size, "INTERFACE=%s", dev->name) + 1;
-       buf += n;
-       size -= n;
-
-       if ((size <= 0) || (i >= num_envp))
-               return -ENOMEM;
-
+       retval = add_uevent_var(envp, num_envp, &i,
+                               buf, size, &len,
+                               "INTERFACE=%s", dev->name);
+       if (retval)
+               goto exit;
+
+       /* pass ifindex to uevent.
+        * ifindex is useful as it won't change (interface name may change)
+        * and is what RtNetlink uses natively. */
+       retval = add_uevent_var(envp, num_envp, &i,
+                               buf, size, &len,
+                               "IFINDEX=%d", dev->ifindex);
+
+exit:
        envp[i] = NULL;
-       return 0;
+       return retval;
 }
 #endif
 
 /*
- *     netdev_release -- destroy and free a dead device. 
+ *     netdev_release -- destroy and free a dead device.
  *     Called when last reference to device kobject is gone.
  */
 static void netdev_release(struct device *d)
@@ -473,7 +478,7 @@ int netdev_register_sysfs(struct net_device *net)
        if (net->get_stats)
                *groups++ = &netstat_group;
 
-#ifdef WIRELESS_EXT
+#ifdef CONFIG_WIRELESS_EXT
        if (net->wireless_handlers && net->wireless_handlers->get_wireless_stats)
                *groups++ = &wireless_group;
 #endif