From c4d7a0118e2b58eccc93267525105e368cb4e8f6 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Thu, 20 Feb 2020 11:01:09 +0100 Subject: phy: introduce phy_get_by_index The upstream (v5.6-rc1) device tree node of the stm32mp157c-dk2's OHCI has a phys property, but not phy-names. We have no API to reference such a phy easily (passing NULL isn't allowed). Add one. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- drivers/phy/phy-core.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'drivers') diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index ad1e814788..ff6e35d160 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -371,3 +371,17 @@ struct phy *phy_optional_get(struct device_d *dev, const char *string) 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); +} -- cgit v1.2.3