Re: [RFC net-next PATCH v2 1/2] net/fsl: add ACPI support for mdio bus

Andrew Lunn
2020-04-18T14:39:12Z

> > +static int xgmac_mdiobus_register_phy(struct mii_bus *bus,
> > + struct fwnode_handle *child, u32 addr)
> > +{
> > + struct phy_device *phy;
> > + bool is_c45 = false;
> > + int rc;
> > + const char *cp;
> > + u32 phy_id;
> > +
> > + fwnode_property_read_string(child, "compatible", &cp);
> > + if (!strcmp(cp, "ethernet-phy-ieee802.3-c45"))
> > + is_c45 = true;
> > +
> > + if (!is_c45 && !xgmac_get_phy_id(child, &phy_id))
> > + phy = phy_device_create(bus, addr, phy_id, 0, NULL);
> > + else
> > + phy = get_phy_device(bus, addr, is_c45);
> > + if (IS_ERR(phy))
> > + return PTR_ERR(phy);
> > +
> > + phy->irq = bus->irq[addr];
> > +
> > + /* Associate the fwnode with the device structure so it
> > + * can be looked up later.
> > + */
> > + phy->mdio.dev.fwnode = child;
> > +
> > + /* All data is now stored in the phy struct, so register it */
> > + rc = phy_device_register(phy);
> > + if (rc) {
> > + phy_device_free(phy);
> > + fwnode_handle_put(child);
> > + return rc;
> > + }
> > +
> > + dev_dbg(&bus->dev, "registered phy at address %i\n", addr);
> > +
> > + return 0;
>
> You seem to be duplicating the OF implementation in a private driver,
> converting it to fwnode. This is not how we develop the Linux kernel.
> We fix subsystem problems by fixing the subsystems, not by throwing
> what should be subsystem code into private drivers.

And i think a similar comment was given for v1, but i could be
remembering wrongly.

Andrew