diff options
author | Jakub Kicinski <kuba@kernel.org> | 2022-11-09 19:28:52 -0800 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-11-09 19:28:53 -0800 |
commit | e29edc475f65ec439c468c85d3c81fac1d19ab61 (patch) | |
tree | 2060d46e9cd37aa97ea8274c82c4128a21cf244b | |
parent | 21780f89d65837e23fef825c79aa836c1cb3a8e9 (diff) | |
parent | 85a2b4ac34449ed5610301e05dab0f7f9efe278b (diff) |
Merge branch 'clean-up-pcs-xpcs-accessors'
Russell King says:
====================
Clean up pcs-xpcs accessors
This series cleans up the pcs-xpcs code to use mdiodev accessors for
read/write just like xpcs_modify_changed() does. In order to do this,
we need to introduce the mdiodev clause 45 accessors.
====================
Link: https://lore.kernel.org/r/Y2pm13+SDg6N/IVx@shell.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r-- | drivers/net/pcs/pcs-xpcs.c | 10 | ||||
-rw-r--r-- | include/linux/mdio.h | 13 |
2 files changed, 15 insertions, 8 deletions
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 70f88eae2a9e..f6a038a1d51e 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -188,18 +188,12 @@ static bool __xpcs_linkmode_supported(const struct xpcs_compat *compat, int xpcs_read(struct dw_xpcs *xpcs, int dev, u32 reg) { - struct mii_bus *bus = xpcs->mdiodev->bus; - int addr = xpcs->mdiodev->addr; - - return mdiobus_c45_read(bus, addr, dev, reg); + return mdiodev_c45_read(xpcs->mdiodev, dev, reg); } int xpcs_write(struct dw_xpcs *xpcs, int dev, u32 reg, u16 val) { - struct mii_bus *bus = xpcs->mdiodev->bus; - int addr = xpcs->mdiodev->addr; - - return mdiobus_c45_write(bus, addr, dev, reg, val); + return mdiodev_c45_write(xpcs->mdiodev, dev, reg, val); } static int xpcs_modify_changed(struct dw_xpcs *xpcs, int dev, u32 reg, diff --git a/include/linux/mdio.h b/include/linux/mdio.h index 00177567cfef..f7fbbf3069e7 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -488,6 +488,19 @@ static inline int mdiobus_c45_write(struct mii_bus *bus, int prtad, int devad, return mdiobus_write(bus, prtad, mdiobus_c45_addr(devad, regnum), val); } +static inline int mdiodev_c45_read(struct mdio_device *mdiodev, int devad, + u16 regnum) +{ + return mdiobus_c45_read(mdiodev->bus, mdiodev->addr, devad, regnum); +} + +static inline int mdiodev_c45_write(struct mdio_device *mdiodev, u32 devad, + u16 regnum, u16 val) +{ + return mdiobus_c45_write(mdiodev->bus, mdiodev->addr, devad, regnum, + val); +} + int mdiobus_register_device(struct mdio_device *mdiodev); int mdiobus_unregister_device(struct mdio_device *mdiodev); bool mdiobus_is_registered_device(struct mii_bus *bus, int addr); |