Skip to content

Commit

Permalink
net: use hlist_for_each_entry()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Oct 30, 2009
1 parent 2454053 commit 0bd8d53
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0bd8d53

Please sign in to comment.