net: designware: Switch back to mdio_alloc()

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: cbb69c2faf ("net: designware: Allocate bb_miiphy using bb_miiphy_alloc() and fill in callbacks")
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Reviewed-by: Paul Barker <paul.barker.ct@bp.renesas.com>
This commit is contained in:
Marek Vasut
2025-03-02 02:24:47 +01:00
parent 596d67e516
commit ce7e9a5a63

View File

@@ -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,11 +973,6 @@ 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_err: