diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index ad1e814..ff6e35d 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -371,3 +371,17 @@ return phy; } +/** + * phy_get_by_index() - lookup and obtain a reference to a phy by index. + * @dev: device with node that references this phy + * @index: index of the phy + * + * Gets the phy using _of_phy_get() + */ +struct phy *phy_get_by_index(struct device_d *dev, int index) +{ + if (!dev->device_node) + return ERR_PTR(-ENODEV); + + return _of_phy_get(dev->device_node, index); +} diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index df480d4..8a28b8e 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -149,6 +149,7 @@ struct of_phandle_args *args)); void of_phy_provider_unregister(struct phy_provider *phy_provider); struct usb_phy *phy_to_usbphy(struct phy *phy); +struct phy *phy_get_by_index(struct device_d *dev, int index); #else static inline int phy_init(struct phy *phy) { @@ -247,6 +248,11 @@ return NULL; } +static struct phy *phy_get_by_index(struct device_d *dev, int index) +{ + return ERR_PTR(-ENODEV); +} + #endif #endif /* __DRIVERS_PHY_H */