All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: core: recursively find netdev by device node
@ 2020-05-15  9:52 Tobias Waldekranz
  2020-05-15 16:00 ` Florian Fainelli
  2020-05-15 17:19 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Tobias Waldekranz @ 2020-05-15  9:52 UTC (permalink / raw)
  To: davem; +Cc: netdev, f.fainelli, andrew

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>
---
 net/core/net-sysfs.c | 10 +++++-----
 1 file 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;
 }
 
 /*
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: core: recursively find netdev by device node
  2020-05-15  9:52 [PATCH net-next] net: core: recursively find netdev by device node Tobias Waldekranz
@ 2020-05-15 16:00 ` Florian Fainelli
  2020-05-15 17:19 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2020-05-15 16:00 UTC (permalink / raw)
  To: Tobias Waldekranz, davem; +Cc: netdev, andrew



On 5/15/2020 2:52 AM, Tobias Waldekranz wrote:
> 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>

Humm, yes I tried to solve this differently before within the Freescale
FMAN driver before and it failed miserably, so I suppose this is as good
as it can be:

a1a50c8e4c241a505b7270e1a3c6e50d94e794b1 ("fsl/man: Inherit parent
device and of_node") later reverted with
48167c9ce0b91c068430345bf039c7be23fa2f3f ("fsl/fman: remove of_node")

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: core: recursively find netdev by device node
  2020-05-15  9:52 [PATCH net-next] net: core: recursively find netdev by device node Tobias Waldekranz
  2020-05-15 16:00 ` Florian Fainelli
@ 2020-05-15 17:19 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-05-15 17:19 UTC (permalink / raw)
  To: tobias; +Cc: netdev, f.fainelli, andrew

From: Tobias Waldekranz <tobias@waldekranz.com>
Date: Fri, 15 May 2020 11:52:52 +0200

> 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>

Applied, thanks Tobias.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-15 17:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-15  9:52 [PATCH net-next] net: core: recursively find netdev by device node Tobias Waldekranz
2020-05-15 16:00 ` Florian Fainelli
2020-05-15 17:19 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.