diff options
author | Marek BehĂșn <marek.behun@nic.cz> | 2022-04-07 00:32:59 +0200 |
---|---|---|
committer | Ramon Fried <ramon@neureality.ai> | 2022-04-10 08:44:12 +0300 |
commit | 1776a24bbbb9afe9cc2a52990c1cee8c48faa20f (patch) | |
tree | f9308bc83907055235ab4bdbbf8c9709cf88dde7 /net | |
parent | 351bfa6ebdcc454441b32976e895002a5b0523b5 (diff) | |
download | u-boot-1776a24bbbb9afe9cc2a52990c1cee8c48faa20f.tar.gz |
treewide: use dm_mdio_read/write/reset() wrappers
Use the new dm_mdio_read/write/reset() wrappers treewide, instead of
always getting and dereferencing MDIO operations structure pointer.
Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/mdio-mux-uclass.c | 16 | ||||
-rw-r--r-- | net/mdio-uclass.c | 19 |
2 files changed, 8 insertions, 27 deletions
diff --git a/net/mdio-mux-uclass.c b/net/mdio-mux-uclass.c index 780526c19e3..94b90e06576 100644 --- a/net/mdio-mux-uclass.c +++ b/net/mdio-mux-uclass.c @@ -54,11 +54,6 @@ static struct udevice *mmux_get_parent_mdio(struct udevice *mux) return pdata->mdio_parent; } -static struct mdio_ops *mmux_get_mdio_parent_ops(struct udevice *mux) -{ - return mdio_get_ops(mmux_get_parent_mdio(mux)); -} - /* call driver select function before performing MDIO r/w */ static int mmux_change_sel(struct udevice *ch, bool sel) { @@ -90,14 +85,13 @@ static int mmux_read(struct udevice *ch, int addr, int devad, { struct udevice *mux = ch->parent; struct udevice *parent_mdio = mmux_get_parent_mdio(mux); - struct mdio_ops *parent_ops = mmux_get_mdio_parent_ops(mux); int err; err = mmux_change_sel(ch, true); if (err) return err; - err = parent_ops->read(parent_mdio, addr, devad, reg); + err = dm_mdio_read(parent_mdio, addr, devad, reg); mmux_change_sel(ch, false); return err; @@ -109,14 +103,13 @@ static int mmux_write(struct udevice *ch, int addr, int devad, { struct udevice *mux = ch->parent; struct udevice *parent_mdio = mmux_get_parent_mdio(mux); - struct mdio_ops *parent_ops = mmux_get_mdio_parent_ops(mux); int err; err = mmux_change_sel(ch, true); if (err) return err; - err = parent_ops->write(parent_mdio, addr, devad, reg, val); + err = dm_mdio_write(parent_mdio, addr, devad, reg, val); mmux_change_sel(ch, false); return err; @@ -127,18 +120,17 @@ static int mmux_reset(struct udevice *ch) { struct udevice *mux = ch->parent; struct udevice *parent_mdio = mmux_get_parent_mdio(mux); - struct mdio_ops *parent_ops = mmux_get_mdio_parent_ops(mux); int err; /* reset is optional, if it's not implemented just exit */ - if (!parent_ops->reset) + if (!mdio_get_ops(parent_mdio)->reset) return 0; err = mmux_change_sel(ch, true); if (err) return err; - err = parent_ops->reset(parent_mdio); + err = dm_mdio_reset(parent_mdio); mmux_change_sel(ch, false); return err; diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c index 887c2281674..bef8280e210 100644 --- a/net/mdio-uclass.c +++ b/net/mdio-uclass.c @@ -95,27 +95,18 @@ int dm_mdio_reset(struct udevice *mdio_dev) */ static int mdio_read(struct mii_dev *mii_bus, int addr, int devad, int reg) { - struct udevice *dev = mii_bus->priv; - - return mdio_get_ops(dev)->read(dev, addr, devad, reg); + return dm_mdio_read(mii_bus->priv, addr, devad, reg); } static int mdio_write(struct mii_dev *mii_bus, int addr, int devad, int reg, u16 val) { - struct udevice *dev = mii_bus->priv; - - return mdio_get_ops(dev)->write(dev, addr, devad, reg, val); + return dm_mdio_write(mii_bus->priv, addr, devad, reg, val); } static int mdio_reset(struct mii_dev *mii_bus) { - struct udevice *dev = mii_bus->priv; - - if (mdio_get_ops(dev)->reset) - return mdio_get_ops(dev)->reset(dev); - else - return 0; + return dm_mdio_reset(mii_bus->priv); } static int dm_mdio_post_probe(struct udevice *dev) @@ -135,10 +126,8 @@ static int dm_mdio_post_probe(struct udevice *dev) static int dm_mdio_pre_remove(struct udevice *dev) { struct mdio_perdev_priv *pdata = dev_get_uclass_priv(dev); - struct mdio_ops *ops = mdio_get_ops(dev); - if (ops->reset) - ops->reset(dev); + dm_mdio_reset(dev); mdio_unregister(pdata->mii_bus); mdio_free(pdata->mii_bus); |