net: use hlist_for_each_entry()
authorEric Dumazet <eric.dumazet@gmail.com>
Fri, 30 Oct 2009 08:40:11 +0000 (01:40 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 30 Oct 2009 08:40:11 +0000 (01:40 -0700)
Small cleanup of __dev_get_by_name() and __dev_get_by_index()
to use hlist_for_each_entry() : They'll look like their _rcu variant.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dev.c

index 631cc40da1971322c53483cca196bdef5454f59a..94f42a15fff13f1d2719ec85fd0d7fc161370f0d 100644 (file)
@@ -587,13 +587,13 @@ __setup("netdev=", netdev_boot_setup);
 struct net_device *__dev_get_by_name(struct net *net, const char *name)
 {
        struct hlist_node *p;
+       struct net_device *dev;
+       struct hlist_head *head = dev_name_hash(net, name);
 
-       hlist_for_each(p, dev_name_hash(net, name)) {
-               struct net_device *dev
-                       = hlist_entry(p, struct net_device, name_hlist);
+       hlist_for_each_entry(dev, p, head, name_hlist)
                if (!strncmp(dev->name, name, IFNAMSIZ))
                        return dev;
-       }
+
        return NULL;
 }
 EXPORT_SYMBOL(__dev_get_by_name);
@@ -638,13 +638,13 @@ EXPORT_SYMBOL(dev_get_by_name);
 struct net_device *__dev_get_by_index(struct net *net, int ifindex)
 {
        struct hlist_node *p;
+       struct net_device *dev;
+       struct hlist_head *head = dev_index_hash(net, ifindex);
 
-       hlist_for_each(p, dev_index_hash(net, ifindex)) {
-               struct net_device *dev
-                       = hlist_entry(p, struct net_device, index_hlist);
+       hlist_for_each_entry(dev, p, head, index_hlist)
                if (dev->ifindex == ifindex)
                        return dev;
-       }
+
        return NULL;
 }
 EXPORT_SYMBOL(__dev_get_by_index);