]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: miiphybb: Drop name field from struct bb_miiphy_bus
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Sat, 22 Feb 2025 20:33:29 +0000 (21:33 +0100)
committerMarek Vasut <marek.vasut+renesas@mailbox.org>
Wed, 26 Feb 2025 17:26:57 +0000 (18:26 +0100)
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>
board/gdsys/a38x/ihs_phys.c
drivers/net/designware.c
drivers/net/ravb.c
drivers/net/sh_eth.c
include/miiphy.h

index a121898be5207c78d33e0ac3a2cc4a3fd80cea9b..128b1395243a157a5d65eeb9e1ac914a4c9019ce 100644 (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,
index 74cf8271e67b1824cca39fd72cd247d03b3bb84c..5124982e68312b3306e7bb84322307c0fe25a151 100644 (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);
 }
index 0018b694ec1348db4ba054c1f0b819ae668d9174..867871834888dfef92121d987dbd77b65494d3f0 100644 (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;
 }
 
index e78d64d77c38d8082ebe187bb55606cd873017e0..49065ebe717eff755a54309db4704a0599b8f3a5 100644 (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,
index 42300ee5386d7e0c92c9fc8c0a0cd11aa146698b..efeff8ae70b54c878492c370890efcdf60878834 100644 (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);