[net-next PATCH v5 07/15] net: mdiobus: Introduce fwnode_mdiobus_register_phy()
Calvin Johnson
calvin.johnson at oss.nxp.com
Tue Feb 9 10:04:33 EST 2021
On Mon, Feb 08, 2021 at 05:40:13PM +0000, Russell King - ARM Linux admin wrote:
> On Mon, Feb 08, 2021 at 08:42:36PM +0530, Calvin Johnson wrote:
> > +int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> > + struct fwnode_handle *child, u32 addr)
> > +{
> > + struct mii_timestamper *mii_ts;
>
> If you initialise this to NULL...
>
> > + struct phy_device *phy;
> > + bool is_c45 = false;
> > + u32 phy_id;
> > + int rc;
> > +
> > + if (is_of_node(child)) {
> > + mii_ts = of_find_mii_timestamper(to_of_node(child));
> > + if (IS_ERR(mii_ts))
> > + return PTR_ERR(mii_ts);
> > + }
> > +
> > + rc = fwnode_property_match_string(child, "compatible", "ethernet-phy-ieee802.3-c45");
> > + if (rc >= 0)
> > + is_c45 = true;
> > +
> > + if (is_c45 || fwnode_get_phy_id(child, &phy_id))
> > + phy = get_phy_device(bus, addr, is_c45);
> > + else
> > + phy = phy_device_create(bus, addr, phy_id, 0, NULL);
> > + if (IS_ERR(phy)) {
> > + if (mii_ts && is_of_node(child))
>
> Then you don't need is_of_node() here.
>
> > + /* phy->mii_ts may already be defined by the PHY driver. A
> > + * mii_timestamper probed via the device tree will still have
> > + * precedence.
> > + */
> > + if (mii_ts)
> > + phy->mii_ts = mii_ts;
>
> Should this be moved out of the if() case?
>
> I'm thinking of the future where we may end up adding mii timestamper
> support for ACPI.
Right. I'll take case of these in next version.
Thanks
Calvin
More information about the linux-arm-kernel
mailing list