net: miiphybb: Pass struct bb_miiphy_bus_ops directly to bb_miiphy_read/write()

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>
This commit is contained in:
Marek Vasut
2025-03-02 02:24:44 +01:00
parent 3374d3783a
commit c5318bdcf8
6 changed files with 24 additions and 25 deletions

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

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

View 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) */

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

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

View 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 */