net: miiphybb: Pass struct bb_miiphy_bus_ops directly to bb_miiphy_read/write()
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Sun, 2 Mar 2025 01:24:44 +0000 (02:24 +0100)
committerMarek Vasut <marek.vasut+renesas@mailbox.org>
Tue, 11 Mar 2025 22:05:57 +0000 (23:05 +0100)
The access to struct bb_miiphy_bus_ops via ops pointer in
struct bb_miiphy_bus is not necessary with wrappers added
in previous patch. Pass the ops pointer directly to both
bb_miiphy_read() and bb_miiphy_write() functions.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Reviewed-by: Paul Barker <paul.barker.ct@bp.renesas.com>
board/gdsys/a38x/ihs_phys.c
drivers/net/designware.c
drivers/net/phy/miiphybb.c
drivers/net/ravb.c
drivers/net/sh_eth.c
include/miiphy.h

index 304b5b5..6176a47 100644 (file)
@@ -231,13 +231,15 @@ static const struct bb_miiphy_bus_ops mii_bb_miiphy_bus_ops = {
 static int mii_bb_miiphy_read(struct mii_dev *miidev, int addr,
                              int devad, int reg)
 {
-       return bb_miiphy_read(miidev, addr, devad, reg);
+       return bb_miiphy_read(miidev, &mii_bb_miiphy_bus_ops,
+                             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);
+       return bb_miiphy_write(miidev, &mii_bb_miiphy_bus_ops,
+                              addr, devad, reg, value);
 }
 
 int register_miiphy_bus(uint k, struct mii_dev **bus)
@@ -255,7 +257,6 @@ int register_miiphy_bus(uint k, struct mii_dev **bus)
        mdiodev->write = mii_bb_miiphy_write;
 
        /* Copy the bus accessors and private data */
-       bb_miiphy->ops = &mii_bb_miiphy_bus_ops;
        bb_miiphy->priv = &gpio_mii_set[k];
 
        retval = mdio_register(mdiodev);
index 3c3450a..2069e34 100644 (file)
@@ -302,13 +302,15 @@ static const struct bb_miiphy_bus_ops dw_eth_bb_miiphy_bus_ops = {
 static int dw_bb_miiphy_read(struct mii_dev *miidev, int addr,
                             int devad, int reg)
 {
-       return bb_miiphy_read(miidev, addr, devad, reg);
+       return bb_miiphy_read(miidev, &dw_eth_bb_miiphy_bus_ops,
+                             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);
+       return bb_miiphy_write(miidev, &dw_eth_bb_miiphy_bus_ops,
+                              addr, devad, reg, value);
 }
 
 static int dw_bb_mdio_init(const char *name, struct udevice *dev)
@@ -351,7 +353,6 @@ static int dw_bb_mdio_init(const char *name, struct udevice *dev)
 #if CONFIG_IS_ENABLED(DM_GPIO)
        bus->reset = dw_mdio_reset;
 #endif
-       bus->ops = &dw_eth_bb_miiphy_bus_ops;
        bus->priv = dwpriv;
 
        return mdio_register(bus);
index e610634..9481ba7 100644 (file)
@@ -126,21 +126,19 @@ static void miiphy_pre(struct bb_miiphy_bus *bus, const struct bb_miiphy_bus_ops
  * Returns:
  *   0 on success
  */
-int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg)
+int bb_miiphy_read(struct mii_dev *miidev, const struct bb_miiphy_bus_ops *ops,
+                  int addr, int devad, int reg)
 {
        unsigned short rdreg; /* register working value */
        int v;
        int j; /* counter */
        struct bb_miiphy_bus *bus;
-       const struct bb_miiphy_bus_ops *ops;
 
        bus = bb_miiphy_getbus(miidev);
        if (bus == NULL) {
                return -1;
        }
 
-       ops = bus->ops;
-
        miiphy_pre(bus, ops, 1, addr, reg);
 
        /* tri-state our MDIO I/O pin so we can read */
@@ -198,11 +196,10 @@ int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg)
  * Returns:
  *   0 on success
  */
-int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg,
-                   u16 value)
+int bb_miiphy_write(struct mii_dev *miidev, const struct bb_miiphy_bus_ops *ops,
+                   int addr, int devad, int reg, u16 value)
 {
        struct bb_miiphy_bus *bus;
-       const struct bb_miiphy_bus_ops *ops;
        int j;                  /* counter */
 
        bus = bb_miiphy_getbus(miidev);
@@ -211,8 +208,6 @@ int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg,
                return -1;
        }
 
-       ops = bus->ops;
-
        miiphy_pre(bus, ops, 0, addr, reg);
 
        /* send the turnaround (10) */
index 9a17ac9..65ba107 100644 (file)
@@ -561,13 +561,15 @@ static const struct bb_miiphy_bus_ops ravb_bb_miiphy_bus_ops = {
 static int ravb_bb_miiphy_read(struct mii_dev *miidev, int addr,
                               int devad, int reg)
 {
-       return bb_miiphy_read(miidev, addr, devad, reg);
+       return bb_miiphy_read(miidev, &ravb_bb_miiphy_bus_ops,
+                             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);
+       return bb_miiphy_write(miidev, &ravb_bb_miiphy_bus_ops,
+                              addr, devad, reg, value);
 }
 
 static int ravb_probe(struct udevice *dev)
@@ -599,7 +601,6 @@ static int ravb_probe(struct udevice *dev)
        snprintf(mdiodev->name, sizeof(mdiodev->name), dev->name);
 
        /* Copy the bus accessors and private data */
-       bb_miiphy->ops = &ravb_bb_miiphy_bus_ops;
        bb_miiphy->priv = eth;
 
        ret = mdio_register(mdiodev);
index cef531c..738dc43 100644 (file)
@@ -723,13 +723,15 @@ static const struct bb_miiphy_bus_ops sh_ether_bb_miiphy_bus_ops = {
 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);
+       return bb_miiphy_read(miidev, &sh_ether_bb_miiphy_bus_ops,
+                             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);
+       return bb_miiphy_write(miidev, &sh_ether_bb_miiphy_bus_ops,
+                              addr, devad, reg, value);
 }
 
 static int sh_ether_probe(struct udevice *udev)
@@ -761,7 +763,6 @@ static int sh_ether_probe(struct udevice *udev)
        snprintf(mdiodev->name, sizeof(mdiodev->name), udev->name);
 
        /* Copy the bus accessors and private data */
-       bb_miiphy->ops = &sh_ether_bb_miiphy_bus_ops;
        bb_miiphy->priv = eth;
 
        ret = mdio_register(mdiodev);
index 5fd86be..31d81b4 100644 (file)
@@ -75,16 +75,16 @@ struct bb_miiphy_bus_ops {
 
 struct bb_miiphy_bus {
        void *priv;
-       const struct bb_miiphy_bus_ops *ops;
        struct mii_dev mii;
 };
 
 struct bb_miiphy_bus *bb_miiphy_alloc(void);
 void bb_miiphy_free(struct bb_miiphy_bus *bus);
 
-int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg);
-int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg,
-                   u16 value);
+int bb_miiphy_read(struct mii_dev *miidev, const struct bb_miiphy_bus_ops *ops,
+                  int addr, int devad, int reg);
+int bb_miiphy_write(struct mii_dev *miidev, const struct bb_miiphy_bus_ops *ops,
+                   int addr, int devad, int reg, u16 value);
 #endif
 
 /* phy seed setup */