diff options
author | Calvin Johnson <calvin.johnson@oss.nxp.com> | 2021-06-11 13:53:48 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-06-11 13:08:52 -0700 |
commit | 0fb16976765143cf0d7d0dd78b3f406ab135c494 (patch) | |
tree | e0e3029a416177831727ef327e7d9d70ef917820 /drivers/net/phy | |
parent | e71305acd81cac222c41849e538c5c661b12c584 (diff) |
net: phy: Introduce fwnode_mdio_find_device()
Define fwnode_mdio_find_device() to get a pointer to the
mdio_device from fwnode passed to the function.
Refactor of_mdio_find_device() to use fwnode_mdio_find_device().
Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Acked-by: Grant Likely <grant.likely@arm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r-- | drivers/net/phy/phy_device.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 495d86b4af7c..dca454b5c209 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2876,6 +2876,29 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv) } /** + * fwnode_mdio_find_device - Given a fwnode, find the mdio_device + * @fwnode: pointer to the mdio_device's fwnode + * + * If successful, returns a pointer to the mdio_device with the embedded + * struct device refcount incremented by one, or NULL on failure. + * The caller should call put_device() on the mdio_device after its use. + */ +struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode) +{ + struct device *d; + + if (!fwnode) + return NULL; + + d = bus_find_device_by_fwnode(&mdio_bus_type, fwnode); + if (!d) + return NULL; + + return to_mdio_device(d); +} +EXPORT_SYMBOL(fwnode_mdio_find_device); + +/** * phy_probe - probe and init a PHY device * @dev: device to probe and init * |