Skip to content

Commit

Permalink
net: core: recursively find netdev by device node
Browse files Browse the repository at this point in the history
The assumption that a device node is associated either with the
netdev's device, or the parent of that device, does not hold for all
drivers. E.g. Freescale's DPAA has two layers of platform devices
above the netdev. Instead, recursively walk up the tree from the
netdev, allowing any parent to match against the sought after node.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tobias Waldekranz authored and David S. Miller committed May 15, 2020
1 parent d00f26b commit 2e186a2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions net/core/net-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1805,12 +1805,12 @@ static struct class net_class __ro_after_init = {
#ifdef CONFIG_OF_NET
static int of_dev_node_match(struct device *dev, const void *data)
{
int ret = 0;

if (dev->parent)
ret = dev->parent->of_node == data;
for (; dev; dev = dev->parent) {
if (dev->of_node == data)
return 1;
}

return ret == 0 ? dev->of_node == data : ret;
return 0;
}

/*
Expand Down

0 comments on commit 2e186a2

Please sign in to comment.