netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: fix circular dependency in of_mdio code
@ 2014-06-26  7:10 Daniel Mack
  2014-06-27  7:26 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Mack @ 2014-06-26  7:10 UTC (permalink / raw)
  To: jeffm, davem; +Cc: f.fainelli, netdev, Daniel Mack

Commit 86f6cf4127 (net: of_mdio: add of_mdiobus_link_phydev()) introduced a
circular dependency between libphy and of_mdio.

depmod: ERROR: <modroot>/kernel/drivers/net/phy/libphy.ko in
dependency cycle!
depmod: ERROR: <modroot>/kernel/drivers/of/of_mdio.ko in dependency cycle!

The problem is that of_mdio.c references &mdio_bus_type and libphy now
references of_mdiobus_link_phydev.

Fix this by not exporting of_mdiobus_link_phydev() from of_mdio.ko.
Make it a static function in mdio_bus.c instead.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Reported-by: Jeff Mahoney <jeffm@suse.com>
Fixes: 86f6cf4127 (net: of_mdio: add of_mdiobus_link_phydev())
---
 drivers/net/phy/mdio_bus.c | 39 +++++++++++++++++++++++++++++++++++++++
 drivers/of/of_mdio.c       | 34 ----------------------------------
 include/linux/of_mdio.h    |  8 --------
 3 files changed, 39 insertions(+), 42 deletions(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 2e58aa5..afc0227 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -187,6 +187,45 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np)
 	return d ? to_mii_bus(d) : NULL;
 }
 EXPORT_SYMBOL(of_mdio_find_bus);
+
+/* Walk the list of subnodes of a mdio bus and look for a node that matches the
+ * phy's address with its 'reg' property. If found, set the of_node pointer for
+ * the phy. This allows auto-probed pyh devices to be supplied with information
+ * passed in via DT.
+ */
+static void of_mdiobus_link_phydev(struct mii_bus *mdio,
+				   struct phy_device *phydev)
+{
+	struct device *dev = &phydev->dev;
+	struct device_node *child;
+
+	if (dev->of_node || !mdio->dev.of_node)
+		return;
+
+	for_each_available_child_of_node(mdio->dev.of_node, child) {
+		int addr;
+		int ret;
+
+		ret = of_property_read_u32(child, "reg", &addr);
+		if (ret < 0) {
+			dev_err(dev, "%s has invalid PHY address\n",
+				child->full_name);
+			continue;
+		}
+
+		/* A PHY must have a reg property in the range [0-31] */
+		if (addr >= PHY_MAX_ADDR) {
+			dev_err(dev, "%s PHY address %i is too large\n",
+				child->full_name, addr);
+			continue;
+		}
+
+		if (addr == phydev->addr) {
+			dev->of_node = child;
+			return;
+		}
+	}
+}
 #endif
 
 /**
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index fb4a598..38fa57c 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -182,40 +182,6 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
 }
 EXPORT_SYMBOL(of_mdiobus_register);
 
-/**
- * of_mdiobus_link_phydev - Find a device node for a phy
- * @mdio: pointer to mii_bus structure
- * @phydev: phydev for which the of_node pointer should be set
- *
- * Walk the list of subnodes of a mdio bus and look for a node that matches the
- * phy's address with its 'reg' property. If found, set the of_node pointer for
- * the phy. This allows auto-probed pyh devices to be supplied with information
- * passed in via DT.
- */
-void of_mdiobus_link_phydev(struct mii_bus *mdio,
-			    struct phy_device *phydev)
-{
-	struct device *dev = &phydev->dev;
-	struct device_node *child;
-
-	if (dev->of_node || !mdio->dev.of_node)
-		return;
-
-	for_each_available_child_of_node(mdio->dev.of_node, child) {
-		int addr;
-
-		addr = of_mdio_parse_addr(&mdio->dev, child);
-		if (addr < 0)
-			continue;
-
-		if (addr == phydev->addr) {
-			dev->of_node = child;
-			return;
-		}
-	}
-}
-EXPORT_SYMBOL(of_mdiobus_link_phydev);
-
 /* Helper function for of_phy_find_device */
 static int of_phy_match(struct device *dev, void *phy_np)
 {
diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
index a70c949..d449018 100644
--- a/include/linux/of_mdio.h
+++ b/include/linux/of_mdio.h
@@ -25,9 +25,6 @@ struct phy_device *of_phy_attach(struct net_device *dev,
 
 extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
 
-extern void of_mdiobus_link_phydev(struct mii_bus *mdio,
-				   struct phy_device *phydev);
-
 #else /* CONFIG_OF */
 static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
 {
@@ -63,11 +60,6 @@ static inline struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np)
 {
 	return NULL;
 }
-
-static inline void of_mdiobus_link_phydev(struct mii_bus *mdio,
-					  struct phy_device *phydev)
-{
-}
 #endif /* CONFIG_OF */
 
 #if defined(CONFIG_OF) && defined(CONFIG_FIXED_PHY)
-- 
1.9.3

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

* Re: [PATCH] net: fix circular dependency in of_mdio code
  2014-06-26  7:10 [PATCH] net: fix circular dependency in of_mdio code Daniel Mack
@ 2014-06-27  7:26 ` David Miller
  2014-06-27 19:45   ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2014-06-27  7:26 UTC (permalink / raw)
  To: zonque; +Cc: jeffm, f.fainelli, netdev

From: Daniel Mack <zonque@gmail.com>
Date: Thu, 26 Jun 2014 09:10:31 +0200

> Commit 86f6cf4127 (net: of_mdio: add of_mdiobus_link_phydev()) introduced a
> circular dependency between libphy and of_mdio.
> 
> depmod: ERROR: <modroot>/kernel/drivers/net/phy/libphy.ko in
> dependency cycle!
> depmod: ERROR: <modroot>/kernel/drivers/of/of_mdio.ko in dependency cycle!
> 
> The problem is that of_mdio.c references &mdio_bus_type and libphy now
> references of_mdiobus_link_phydev.
> 
> Fix this by not exporting of_mdiobus_link_phydev() from of_mdio.ko.
> Make it a static function in mdio_bus.c instead.
> 
> Signed-off-by: Daniel Mack <zonque@gmail.com>
> Reported-by: Jeff Mahoney <jeffm@suse.com>
> Fixes: 86f6cf4127 (net: of_mdio: add of_mdiobus_link_phydev())

Applied, thank you.

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

* Re: [PATCH] net: fix circular dependency in of_mdio code
  2014-06-27  7:26 ` David Miller
@ 2014-06-27 19:45   ` David Miller
       [not found]     ` <1c64f353-b695-481b-8ffb-bc1fa2f45bae@email.android.com>
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2014-06-27 19:45 UTC (permalink / raw)
  To: zonque; +Cc: jeffm, f.fainelli, netdev

From: David Miller <davem@davemloft.net>
Date: Fri, 27 Jun 2014 00:26:26 -0700 (PDT)

> From: Daniel Mack <zonque@gmail.com>
> Date: Thu, 26 Jun 2014 09:10:31 +0200
> 
>> Commit 86f6cf4127 (net: of_mdio: add of_mdiobus_link_phydev()) introduced a
>> circular dependency between libphy and of_mdio.
>> 
>> depmod: ERROR: <modroot>/kernel/drivers/net/phy/libphy.ko in
>> dependency cycle!
>> depmod: ERROR: <modroot>/kernel/drivers/of/of_mdio.ko in dependency cycle!
>> 
>> The problem is that of_mdio.c references &mdio_bus_type and libphy now
>> references of_mdiobus_link_phydev.
>> 
>> Fix this by not exporting of_mdiobus_link_phydev() from of_mdio.ko.
>> Make it a static function in mdio_bus.c instead.
>> 
>> Signed-off-by: Daniel Mack <zonque@gmail.com>
>> Reported-by: Jeff Mahoney <jeffm@suse.com>
>> Fixes: 86f6cf4127 (net: of_mdio: add of_mdiobus_link_phydev())
> 
> Applied, thank you.

This doesn't work, it breaks the build:

drivers/net/phy/mdio_bus.c: In function ‘mdiobus_scan’:
drivers/net/phy/mdio_bus.c:346:2: error: implicit declaration of function ‘of_mdiobus_link_phydev’ [-Werror=implicit-function-declaration]

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

* Re: [PATCH] net: fix circular dependency in of_mdio code
       [not found]     ` <1c64f353-b695-481b-8ffb-bc1fa2f45bae@email.android.com>
@ 2014-06-27 20:00       ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-06-27 20:00 UTC (permalink / raw)
  To: daniel; +Cc: jeffm, f.fainelli, netdev

From: Daniel Mack <daniel@zonque.org>
Date: Fri, 27 Jun 2014 21:57:16 +0200

> Ok, we need a stub for !CONFIG_OF_MDIO. I'll send a patch in a few
> hours. Is one that goes on top ok? Or do you want me to send an
> amended version of the last one?

I never pushed your patch out, I removed it from my tree, so you need to send
me a completely new change.

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

end of thread, other threads:[~2014-06-27 20:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-26  7:10 [PATCH] net: fix circular dependency in of_mdio code Daniel Mack
2014-06-27  7:26 ` David Miller
2014-06-27 19:45   ` David Miller
     [not found]     ` <1c64f353-b695-481b-8ffb-bc1fa2f45bae@email.android.com>
2014-06-27 20:00       ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).