]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/core/net-sysfs.c
[ETHTOOL]: Internal cleanup of ethtool_value-related handlers
[linux-2.6-omap-h63xx.git] / net / core / net-sysfs.c
index 4cbb1290a6a34707c93b0ddfa040a06f1d1d47bf..79159db6acb9ba54d2280d30fb0b79cdf8cfec9f 100644 (file)
@@ -216,20 +216,6 @@ static ssize_t store_tx_queue_len(struct device *dev,
        return netdev_store(dev, attr, buf, len, change_tx_queue_len);
 }
 
-NETDEVICE_SHOW(weight, fmt_dec);
-
-static int change_weight(struct net_device *net, unsigned long new_weight)
-{
-       net->weight = new_weight;
-       return 0;
-}
-
-static ssize_t store_weight(struct device *dev, struct device_attribute *attr,
-                           const char *buf, size_t len)
-{
-       return netdev_store(dev, attr, buf, len, change_weight);
-}
-
 static struct device_attribute net_class_attributes[] = {
        __ATTR(addr_len, S_IRUGO, show_addr_len, NULL),
        __ATTR(iflink, S_IRUGO, show_iflink, NULL),
@@ -246,7 +232,6 @@ static struct device_attribute net_class_attributes[] = {
        __ATTR(flags, S_IRUGO | S_IWUSR, show_flags, store_flags),
        __ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len,
               store_tx_queue_len),
-       __ATTR(weight, S_IRUGO | S_IWUSR, show_weight, store_weight),
        {}
 };
 
@@ -352,8 +337,8 @@ static ssize_t wireless_show(struct device *d, char *buf,
 
        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,20 +397,25 @@ 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
 
@@ -451,9 +441,15 @@ static struct class net_class = {
 #endif
 };
 
+/* Delete sysfs entries but hold kobject reference until after all
+ * netdev references are gone.
+ */
 void netdev_unregister_sysfs(struct net_device * net)
 {
-       device_del(&(net->dev));
+       struct device *dev = &(net->dev);
+
+       kobject_get(&dev->kobj);
+       device_del(dev);
 }
 
 /* Create sysfs entries for network device. */