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: cbb69c2fafcc ("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>
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 4827811..0f93c25 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -316,17 +316,14 @@
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 @@
{
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 @@
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 @@
/* 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