Add mdiobus_get_bus() -- a function to get a MDIO bus by its number Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx> --- drivers/net/phy/mdio_bus.c | 19 +++++++++++++++++++ include/linux/phy.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 54d2f8f..b74b27e 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -187,6 +187,25 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr) } EXPORT_SYMBOL(mdiobus_scan); + +/** + * + * mdio_get_bus - get a MDIO bus from its busnum + * + * @param busnum the desired bus number + * + */ +struct mii_bus *mdiobus_get_bus(int busnum) +{ + struct mii_bus *mii; + + for_each_mii_bus(mii) + if (mii->dev.id == busnum) + return mii; + + return NULL; +} + /** * mdio_bus_match - determine if given PHY driver supports the given PHY device * @dev: target PHY device diff --git a/include/linux/phy.h b/include/linux/phy.h index 58e69da..4e88936 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -114,6 +114,8 @@ int mdiobus_detect(struct device_d *dev); #define for_each_mii_bus(mii) \ list_for_each_entry(mii, &mii_bus_list, list) +struct mii_bus *mdiobus_get_bus(int busnum); + /** * mdiobus_read - Convenience function for reading a given MII mgmt register * @bus: the mii_bus struct -- 2.5.0 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox