Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Rob Herring and committed by
Vinod Koul
8a917813 520264db

+9 -7
+9 -7
drivers/phy/phy-core.c
··· 697 697 struct phy *phy; 698 698 struct device_link *link; 699 699 700 - if (string == NULL) { 701 - dev_WARN(dev, "missing string\n"); 702 - return ERR_PTR(-EINVAL); 703 - } 704 - 705 700 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; 708 706 phy = _of_phy_get(dev->of_node, index); 709 707 } else { 708 + if (string == NULL) { 709 + dev_WARN(dev, "missing string\n"); 710 + return ERR_PTR(-EINVAL); 711 + } 710 712 phy = phy_find(dev, string); 711 713 } 712 714 if (IS_ERR(phy))