Re: [PATCH net-next 12/13] net: dsa: sja1105: expose the SGMII PCS as an mdio_device

Andrew Lunn
2021-05-25T02:33:38Z

> +static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv)
> +{
> + struct sja1105_mdio_private *mdio_priv;
> + struct dsa_switch *ds = priv->ds;
> + struct mii_bus *bus;
> + int rc = 0;
> + int port;
> +
> + if (!priv->info->pcs_mdio_read || !priv->info->pcs_mdio_write)
> + return 0;
> +
> + bus = mdiobus_alloc_size(sizeof(*mdio_priv));
> + if (!bus)
> + return -ENOMEM;
> +
> + bus->name = "SJA1105 PCS MDIO bus";
> + snprintf(bus->id, MII_BUS_ID_SIZE, "%s-pcs",
> + dev_name(ds->dev));
> + bus->read = priv->info->pcs_mdio_read;
> + bus->write = priv->info->pcs_mdio_write;
> + bus->parent = ds->dev;
> + mdio_priv = bus->priv;
> + mdio_priv->priv = priv;
> +
> + /* We don't register this MDIO bus because there is no PHY on it */

Interesting. If you don't register it, you miss out on the stats in
/sysfs. I wonder if it makes more sense to set phy_mask to stop it
probing for PHYs and register it?

Andrew