Use mdio_alloc() again to allocate MDIO bus. This is possible
because all the miiphybb parameters and ops passing is handled in
at bb_miiphy_read()/bb_miiphy_write() level.

This also fixes previously missed bb_miiphy_free() in .remove
callback of this driver. which does not pose a problem anymore.

Fixes: cbb69c2fafcc ("net: designware: Allocate bb_miiphy using 
bb_miiphy_alloc() and fill in callbacks")
Signed-off-by: Marek Vasut <marek.vasut+rene...@mailbox.org>
---
Cc: Jim Liu <jim.t90...@gmail.com>
Cc: Joe Hershberger <joe.hershber...@ni.com>
Cc: Mario Six <mario....@gdsys.cc>
Cc: Michael Chang <zhang971090...@gmail.com>
Cc: Nobuhiro Iwamatsu <iwama...@nigauri.org>
Cc: Parvathi Bhogaraju <pbhogar...@microsoft.com>
Cc: Paul Barker <paul.barker...@bp.renesas.com>
Cc: Ramon Fried <rfried....@gmail.com>
Cc: Tom Rini <tr...@konsulko.com>
Cc: u-boot@lists.denx.de
---
 drivers/net/designware.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 4827811dce3..0f93c25e3fe 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -316,17 +316,14 @@ static int dw_bb_miiphy_write(struct mii_dev *miidev, int 
addr,
 static int dw_bb_mdio_init(const char *name, struct udevice *dev)
 {
        struct dw_eth_dev *dwpriv = dev_get_priv(dev);
-       struct bb_miiphy_bus *bb_miiphy = bb_miiphy_alloc();
-       struct mii_dev *bus;
+       struct mii_dev *bus = mdio_alloc();
        int ret;
 
-       if (!bb_miiphy) {
+       if (!bus) {
                printf("Failed to allocate MDIO bus\n");
                return -ENOMEM;
        }
 
-       bus = &bb_miiphy->mii;
-
        debug("\n%s: use bitbang mii..\n", dev->name);
        ret = gpio_request_by_name(dev, "snps,mdc-gpio", 0,
                                   &dwpriv->mdc_gpio,
@@ -855,7 +852,6 @@ int designware_eth_probe(struct udevice *dev)
 {
        struct eth_pdata *pdata = dev_get_plat(dev);
        struct dw_eth_dev *priv = dev_get_priv(dev);
-       bool __maybe_unused bbmiiphy = false;
        phys_addr_t iobase = pdata->iobase;
        void *ioaddr;
        int ret, err;
@@ -947,8 +943,7 @@ int designware_eth_probe(struct udevice *dev)
        priv->max_speed = pdata->max_speed;
 
 #if IS_ENABLED(CONFIG_BITBANGMII) && IS_ENABLED(CONFIG_DM_GPIO)
-       bbmiiphy = dev_read_bool(dev, "snps,bitbang-mii");
-       if (bbmiiphy) {
+       if (dev_read_bool(dev, "snps,bitbang-mii")) {
                ret = dw_bb_mdio_init(dev->name, dev);
                if (ret) {
                        err = ret;
@@ -978,12 +973,7 @@ int designware_eth_probe(struct udevice *dev)
        /* continue here for cleanup if no PHY found */
        err = ret;
        mdio_unregister(priv->bus);
-#if IS_ENABLED(CONFIG_BITBANGMII) && IS_ENABLED(CONFIG_DM_GPIO)
-       if (bbmiiphy)
-               bb_miiphy_free(container_of(priv->bus, struct bb_miiphy_bus, 
mii));
-       else
-#endif
-               mdio_free(priv->bus);
+       mdio_free(priv->bus);
 mdio_err:
 
 #ifdef CONFIG_CLK
-- 
2.47.2

Reply via email to