--- zzzz-none-000/linux-3.10.107/drivers/net/phy/mdio_bus.c 2017-06-27 09:49:32.000000000 +0000 +++ vr9-7490-729/linux-3.10.107/drivers/net/phy/mdio_bus.c 2021-11-10 11:53:55.000000000 +0000 @@ -41,6 +41,8 @@ #include #include +#include "mdio-boardinfo.h" + /** * mdiobus_alloc_size - allocate a mii_bus structure * @size: extra amount of memory to allocate for private storage. @@ -229,15 +231,33 @@ } EXPORT_SYMBOL(mdiobus_free); +static void mdiobus_setup_phydev_from_boardinfo(struct mii_bus *bus, + struct phy_device *phydev, + struct mdio_board_info *bi) +{ + if (strcmp(bus->id, bi->bus_id) || + bi->phy_addr != phydev->addr) + return; + + phydev->dev.platform_data = (void *) bi->platform_data; +} + struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr) { struct phy_device *phydev; + struct mdio_board_entry *be; int err; phydev = get_phy_device(bus, addr, false); if (IS_ERR(phydev) || phydev == NULL) return phydev; + mutex_lock(&__mdio_board_lock); + list_for_each_entry(be, &__mdio_board_list, list) + mdiobus_setup_phydev_from_boardinfo(bus, phydev, + &be->board_info); + mutex_unlock(&__mdio_board_lock); + err = phy_device_register(phydev); if (err) { phy_device_free(phydev);