include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / net / core / net-sysfs.c
index 4242e94..59cfc7d 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <linux/rtnetlink.h>
 #include <linux/wireless.h>
@@ -139,7 +140,9 @@ static ssize_t show_speed(struct device *dev,
        if (!rtnl_trylock())
                return restart_syscall();
 
-       if (netif_running(netdev) && netdev->ethtool_ops->get_settings) {
+       if (netif_running(netdev) &&
+           netdev->ethtool_ops &&
+           netdev->ethtool_ops->get_settings) {
                struct ethtool_cmd cmd = { ETHTOOL_GSET };
 
                if (!netdev->ethtool_ops->get_settings(netdev, &cmd))
@@ -158,7 +161,9 @@ static ssize_t show_duplex(struct device *dev,
        if (!rtnl_trylock())
                return restart_syscall();
 
-       if (netif_running(netdev) && netdev->ethtool_ops->get_settings) {
+       if (netif_running(netdev) &&
+           netdev->ethtool_ops &&
+           netdev->ethtool_ops->get_settings) {
                struct ethtool_cmd cmd = { ETHTOOL_GSET };
 
                if (!netdev->ethtool_ops->get_settings(netdev, &cmd))
@@ -406,7 +411,8 @@ static ssize_t wireless_show(struct device *d, char *buf,
        const struct iw_statistics *iw;
        ssize_t ret = -EINVAL;
 
-       rtnl_lock();
+       if (!rtnl_trylock())
+               return restart_syscall();
        if (dev_isalive(dev)) {
                iw = get_wireless_stats(dev);
                if (iw)
@@ -521,7 +527,7 @@ void netdev_unregister_kobject(struct net_device * net)
 
        kobject_get(&dev->kobj);
 
-       if (dev_net(net) != &init_net)
+       if (!net_eq(dev_net(net), &init_net))
                return;
 
        device_del(dev);
@@ -540,15 +546,22 @@ int netdev_register_kobject(struct net_device *net)
        dev_set_name(dev, "%s", net->name);
 
 #ifdef CONFIG_SYSFS
-       *groups++ = &netstat_group;
+       /* Allow for a device specific group */
+       if (*groups)
+               groups++;
 
+       *groups++ = &netstat_group;
 #ifdef CONFIG_WIRELESS_EXT_SYSFS
-       if (net->wireless_handlers || net->ieee80211_ptr)
+       if (net->ieee80211_ptr)
+               *groups++ = &wireless_group;
+#ifdef CONFIG_WIRELESS_EXT
+       else if (net->wireless_handlers)
                *groups++ = &wireless_group;
 #endif
+#endif
 #endif /* CONFIG_SYSFS */
 
-       if (dev_net(net) != &init_net)
+       if (!net_eq(dev_net(net), &init_net))
                return 0;
 
        return device_add(dev);