Skip to contentSkip to conversation

net: dsa: microchip: Small cleanups for ksz9477 SGMII

PATCH Applied Maxime Chevallier 3 participants 6 messages Mar 24 – Mar 27

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover net: dsa: microchip: Small cleanups for ksz9477 SGMII

Hi,

While working with ksz9477, I've done some very minor cleanups around the PCS code for the SGMII port. No changes intended.

Maxime

Maxime Chevallier (2):
net: dsa: microchip: Drop unnecessary check in ksz9477 PCS setup
net: dsa: microchip: drop an outdated comment about SGMII support

 drivers/net/dsa/microchip/ksz9477.c | 57 ++++++++++++++---------------
 1 file changed, 27 insertions(+), 30 deletions(-)
Signature · 1 line
2.49.0
#1 lore raw

PATCH 1/2 net: dsa: microchip: Drop unnecessary check in ksz9477 PCS setup

The ksz_dev_ops .pcs_create() is called under the assumption that the switch has a PCS port :

  if (ksz_has_sgmii_port(dev) && dev->dev_ops->pcs_create) {
          ret = dev->dev_ops->pcs_create(dev);
	  [...]

}

The KSZ9477 implementation of .pcs_create() does the same check on ksz_has_sgmii_port(), and protects the entire function with it.

Drop it, saving a level of indentation and increasing readability.

---
 drivers/net/dsa/microchip/ksz9477.c | 55 ++++++++++++++---------------
 1 file changed, 26 insertions(+), 29 deletions(-)
drivers/net/dsa/microchip/ksz9477.c +26 -29
index 5416016b33e0..30d8c0146bbb 100644
@@ -310,36 +310,33 @@ static int ksz9477_pcs_write(struct mii_bus *bus, int phy, int mmd, int reg,
 
 int ksz9477_pcs_create(struct ksz_device *dev)
 {
-	/* This chip has a SGMII port. */
-	if (ksz_has_sgmii_port(dev)) {
-		int port = ksz_get_sgmii_port(dev);
-		struct ksz_port *p = &dev->ports[port];
-		struct phylink_pcs *pcs;
-		struct mii_bus *bus;
-		int ret;
-
-		bus = devm_mdiobus_alloc(dev->dev);
-		if (!bus)
-			return -ENOMEM;
-
-		bus->name = "ksz_pcs_mdio_bus";
-		snprintf(bus->id, MII_BUS_ID_SIZE, "%s-pcs",
-			 dev_name(dev->dev));
-		bus->read_c45 = &ksz9477_pcs_read;
-		bus->write_c45 = &ksz9477_pcs_write;
-		bus->parent = dev->dev;
-		bus->phy_mask = ~0;
-		bus->priv = dev;
-
-		ret = devm_mdiobus_register(dev->dev, bus);
-		if (ret)
-			return ret;
+	int port = ksz_get_sgmii_port(dev);
+	struct ksz_port *p = &dev->ports[port];
+	struct phylink_pcs *pcs;
+	struct mii_bus *bus;
+	int ret;
 
-		pcs = xpcs_create_pcs_mdiodev(bus, 0);
-		if (IS_ERR(pcs))
-			return PTR_ERR(pcs);
-		p->pcs = pcs;
-	}
+	bus = devm_mdiobus_alloc(dev->dev);
+	if (!bus)
+		return -ENOMEM;
+
+	bus->name = "ksz_pcs_mdio_bus";
+	snprintf(bus->id, MII_BUS_ID_SIZE, "%s-pcs",
+		 dev_name(dev->dev));
+	bus->read_c45 = &ksz9477_pcs_read;
+	bus->write_c45 = &ksz9477_pcs_write;
+	bus->parent = dev->dev;
+	bus->phy_mask = ~0;
+	bus->priv = dev;
+
+	ret = devm_mdiobus_register(dev->dev, bus);
+	if (ret)
+		return ret;
+
+	pcs = xpcs_create_pcs_mdiodev(bus, 0);
+	if (IS_ERR(pcs))
+		return PTR_ERR(pcs);
+	p->pcs = pcs;
 
 	return 0;
 }
Signature · 1 line
2.49.0
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH net-next 1/2] net: dsa: microchip: Drop unnecessary check in ksz9477 PCS setup

Quoted 8 lines · Maxime Chevallier

The ksz_dev_ops .pcs_create() is called under the assumption that the switch has a PCS port :

  if (ksz_has_sgmii_port(dev) && dev->dev_ops->pcs_create) {
          ret = dev->dev_ops->pcs_create(dev);
	  [...]

}

Quoted 7 lines

The KSZ9477 implementation of .pcs_create() does the same check on ksz_has_sgmii_port(), and protects the entire function with it.

Drop it, saving a level of indentation and increasing readability.

---

#3 lore raw

PATCH 2/2 net: dsa: microchip: drop an outdated comment about SGMII support

In reply to Maxime Chevallier

SGMII support has been added to ksz9477, we can drop the comment saying that it'll be added later.

---
 drivers/net/dsa/microchip/ksz9477.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/microchip/ksz9477.c +1 -1
index 30d8c0146bbb..d3c23dcaea8c 100644
@@ -525,7 +525,7 @@ int ksz9477_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data)
 	 * A fixed PHY can be setup in the device tree, but this function is
 	 * still called for that port during initialization.
 	 * For RGMII PHY there is no way to access it so the fixed PHY should
-	 * be used.  For SGMII PHY the supporting code will be added later.
+	 * be used.
 	 */
 	if (!dev->info->internal_phy[addr]) {
 		struct ksz_port *p = &dev->ports[addr];
Signature · 1 line
2.49.0
#5 lore raw
In reply to Maxime Chevallier
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 8 lines · On Tue, 24 Mar 2026 19:08:23 +0100 you wrote:

Hi,

While working with ksz9477, I've done some very minor cleanups around the PCS code for the SGMII port. No changes intended.

Maxime

[...]

Here is the summary with links:
- [net-next,1/2] net: dsa: microchip: Drop unnecessary check in ksz9477 PCS setup

    https://git.kernel.org/netdev/net-next/c/e1da0e1859c6
  - [net-next,2/2] net: dsa: microchip: drop an outdated comment about SGMII support
    https://git.kernel.org/netdev/net-next/c/588cd4e7d22c

You are awesome, thank you!

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