lkml.org 
[lkml]   [2020]   [Jul]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [net-next PATCH v2 1/3] net: phy: introduce find_phy_device()
On Wed, Jul 1, 2020 at 9:13 AM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
>
> The PHYs on a 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 find_phy_device() to get the PHY connected to the MAC.

...

> + struct platform_device *pdev;

This...

> + fwnode_mdio = fwnode_find_reference(fwnode, "mdio-handle", 0);
> + dev = bus_find_device_by_fwnode(&platform_bus_type, fwnode_mdio);

> + if (IS_ERR_OR_NULL(dev))

IS_ERR()?!

> + return NULL;

> + pdev = to_platform_device(dev);
> + mdio = platform_get_drvdata(pdev);

...and this can be simple:

mdio = dev_get_drvdata(dev);

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

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2020-07-01 12:24    [W:0.096 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site