Re: [PATCH net-next v3 6/6] net: dsa: microchip: parse PHY config from device tree
From: Oleksij Rempel
Date: Tue Nov 05 2024 - 09:32:42 EST
Hi Maxime,
On Tue, Nov 05, 2024 at 03:28:05PM +0100, Maxime Chevallier wrote:
> > + dsa_switch_for_each_user_port(dp, dev->ds) {
> > + if (!dev->info->internal_phy[dp->index])
> > + continue;
> > +
> > + phy_node = of_parse_phandle(dp->dn, "phy-handle", 0);
> > + if (!phy_node) {
> > + dev_err(dev->dev, "failed to parse phy-handle for port %d.\n",
> > + dp->index);
> > + phys_are_valid = false;
> > + continue;
> > + }
> > +
> > + phy_parent_node = of_get_parent(phy_node);
> > + if (!phy_parent_node) {
> > + dev_err(dev->dev, "failed to get PHY-parent node for port %d\n",
> > + dp->index);
> > + phys_are_valid = false;
> > + } else if (dev->info->internal_phy[dp->index] &&
> > + phy_parent_node != mdio_np) {
>
> There's a check a few lines above that guarantees that at this point
> dev->info->internal_phy[dp->index] will always evaluate as true,
> so you could simplify that condition a bit :)
good point :)
> > + dev_err(dev->dev, "PHY-parent node mismatch for port %d, expected %pOF, got %pOF\n",
> > + dp->index, mdio_np, phy_parent_node);
> > + phys_are_valid = false;
> > + } else {
> > + ret = of_property_read_u32(phy_node, "reg", &phy_id);
> > + if (ret < 0) {
> > + dev_err(dev->dev, "failed to read PHY ID for port %d. Error %d\n",
> > + dp->index, ret);
> > + phys_are_valid = false;
> > + } else if (phy_id != dev->phy_addr_map[dp->index]) {
> > + dev_err(dev->dev, "PHY ID mismatch for port %d, expected 0x%x, got 0x%x\n",
> > + dp->index, dev->phy_addr_map[dp->index],
> > + phy_id);
>
> In this context, PHY ID might be a bit misleading, as PHY ID usually
> refers to the identifier (OUI + model id used at probe to select the
> driver). May I suggest phy_addr instead ?
ack, will rework it.
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |