[PATCH 02/11] net: miiphybb: Wrap driver side bb_miiphy_read/write() accessors

Marek Vasut marek.vasut+renesas at mailbox.org
Sun Mar 2 02:24:43 CET 2025


Do not call bb_miiphy_read()/bb_miiphy_write() accessors directly
in drivers, instead call them through wrapper functions. Those are
meant to be used as function parameter adaptation layer between
struct mii_dev callback function parameters and what the miiphybb
does expect and will soon expect. This is a preparatory patch, no
functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
---
Cc: Jim Liu <jim.t90615 at gmail.com>
Cc: Joe Hershberger <joe.hershberger at ni.com>
Cc: Mario Six <mario.six at gdsys.cc>
Cc: Michael Chang <zhang971090220 at gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
Cc: Parvathi Bhogaraju <pbhogaraju at microsoft.com>
Cc: Paul Barker <paul.barker.ct at bp.renesas.com>
Cc: Ramon Fried <rfried.dev at gmail.com>
Cc: Tom Rini <trini at konsulko.com>
Cc: u-boot at lists.denx.de
---
 board/gdsys/a38x/ihs_phys.c | 16 ++++++++++++++--
 drivers/net/designware.c    | 16 ++++++++++++++--
 drivers/net/ravb.c          | 16 ++++++++++++++--
 drivers/net/sh_eth.c        | 16 ++++++++++++++--
 4 files changed, 56 insertions(+), 8 deletions(-)

diff --git a/board/gdsys/a38x/ihs_phys.c b/board/gdsys/a38x/ihs_phys.c
index c999ab6d6fa..304b5b5f0bc 100644
--- a/board/gdsys/a38x/ihs_phys.c
+++ b/board/gdsys/a38x/ihs_phys.c
@@ -228,6 +228,18 @@ static const struct bb_miiphy_bus_ops mii_bb_miiphy_bus_ops = {
 	.delay		= mii_delay,
 };
 
+static int mii_bb_miiphy_read(struct mii_dev *miidev, int addr,
+			      int devad, int reg)
+{
+	return bb_miiphy_read(miidev, addr, devad, reg);
+}
+
+static int mii_bb_miiphy_write(struct mii_dev *miidev, int addr,
+			       int devad, int reg, u16 value)
+{
+	return bb_miiphy_write(miidev, addr, devad, reg, value);
+}
+
 int register_miiphy_bus(uint k, struct mii_dev **bus)
 {
 	struct bb_miiphy_bus *bb_miiphy = bb_miiphy_alloc();
@@ -239,8 +251,8 @@ int register_miiphy_bus(uint k, struct mii_dev **bus)
 
 	mdiodev = &bb_miiphy->mii;
 	snprintf(mdiodev->name, MDIO_NAME_LEN, "ihs%d", k);
-	mdiodev->read = bb_miiphy_read;
-	mdiodev->write = bb_miiphy_write;
+	mdiodev->read = mii_bb_miiphy_read;
+	mdiodev->write = mii_bb_miiphy_write;
 
 	/* Copy the bus accessors and private data */
 	bb_miiphy->ops = &mii_bb_miiphy_bus_ops;
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 045bff476d1..3c3450aa778 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -299,6 +299,18 @@ static const struct bb_miiphy_bus_ops dw_eth_bb_miiphy_bus_ops = {
 	.delay		= dw_eth_bb_delay,
 };
 
+static int dw_bb_miiphy_read(struct mii_dev *miidev, int addr,
+			     int devad, int reg)
+{
+	return bb_miiphy_read(miidev, addr, devad, reg);
+}
+
+static int dw_bb_miiphy_write(struct mii_dev *miidev, int addr,
+			      int devad, int reg, u16 value)
+{
+	return bb_miiphy_write(miidev, addr, devad, reg, value);
+}
+
 static int dw_bb_mdio_init(const char *name, struct udevice *dev)
 {
 	struct dw_eth_dev *dwpriv = dev_get_priv(dev);
@@ -334,8 +346,8 @@ static int dw_bb_mdio_init(const char *name, struct udevice *dev)
 	dwpriv->dev = dev;
 
 	snprintf(bus->name, sizeof(bus->name), "%s", name);
-	bus->read = bb_miiphy_read;
-	bus->write = bb_miiphy_write;
+	bus->read = dw_bb_miiphy_read;
+	bus->write = dw_bb_miiphy_write;
 #if CONFIG_IS_ENABLED(DM_GPIO)
 	bus->reset = dw_mdio_reset;
 #endif
diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index bd4900270a2..9a17ac97cce 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -558,6 +558,18 @@ static const struct bb_miiphy_bus_ops ravb_bb_miiphy_bus_ops = {
 	.delay		= ravb_bb_delay,
 };
 
+static int ravb_bb_miiphy_read(struct mii_dev *miidev, int addr,
+			       int devad, int reg)
+{
+	return bb_miiphy_read(miidev, addr, devad, reg);
+}
+
+static int ravb_bb_miiphy_write(struct mii_dev *miidev, int addr,
+				int devad, int reg, u16 value)
+{
+	return bb_miiphy_write(miidev, addr, devad, reg, value);
+}
+
 static int ravb_probe(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
@@ -582,8 +594,8 @@ static int ravb_probe(struct udevice *dev)
 
 	mdiodev = &bb_miiphy->mii;
 
-	mdiodev->read = bb_miiphy_read;
-	mdiodev->write = bb_miiphy_write;
+	mdiodev->read = ravb_bb_miiphy_read;
+	mdiodev->write = ravb_bb_miiphy_write;
 	snprintf(mdiodev->name, sizeof(mdiodev->name), dev->name);
 
 	/* Copy the bus accessors and private data */
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index 0693c240fbd..cef531c8c6f 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -720,6 +720,18 @@ static const struct bb_miiphy_bus_ops sh_ether_bb_miiphy_bus_ops = {
 	.delay		= sh_eth_bb_delay,
 };
 
+static int sh_eth_bb_miiphy_read(struct mii_dev *miidev, int addr,
+				 int devad, int reg)
+{
+	return bb_miiphy_read(miidev, addr, devad, reg);
+}
+
+static int sh_eth_bb_miiphy_write(struct mii_dev *miidev, int addr,
+				  int devad, int reg, u16 value)
+{
+	return bb_miiphy_write(miidev, addr, devad, reg, value);
+}
+
 static int sh_ether_probe(struct udevice *udev)
 {
 	struct eth_pdata *pdata = dev_get_plat(udev);
@@ -744,8 +756,8 @@ static int sh_ether_probe(struct udevice *udev)
 
 	mdiodev = &bb_miiphy->mii;
 
-	mdiodev->read = bb_miiphy_read;
-	mdiodev->write = bb_miiphy_write;
+	mdiodev->read = sh_eth_bb_miiphy_read;
+	mdiodev->write = sh_eth_bb_miiphy_write;
 	snprintf(mdiodev->name, sizeof(mdiodev->name), udev->name);
 
 	/* Copy the bus accessors and private data */
-- 
2.47.2



More information about the U-Boot mailing list