Skip to contentSkip to conversation

phy: Allow a NULL phy name for devm_phy_get()

PATCH Applied Rob Herring 2 participants 2 messages Apr 14, 2021 – May 14, 2021 Generic PHY framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 phy: Allow a NULL phy name for devm_phy_get()

For a single PHY, there's no reason to have a phy-names entry in DT. The DT specific get functions allow for this already, but devm_phy_get() WARNs in this case. Other subsystems also don't warn in their get functions. Let's drop the WARN for DT case in devm_phy_get().

Cc Kishon Vijay Abraham I <[email protected]>
Cc Vinod Koul <[email protected]>

---
Note that I think the device_link_add later on is now redundant with fw_devlinks. If so, this can be simplified to just calling of_phy_get() for DT case.

 drivers/phy/phy-core.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/phy/phy-core.c +9 -7
index 71cb10826326..3e4971253ec1 100644
@@ -667,16 +667,18 @@ struct phy *phy_get(struct device *dev, const char *string)
 	struct phy *phy;
 	struct device_link *link;
 
-	if (string == NULL) {
-		dev_WARN(dev, "missing string\n");
-		return ERR_PTR(-EINVAL);
-	}
-
 	if (dev->of_node) {
-		index = of_property_match_string(dev->of_node, "phy-names",
-			string);
+		if (string)
+			index = of_property_match_string(dev->of_node, "phy-names",
+				string);
+		else
+			index = 0;
 		phy = _of_phy_get(dev->of_node, index);
 	} else {
+		if (string == NULL) {
+			dev_WARN(dev, "missing string\n");
+			return ERR_PTR(-EINVAL);
+		}
 		phy = phy_find(dev, string);
 	}
 	if (IS_ERR(phy))
Signature · 1 line
2.27.0
maintainer Applied
#1 lore raw
Quoted 4 lines · Rob Herring

For a single PHY, there's no reason to have a phy-names entry in DT. The DT specific get functions allow for this already, but devm_phy_get() WARNs in this case. Other subsystems also don't warn in their get functions. Let's drop the WARN for DT case in devm_phy_get().

Applied, thanks

Signature · 1 line
~Vinod