net: miiphybb: Drop name field from struct bb_miiphy_bus

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@bp.renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
This commit is contained in:
Marek Vasut 2025-02-22 21:33:29 +01:00
parent ed4ab7c5e0
commit a23f9a786b
5 changed files with 6 additions and 23 deletions

View File

@ -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,

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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,

View File

@ -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);