aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/net/core/net-sysfs.c
diff options
context:
space:
mode:
authorTobias Waldekranz <tobias@waldekranz.com>2020-05-15 11:52:52 +0200
committerDavid S. Miller <davem@davemloft.net>2020-05-15 10:18:49 -0700
commit2e186a2cf8c785f38ef3237e83f8921f82f6e2b7 (patch)
tree0587fcc00ad19a9a1cc43b7652ad243ef6a6ef10 /net/core/net-sysfs.c
parentMerge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next (diff)
downloadwireguard-linux-2e186a2cf8c785f38ef3237e83f8921f82f6e2b7.tar.xz
wireguard-linux-2e186a2cf8c785f38ef3237e83f8921f82f6e2b7.zip
net: core: recursively find netdev by device node
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>
Diffstat (limited to '')
-rw-r--r--net/core/net-sysfs.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 880e89c894f6..e353b822bb15 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -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;
}
/*