Allocate bb_miiphy using bb_miiphy_alloc() and fill in callbacks currently listed in bb_miiphy_buses[] array. This is a temporary duplication of assignment to avoid breakage, which will be removed in follow up patches. At this point, the bb_miiphy callbacks can reach these accessors by doing container_of() on struct mii_dev.
Signed-off-by: Marek Vasut <[email protected]> --- Cc: Christian Marangi <[email protected]> Cc: Ilias Apalodimas <[email protected]> Cc: Jerome Forissier <[email protected]> Cc: Jim Liu <[email protected]> Cc: Joe Hershberger <[email protected]> Cc: Mario Six <[email protected]> Cc: Michal Simek <[email protected]> Cc: Nobuhiro Iwamatsu <[email protected]> Cc: Paul Barker <[email protected]> Cc: Ramon Fried <[email protected]> Cc: Simon Glass <[email protected]> Cc: Sughosh Ganu <[email protected]> Cc: Tom Rini <[email protected]> Cc: [email protected] --- V2: No change V3: No change --- board/gdsys/a38x/ihs_phys.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/board/gdsys/a38x/ihs_phys.c b/board/gdsys/a38x/ihs_phys.c index 86708ee6715..a121898be52 100644 --- a/board/gdsys/a38x/ihs_phys.c +++ b/board/gdsys/a38x/ihs_phys.c @@ -221,22 +221,35 @@ static int mii_delay(struct bb_miiphy_bus *bus) int register_miiphy_bus(uint k, struct mii_dev **bus) { - int retval; - struct mii_dev *mdiodev = mdio_alloc(); + struct bb_miiphy_bus *bb_miiphy = bb_miiphy_alloc(); + struct mii_dev *mdiodev; char *name = bb_miiphy_buses[k].name; + int retval; - if (!mdiodev) + if (!bb_miiphy) return -ENOMEM; + + mdiodev = &bb_miiphy->mii; strlcpy(mdiodev->name, name, MDIO_NAME_LEN); mdiodev->read = bb_miiphy_read; mdiodev->write = bb_miiphy_write; + /* Copy the bus accessors, name and private data */ + bb_miiphy->mdio_active = mii_mdio_active; + bb_miiphy->mdio_tristate = mii_mdio_tristate; + bb_miiphy->set_mdio = mii_set_mdio; + bb_miiphy->get_mdio = mii_get_mdio; + bb_miiphy->set_mdc = mii_set_mdc; + bb_miiphy->delay = mii_delay; + strlcpy(bb_miiphy->name, name, MDIO_NAME_LEN); + bb_miiphy->priv = &gpio_mii_set[k]; + retval = mdio_register(mdiodev); if (retval < 0) return retval; *bus = miiphy_get_dev_by_name(name); - return mii_mdio_init(&bb_miiphy_buses[k]); + return mii_mdio_init(bb_miiphy); } struct porttype *get_porttype(uint octo_phy_mask, uint k) -- 2.47.2

