--- zzzz-none-000/linux-4.4.271/drivers/net/phy/mdio_bus.c 2021-06-03 06:22:09.000000000 +0000 +++ hawkeye-5590-750/linux-4.4.271/drivers/net/phy/mdio_bus.c 2023-04-19 10:22:29.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. @@ -345,9 +347,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); @@ -360,6 +374,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);