diff options
author | Daniel Mack <zonque@gmail.com> | 2014-06-27 19:23:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-02 03:24:14 -0400 |
commit | d9daa24720891a88bedb93928f57767da96e5c80 (patch) | |
tree | f661313d5ecf270e5fbbe43847b3e0a6411d18e0 | |
parent | eb608d2b99d993a4b4ee9cb70e6cf66f96bb1168 (diff) |
net: fix circular dependency in of_mdio code
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())
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/phy/mdio_bus.c | 44 | ||||
-rw-r--r-- | drivers/of/of_mdio.c | 34 | ||||
-rw-r--r-- | include/linux/of_mdio.h | 8 |
3 files changed, 44 insertions, 42 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 2e58aa54484c..4eaadcfcb0fe 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c | |||
@@ -187,6 +187,50 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np) | |||
187 | return d ? to_mii_bus(d) : NULL; | 187 | return d ? to_mii_bus(d) : NULL; |
188 | } | 188 | } |
189 | EXPORT_SYMBOL(of_mdio_find_bus); | 189 | EXPORT_SYMBOL(of_mdio_find_bus); |
190 | |||
191 | /* Walk the list of subnodes of a mdio bus and look for a node that matches the | ||
192 | * phy's address with its 'reg' property. If found, set the of_node pointer for | ||
193 | * the phy. This allows auto-probed pyh devices to be supplied with information | ||
194 | * passed in via DT. | ||
195 | */ | ||
196 | static void of_mdiobus_link_phydev(struct mii_bus *mdio, | ||
197 | struct phy_device *phydev) | ||
198 | { | ||
199 | struct device *dev = &phydev->dev; | ||
200 | struct device_node *child; | ||
201 | |||
202 | if (dev->of_node || !mdio->dev.of_node) | ||
203 | return; | ||
204 | |||
205 | for_each_available_child_of_node(mdio->dev.of_node, child) { | ||
206 | int addr; | ||
207 | int ret; | ||
208 | |||
209 | ret = of_property_read_u32(child, "reg", &addr); | ||
210 | if (ret < 0) { | ||
211 | dev_err(dev, "%s has invalid PHY address\n", | ||
212 | child->full_name); | ||
213 | continue; | ||
214 | } | ||
215 | |||
216 | /* A PHY must have a reg property in the range [0-31] */ | ||
217 | if (addr >= PHY_MAX_ADDR) { | ||
218 | dev_err(dev, "%s PHY address %i is too large\n", | ||
219 | child->full_name, addr); | ||
220 | continue; | ||
221 | } | ||
222 | |||
223 | if (addr == phydev->addr) { | ||
224 | dev->of_node = child; | ||
225 | return; | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | #else /* !IS_ENABLED(CONFIG_OF_MDIO) */ | ||
230 | static inline void of_mdiobus_link_phydev(struct mii_bus *mdio, | ||
231 | struct phy_device *phydev) | ||
232 | { | ||
233 | } | ||
190 | #endif | 234 | #endif |
191 | 235 | ||
192 | /** | 236 | /** |
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index a3bf2122a8d5..401b2453da45 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) | |||
182 | } | 182 | } |
183 | EXPORT_SYMBOL(of_mdiobus_register); | 183 | EXPORT_SYMBOL(of_mdiobus_register); |
184 | 184 | ||
185 | /** | ||
186 | * of_mdiobus_link_phydev - Find a device node for a phy | ||
187 | * @mdio: pointer to mii_bus structure | ||
188 | * @phydev: phydev for which the of_node pointer should be set | ||
189 | * | ||
190 | * Walk the list of subnodes of a mdio bus and look for a node that matches the | ||
191 | * phy's address with its 'reg' property. If found, set the of_node pointer for | ||
192 | * the phy. This allows auto-probed pyh devices to be supplied with information | ||
193 | * passed in via DT. | ||
194 | */ | ||
195 | void of_mdiobus_link_phydev(struct mii_bus *mdio, | ||
196 | struct phy_device *phydev) | ||
197 | { | ||
198 | struct device *dev = &phydev->dev; | ||
199 | struct device_node *child; | ||
200 | |||
201 | if (dev->of_node || !mdio->dev.of_node) | ||
202 | return; | ||
203 | |||
204 | for_each_available_child_of_node(mdio->dev.of_node, child) { | ||
205 | int addr; | ||
206 | |||
207 | addr = of_mdio_parse_addr(&mdio->dev, child); | ||
208 | if (addr < 0) | ||
209 | continue; | ||
210 | |||
211 | if (addr == phydev->addr) { | ||
212 | dev->of_node = child; | ||
213 | return; | ||
214 | } | ||
215 | } | ||
216 | } | ||
217 | EXPORT_SYMBOL(of_mdiobus_link_phydev); | ||
218 | |||
219 | /* Helper function for of_phy_find_device */ | 185 | /* Helper function for of_phy_find_device */ |
220 | static int of_phy_match(struct device *dev, void *phy_np) | 186 | static int of_phy_match(struct device *dev, void *phy_np) |
221 | { | 187 | { |
diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h index a70c9493d55a..d449018d0726 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, | |||
25 | 25 | ||
26 | extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np); | 26 | extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np); |
27 | 27 | ||
28 | extern void of_mdiobus_link_phydev(struct mii_bus *mdio, | ||
29 | struct phy_device *phydev); | ||
30 | |||
31 | #else /* CONFIG_OF */ | 28 | #else /* CONFIG_OF */ |
32 | static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) | 29 | static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) |
33 | { | 30 | { |
@@ -63,11 +60,6 @@ static inline struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np) | |||
63 | { | 60 | { |
64 | return NULL; | 61 | return NULL; |
65 | } | 62 | } |
66 | |||
67 | static inline void of_mdiobus_link_phydev(struct mii_bus *mdio, | ||
68 | struct phy_device *phydev) | ||
69 | { | ||
70 | } | ||
71 | #endif /* CONFIG_OF */ | 63 | #endif /* CONFIG_OF */ |
72 | 64 | ||
73 | #if defined(CONFIG_OF) && defined(CONFIG_FIXED_PHY) | 65 | #if defined(CONFIG_OF) && defined(CONFIG_FIXED_PHY) |