Skip to contentSkip to conversation

Clean up pcs-xpcs accessors

PATCH Applied Russell King (Oracle) 4 participants 6 messages Nov 8, 2022 – Nov 10, 2022

Subsystems (4)
lore
Share & tools
lore

Russell King (Oracle)

author reviewer
#0 lore raw

cover Clean up pcs-xpcs accessors

Hi,

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.

 drivers/net/pcs/pcs-xpcs.c | 10 ++--------
 include/linux/mdio.h       | 13 +++++++++++++
 2 files changed, 15 insertions(+), 8 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#1 lore raw

PATCH 1/2 net: mdio: add mdiodev_c45_(read|write)

---
 include/linux/mdio.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
include/linux/mdio.h +13 -0
index 00177567cfef..f7fbbf3069e7 100644
@@ -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);
Signature · 1 line
2.30.2
#3 lore raw

PATCH 2/2 net: pcs: xpcs: use mdiodev accessors

In reply to Russell King (Oracle)

Use mdiodev accessors rather than accessing the bus and address in the mdio_device structure and using the mdiobus accessors.

---
 drivers/net/pcs/pcs-xpcs.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/net/pcs/pcs-xpcs.c +2 -8
index 70f88eae2a9e..f6a038a1d51e 100644
@@ -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,
Signature · 1 line
2.30.2
#5 lore raw
In reply to Russell King (Oracle)
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Tue, 8 Nov 2022 14:25:27 +0000 you wrote:

Hi,

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.

 drivers/net/pcs/pcs-xpcs.c | 10 ++--------
 include/linux/mdio.h       | 13 +++++++++++++
 2 files changed, 15 insertions(+), 8 deletions(-)

Here is the summary with links:
- [net-next,1/2] net: mdio: add mdiodev_c45_(read|write)

    https://git.kernel.org/netdev/net-next/c/f6479ea4e599
  - [net-next,2/2] net: pcs: xpcs: use mdiodev accessors
    https://git.kernel.org/netdev/net-next/c/85a2b4ac3444

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html