[PATCH 10/17] net: miiphybb: Drop name field from struct bb_miiphy_bus

Marek Vasut marek.vasut+renesas at mailbox.org
Sat Jan 18 07:53:14 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.

Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
---
Cc: Christian Marangi <ansuelsmth at gmail.com>
Cc: Evgeny Bachinin <EABachinin at salutedevices.com>
Cc: Ilias Apalodimas <ilias.apalodimas at linaro.org>
Cc: Jerome Forissier <jerome.forissier at linaro.org>
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
---
 board/gdsys/a38x/ihs_phys.c | 11 +++--------
 drivers/net/ravb.c          |  6 +-----
 drivers/net/sh_eth.c        |  6 +-----
 include/miiphy.h            |  1 -
 4 files changed, 5 insertions(+), 19 deletions(-)

diff --git a/board/gdsys/a38x/ihs_phys.c b/board/gdsys/a38x/ihs_phys.c
index aa738016025..2b598abb7f0 100644
--- a/board/gdsys/a38x/ihs_phys.c
+++ b/board/gdsys/a38x/ihs_phys.c
@@ -223,18 +223,17 @@ 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->init = mii_mdio_init;
 	bb_miiphy->mdio_active = mii_mdio_active;
 	bb_miiphy->mdio_tristate = mii_mdio_tristate;
@@ -242,13 +241,12 @@ int register_miiphy_bus(uint k, struct mii_dev **bus)
 	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 0;
 }
@@ -331,7 +329,6 @@ int init_octo_phys(uint octo_phy_mask)
 
 struct bb_miiphy_bus bb_miiphy_buses[] = {
 	{
-		.name = "ihs0",
 		.init = mii_mdio_init,
 		.mdio_active = mii_mdio_active,
 		.mdio_tristate = mii_mdio_tristate,
@@ -342,7 +339,6 @@ struct bb_miiphy_bus bb_miiphy_buses[] = {
 		.priv = &gpio_mii_set[0],
 	},
 	{
-		.name = "ihs1",
 		.init = mii_mdio_init,
 		.mdio_active = mii_mdio_active,
 		.mdio_tristate = mii_mdio_tristate,
@@ -353,7 +349,6 @@ struct bb_miiphy_bus bb_miiphy_buses[] = {
 		.priv = &gpio_mii_set[1],
 	},
 	{
-		.name = "ihs2",
 		.init = mii_mdio_init,
 		.mdio_active = mii_mdio_active,
 		.mdio_tristate = mii_mdio_tristate,
diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index 60454d1a579..efcf176c6ad 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -578,7 +578,7 @@ 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->init = NULL;
 	bb_miiphy->mdio_active = ravb_bb_mdio_active;
 	bb_miiphy->mdio_tristate = ravb_bb_mdio_tristate;
@@ -586,7 +586,6 @@ static int ravb_probe(struct udevice *dev)
 	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);
@@ -635,7 +634,6 @@ static int ravb_remove(struct udevice *dev)
 
 struct bb_miiphy_bus bb_miiphy_buses[] = {
 	{
-		.name		= "ravb",
 		.init		= NULL,
 		.mdio_active	= ravb_bb_mdio_active,
 		.mdio_tristate	= ravb_bb_mdio_tristate,
@@ -668,8 +666,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 a765c280ff0..ccfb31d40fd 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -740,7 +740,7 @@ 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->init = NULL;
 	bb_miiphy->mdio_active = sh_eth_bb_mdio_active;
 	bb_miiphy->mdio_tristate = sh_eth_bb_mdio_tristate;
@@ -748,7 +748,6 @@ static int sh_ether_probe(struct udevice *udev)
 	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);
@@ -830,8 +829,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;
 }
 
@@ -860,7 +857,6 @@ U_BOOT_DRIVER(eth_sh_ether) = {
 
 struct bb_miiphy_bus bb_miiphy_buses[] = {
 	{
-		.name		= "sh_eth",
 		.init		= NULL,
 		.mdio_active	= sh_eth_bb_mdio_active,
 		.mdio_tristate	= sh_eth_bb_mdio_tristate,
diff --git a/include/miiphy.h b/include/miiphy.h
index 962ace13079..03ae4e0078a 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 (*init)(struct bb_miiphy_bus *bus);
 	int (*mdio_active)(struct bb_miiphy_bus *bus);
 	int (*mdio_tristate)(struct bb_miiphy_bus *bus);
-- 
2.45.2



More information about the U-Boot mailing list