Re: [net-next PATCH v4 4/6] net: phy: introduce phy_find_by_fwnode()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 9, 2020 at 8:57 PM Calvin Johnson
<calvin.johnson@xxxxxxxxxxx> wrote:
>
> The PHYs on an mdiobus are probed and registered using mdiobus_register().
> Later, for connecting these PHYs to MAC, the PHYs registered on the
> mdiobus have to be referenced.
>
> For each MAC node, a property "mdio-handle" is used to reference the
> MDIO bus on which the PHYs are registered. On getting hold of the MDIO
> bus, use phy_find_by_fwnode() to get the PHY connected to the MAC.
>
> Introduce fwnode_mdio_find_bus() to find the mii_bus that corresponds
> to given mii_bus fwnode.

...

> +struct phy_device *phy_find_by_fwnode(struct fwnode_handle *fwnode)
> +{
> +       struct fwnode_handle *fwnode_mdio;
> +       struct mii_bus *mdio;
> +       int addr;
> +       int err;
> +
> +       fwnode_mdio = fwnode_find_reference(fwnode, "mdio-handle", 0);
> +       mdio = fwnode_mdio_find_bus(fwnode_mdio);
> +       fwnode_handle_put(fwnode_mdio);
> +       if (!mdio)
> +               return ERR_PTR(-ENODEV);

> +       err = fwnode_property_read_u32(fwnode, "phy-channel", &addr);
> +       if (err < 0 || addr < 0 || addr >= PHY_MAX_ADDR)
> +               return ERR_PTR(-EINVAL);

I'm wondering why this is written like above and not like below

err = ...
if (err)
  return ERR_PTR(err);
if (...)
 return ERR_PTR(-E...);

?

> +       return mdiobus_get_phy(mdio, addr);
> +}

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux