Skip to content

Commit 8a91781

Browse files
robherringvinodkoul
authored andcommitted
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 <kishon@ti.com> Cc: Vinod Koul <vkoul@kernel.org> Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20210414135525.3535787-1-robh@kernel.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 520264d commit 8a91781

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

drivers/phy/phy-core.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,16 +697,18 @@ struct phy *phy_get(struct device *dev, const char *string)
697697
struct phy *phy;
698698
struct device_link *link;
699699

700-
if (string == NULL) {
701-
dev_WARN(dev, "missing string\n");
702-
return ERR_PTR(-EINVAL);
703-
}
704-
705700
if (dev->of_node) {
706-
index = of_property_match_string(dev->of_node, "phy-names",
707-
string);
701+
if (string)
702+
index = of_property_match_string(dev->of_node, "phy-names",
703+
string);
704+
else
705+
index = 0;
708706
phy = _of_phy_get(dev->of_node, index);
709707
} else {
708+
if (string == NULL) {
709+
dev_WARN(dev, "missing string\n");
710+
return ERR_PTR(-EINVAL);
711+
}
710712
phy = phy_find(dev, string);
711713
}
712714
if (IS_ERR(phy))

0 commit comments

Comments
 (0)