Commit 0bd8d536 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: use hlist_for_each_entry()

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: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 24540535
...@@ -587,13 +587,13 @@ __setup("netdev=", netdev_boot_setup); ...@@ -587,13 +587,13 @@ __setup("netdev=", netdev_boot_setup);
struct net_device *__dev_get_by_name(struct net *net, const char *name) struct net_device *__dev_get_by_name(struct net *net, const char *name)
{ {
struct hlist_node *p; 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)) { hlist_for_each_entry(dev, p, head, name_hlist)
struct net_device *dev
= hlist_entry(p, struct net_device, name_hlist);
if (!strncmp(dev->name, name, IFNAMSIZ)) if (!strncmp(dev->name, name, IFNAMSIZ))
return dev; return dev;
}
return NULL; return NULL;
} }
EXPORT_SYMBOL(__dev_get_by_name); EXPORT_SYMBOL(__dev_get_by_name);
...@@ -638,13 +638,13 @@ 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 net_device *__dev_get_by_index(struct net *net, int ifindex)
{ {
struct hlist_node *p; 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)) { hlist_for_each_entry(dev, p, head, index_hlist)
struct net_device *dev
= hlist_entry(p, struct net_device, index_hlist);
if (dev->ifindex == ifindex) if (dev->ifindex == ifindex)
return dev; return dev;
}
return NULL; return NULL;
} }
EXPORT_SYMBOL(__dev_get_by_index); EXPORT_SYMBOL(__dev_get_by_index);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment