summaryrefslogtreecommitdiffstats
path: root/drivers/net/phy
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2017-12-04 07:27:14 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2017-12-06 15:49:15 +0100
commit48df7919f9c2787c23e5efade7d5a7af39d40f13 (patch)
tree8d5ddba1b5b19bdd34e030a15a34b921e83b6d9b /drivers/net/phy
parent725052d5fe1a1ae2979404ac265577ef3879f0f2 (diff)
downloadbarebox-48df7919f9c2787c23e5efade7d5a7af39d40f13.tar.gz
barebox-48df7919f9c2787c23e5efade7d5a7af39d40f13.tar.xz
mdio_bus: Port of_mdio_find_bus() from Linux kernel
Port of_mdio_find_bus() from Linux kernel. This function is used in MDIO multiplexor infrastructure added in following commit. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r--drivers/net/phy/mdio_bus.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 012b90e834..6ae85692da 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -207,6 +207,33 @@ struct mii_bus *mdiobus_get_bus(int busnum)
}
/**
+ * of_mdio_find_bus - Given an mii_bus node, find the mii_bus.
+ * @mdio_bus_np: Pointer to the mii_bus.
+ *
+ * Returns a reference to the mii_bus, or NULL if none found.
+ *
+ * Because the association of a device_node and mii_bus is made via
+ * mdiobus_register(), the mii_bus cannot be found before it is
+ * registered with mdiobus_register().
+ *
+ */
+struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np)
+{
+ struct mii_bus *mii;
+
+ if (!mdio_bus_np)
+ return NULL;
+
+ for_each_mii_bus(mii)
+ if (mii->dev.device_node == mdio_bus_np)
+ return mii;
+
+ return NULL;
+}
+EXPORT_SYMBOL(of_mdio_find_bus);
+
+
+/**
* mdio_bus_match - determine if given PHY driver supports the given PHY device
* @dev: target PHY device
* @drv: given PHY driver