]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: dsa: microchip: Drop unnecessary check in ksz9477 PCS setup
authorMaxime Chevallier <maxime.chevallier@bootlin.com>
Tue, 24 Mar 2026 18:08:24 +0000 (19:08 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 27 Mar 2026 01:55:19 +0000 (18:55 -0700)
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.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Link: https://patch.msgid.link/20260324180826.524327-2-maxime.chevallier@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/microchip/ksz9477.c

index 5416016b33e0f0024dc2d40573057da2eda1de2e..30d8c0146bbb0e0405d9b0ea64163e2893d7f2fa 100644 (file)
@@ -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;
 }