--- zzzz-none-000/linux-4.4.60/drivers/net/phy/mdio_bus.c 2017-04-08 07:53:53.000000000 +0000 +++ jet-2400-727/linux-4.4.60/drivers/net/phy/mdio_bus.c 2021-03-17 14:36:41.000000000 +0000 @@ -38,6 +38,8 @@ #include +#include "mdio-boardinfo.h" + /** * mdiobus_alloc_size - allocate a mii_bus structure * @size: extra amount of memory to allocate for private storage. @@ -346,9 +348,21 @@ } 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); @@ -361,6 +375,12 @@ */ of_mdiobus_link_phydev(bus, 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);