[PATCH v3 19/23] net: miiphybb: Drop name field from struct bb_miiphy_bus

Marek Vasut marek.vasut+renesas at mailbox.org
Sat Feb 22 21:33:29 CET 2025


The struct bb_miiphy_bus embeds struct struct mii_dev, which
already contains one copy of name field. Drop the duplicate
top level copy of name field.

The a38x code does static assignment of disparate names, use
snprintf(...) to fill in matching name in probe to avoid any
breakage.

Reviewed-by: Paul Barker <paul.barker.ct at bp.renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
---
Cc: Christian Marangi <ansuelsmth at gmail.com>
Cc: Ilias Apalodimas <ilias.apalodimas at linaro.org>
Cc: Jerome Forissier <jerome.forissier at linaro.org>
Cc: Jim Liu <JJLIU0 at nuvoton.com>
Cc: Joe Hershberger <joe.hershberger at ni.com>
Cc: Mario Six <mario.six at gdsys.cc>
Cc: Michal Simek <michal.simek at amd.com>
Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
Cc: Paul Barker <paul.barker.ct at bp.renesas.com>
Cc: Ramon Fried <rfried.dev at gmail.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Sughosh Ganu <sughosh.ganu at linaro.org>
Cc: Tom Rini <trini at konsulko.com>
Cc: u-boot at lists.denx.de
---
V2: Fold in recently added DWC bbmiiphy too
V3: Add RB from Paul
---
 board/gdsys/a38x/ihs_phys.c | 11 +++--------
 drivers/net/designware.c    |  5 +----
 drivers/net/ravb.c          |  6 +-----
 drivers/net/sh_eth.c        |  6 +-----
 include/miiphy.h            |  1 -
 5 files changed, 6 insertions(+), 23 deletions(-)

diff --git a/board/gdsys/a38x/ihs_phys.c b/board/gdsys/a38x/ihs_phys.c
index a121898be52..128b1395243 100644
--- a/board/gdsys/a38x/ihs_phys.c
+++ b/board/gdsys/a38x/ihs_phys.c
@@ -223,31 +223,29 @@ int register_miiphy_bus(uint k, struct mii_dev **bus)
 {
 	struct bb_miiphy_bus *bb_miiphy = bb_miiphy_alloc();
 	struct mii_dev *mdiodev;
-	char *name = bb_miiphy_buses[k].name;
 	int retval;
 
 	if (!bb_miiphy)
 		return -ENOMEM;
 
 	mdiodev = &bb_miiphy->mii;
-	strlcpy(mdiodev->name, name, MDIO_NAME_LEN);
+	snprintf(mdiodev->name, MDIO_NAME_LEN, "ihs%d", k);
 	mdiodev->read = bb_miiphy_read;
 	mdiodev->write = bb_miiphy_write;
 
-	/* Copy the bus accessors, name and private data */
+	/* Copy the bus accessors and private data */
 	bb_miiphy->mdio_active = mii_mdio_active;
 	bb_miiphy->mdio_tristate = mii_mdio_tristate;
 	bb_miiphy->set_mdio = mii_set_mdio;
 	bb_miiphy->get_mdio = mii_get_mdio;
 	bb_miiphy->set_mdc = mii_set_mdc;
 	bb_miiphy->delay = mii_delay;
-	strlcpy(bb_miiphy->name, name, MDIO_NAME_LEN);
 	bb_miiphy->priv = &gpio_mii_set[k];
 
 	retval = mdio_register(mdiodev);
 	if (retval < 0)
 		return retval;
-	*bus = miiphy_get_dev_by_name(name);
+	*bus = miiphy_get_dev_by_name(mdiodev->name);
 
 	return mii_mdio_init(bb_miiphy);
 }
@@ -330,7 +328,6 @@ int init_octo_phys(uint octo_phy_mask)
 
 struct bb_miiphy_bus bb_miiphy_buses[] = {
 	{
-		.name = "ihs0",
 		.mdio_active = mii_mdio_active,
 		.mdio_tristate = mii_mdio_tristate,
 		.set_mdio = mii_set_mdio,
@@ -340,7 +337,6 @@ struct bb_miiphy_bus bb_miiphy_buses[] = {
 		.priv = &gpio_mii_set[0],
 	},
 	{
-		.name = "ihs1",
 		.mdio_active = mii_mdio_active,
 		.mdio_tristate = mii_mdio_tristate,
 		.set_mdio = mii_set_mdio,
@@ -350,7 +346,6 @@ struct bb_miiphy_bus bb_miiphy_buses[] = {
 		.priv = &gpio_mii_set[1],
 	},
 	{
-		.name = "ihs2",
 		.mdio_active = mii_mdio_active,
 		.mdio_tristate = mii_mdio_tristate,
 		.set_mdio = mii_set_mdio,
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 74cf8271e67..5124982e683 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -292,7 +292,6 @@ static int dw_eth_bb_delay(struct bb_miiphy_bus *bus)
 
 struct bb_miiphy_bus bb_miiphy_buses[] = {
 	{
-		.name		= BB_MII_DEVNAME,
 		.mdio_active	= dw_eth_bb_mdio_active,
 		.mdio_tristate	= dw_eth_bb_mdio_tristate,
 		.set_mdio	= dw_eth_bb_set_mdio,
@@ -340,7 +339,6 @@ static int dw_bb_mdio_init(const char *name, struct udevice *dev)
 
 	bb_miiphy_buses[0].priv = dwpriv;
 	snprintf(bus->name, sizeof(bus->name), "%s", name);
-	strlcpy(bb_miiphy_buses[0].name, bus->name, MDIO_NAME_LEN);
 	bus->read = bb_miiphy_read;
 	bus->write = bb_miiphy_write;
 #if CONFIG_IS_ENABLED(DM_GPIO)
@@ -348,14 +346,13 @@ static int dw_bb_mdio_init(const char *name, struct udevice *dev)
 #endif
 	bus->priv = dwpriv;
 
-	/* Copy the bus accessors, name and private data */
+	/* Copy the bus accessors and private data */
 	bb_miiphy->mdio_active = dw_eth_bb_mdio_active;
 	bb_miiphy->mdio_tristate = dw_eth_bb_mdio_tristate;
 	bb_miiphy->set_mdio = dw_eth_bb_set_mdio;
 	bb_miiphy->get_mdio = dw_eth_bb_get_mdio;
 	bb_miiphy->set_mdc = dw_eth_bb_set_mdc;
 	bb_miiphy->delay = dw_eth_bb_delay;
-	strlcpy(bb_miiphy->name, bus->name, MDIO_NAME_LEN);
 
 	return mdio_register(bus);
 }
diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index 0018b694ec1..86787183488 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -578,14 +578,13 @@ static int ravb_probe(struct udevice *dev)
 	bb_miiphy_buses[0].priv = eth;
 	snprintf(mdiodev->name, sizeof(mdiodev->name), dev->name);
 
-	/* Copy the bus accessors, name and private data */
+	/* Copy the bus accessors and private data */
 	bb_miiphy->mdio_active = ravb_bb_mdio_active;
 	bb_miiphy->mdio_tristate = ravb_bb_mdio_tristate;
 	bb_miiphy->set_mdio = ravb_bb_set_mdio;
 	bb_miiphy->get_mdio = ravb_bb_get_mdio;
 	bb_miiphy->set_mdc = ravb_bb_set_mdc;
 	bb_miiphy->delay = ravb_bb_delay;
-	strlcpy(bb_miiphy->name, "ravb", MDIO_NAME_LEN);
 	bb_miiphy->priv = eth;
 
 	ret = mdio_register(mdiodev);
@@ -634,7 +633,6 @@ static int ravb_remove(struct udevice *dev)
 
 struct bb_miiphy_bus bb_miiphy_buses[] = {
 	{
-		.name		= "ravb",
 		.mdio_active	= ravb_bb_mdio_active,
 		.mdio_tristate	= ravb_bb_mdio_tristate,
 		.set_mdio	= ravb_bb_set_mdio,
@@ -666,8 +664,6 @@ int ravb_of_to_plat(struct udevice *dev)
 
 	pdata->max_speed = dev_read_u32_default(dev, "max-speed", 1000);
 
-	sprintf(bb_miiphy_buses[0].name, dev->name);
-
 	return 0;
 }
 
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index e78d64d77c3..49065ebe717 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -740,14 +740,13 @@ static int sh_ether_probe(struct udevice *udev)
 	bb_miiphy_buses[0].priv = eth;
 	snprintf(mdiodev->name, sizeof(mdiodev->name), udev->name);
 
-	/* Copy the bus accessors, name and private data */
+	/* Copy the bus accessors and private data */
 	bb_miiphy->mdio_active = sh_eth_bb_mdio_active;
 	bb_miiphy->mdio_tristate = sh_eth_bb_mdio_tristate;
 	bb_miiphy->set_mdio = sh_eth_bb_set_mdio;
 	bb_miiphy->get_mdio = sh_eth_bb_get_mdio;
 	bb_miiphy->set_mdc = sh_eth_bb_set_mdc;
 	bb_miiphy->delay = sh_eth_bb_delay;
-	strlcpy(bb_miiphy->name, "sh_eth", MDIO_NAME_LEN);
 	bb_miiphy->priv = eth;
 
 	ret = mdio_register(mdiodev);
@@ -829,8 +828,6 @@ int sh_ether_of_to_plat(struct udevice *dev)
 	if (cell)
 		pdata->max_speed = fdt32_to_cpu(*cell);
 
-	sprintf(bb_miiphy_buses[0].name, dev->name);
-
 	return 0;
 }
 
@@ -859,7 +856,6 @@ U_BOOT_DRIVER(eth_sh_ether) = {
 
 struct bb_miiphy_bus bb_miiphy_buses[] = {
 	{
-		.name		= "sh_eth",
 		.mdio_active	= sh_eth_bb_mdio_active,
 		.mdio_tristate	= sh_eth_bb_mdio_tristate,
 		.set_mdio	= sh_eth_bb_set_mdio,
diff --git a/include/miiphy.h b/include/miiphy.h
index 42300ee5386..efeff8ae70b 100644
--- a/include/miiphy.h
+++ b/include/miiphy.h
@@ -65,7 +65,6 @@ void mdio_list_devices(void);
 #define BB_MII_DEVNAME	"bb_miiphy"
 
 struct bb_miiphy_bus {
-	char name[MDIO_NAME_LEN];
 	int (*mdio_active)(struct bb_miiphy_bus *bus);
 	int (*mdio_tristate)(struct bb_miiphy_bus *bus);
 	int (*set_mdio)(struct bb_miiphy_bus *bus, int v);
-- 
2.47.2



More information about the U-Boot mailing list