Introduce mdio_init() split off from mdio_alloc(), which is used
to initialize already allocated struct mii_dev.

Signed-off-by: Marek Vasut <marek.vasut+rene...@mailbox.org>
---
Cc: Christian Marangi <ansuels...@gmail.com>
Cc: Ilias Apalodimas <ilias.apalodi...@linaro.org>
Cc: Jerome Forissier <jerome.foriss...@linaro.org>
Cc: Jim Liu <jjl...@nuvoton.com>
Cc: Joe Hershberger <joe.hershber...@ni.com>
Cc: Mario Six <mario....@gdsys.cc>
Cc: Michal Simek <michal.si...@amd.com>
Cc: Nobuhiro Iwamatsu <iwama...@nigauri.org>
Cc: Paul Barker <paul.barker...@bp.renesas.com>
Cc: Ramon Fried <rfried....@gmail.com>
Cc: Simon Glass <s...@chromium.org>
Cc: Sughosh Ganu <sughosh.g...@linaro.org>
Cc: Tom Rini <tr...@konsulko.com>
Cc: u-boot@lists.denx.de
---
V2: No change
---
 common/miiphyutil.c | 13 +++++++++----
 include/miiphy.h    |  1 +
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/common/miiphyutil.c b/common/miiphyutil.c
index 9b8744e5d8b..2a034d3a77c 100644
--- a/common/miiphyutil.c
+++ b/common/miiphyutil.c
@@ -65,6 +65,14 @@ void miiphy_init(void)
        current_mii = NULL;
 }
 
+void mdio_init(struct mii_dev *bus)
+{
+       memset(bus, 0, sizeof(*bus));
+
+       /* initialize mii_dev struct fields */
+       INIT_LIST_HEAD(&bus->link);
+}
+
 struct mii_dev *mdio_alloc(void)
 {
        struct mii_dev *bus;
@@ -73,10 +81,7 @@ struct mii_dev *mdio_alloc(void)
        if (!bus)
                return bus;
 
-       memset(bus, 0, sizeof(*bus));
-
-       /* initalize mii_dev struct fields */
-       INIT_LIST_HEAD(&bus->link);
+       mdio_init(bus);
 
        return bus;
 }
diff --git a/include/miiphy.h b/include/miiphy.h
index 0464f5dc219..40eb14669b8 100644
--- a/include/miiphy.h
+++ b/include/miiphy.h
@@ -44,6 +44,7 @@ struct phy_device *mdio_phydev_for_ethname(const char 
*devname);
 
 void miiphy_listdev(void);
 
+void mdio_init(struct mii_dev *bus);
 struct mii_dev *mdio_alloc(void);
 void mdio_free(struct mii_dev *bus);
 int mdio_register(struct mii_dev *bus);
-- 
2.47.2

Reply via email to