Skip to content

Commit e6625db

Browse files
zijun-huvinodkoul
authored andcommitted
phy: core: Simplify API of_phy_simple_xlate() implementation
Simplify of_phy_simple_xlate() implementation by API class_find_device_by_of_node(). Also correct comments to mark its parameter @dev as unused instead of @Args in passing. Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com> Cc: Simon Horman <horms@kernel.org> Link: https://lore.kernel.org/r/20241213-phy_core_fix-v6-6-40ae28f5015a@quicinc.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent b609675 commit e6625db

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

drivers/phy/phy-core.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,8 @@ EXPORT_SYMBOL_GPL(devm_phy_put);
744744

745745
/**
746746
* of_phy_simple_xlate() - returns the phy instance from phy provider
747-
* @dev: the PHY provider device
748-
* @args: of_phandle_args (not used here)
747+
* @dev: the PHY provider device (not used here)
748+
* @args: of_phandle_args
749749
*
750750
* Intended to be used by phy provider for the common case where #phy-cells is
751751
* 0. For other cases where #phy-cells is greater than '0', the phy provider
@@ -755,21 +755,14 @@ EXPORT_SYMBOL_GPL(devm_phy_put);
755755
struct phy *of_phy_simple_xlate(struct device *dev,
756756
const struct of_phandle_args *args)
757757
{
758-
struct phy *phy;
759-
struct class_dev_iter iter;
760-
761-
class_dev_iter_init(&iter, &phy_class, NULL, NULL);
762-
while ((dev = class_dev_iter_next(&iter))) {
763-
phy = to_phy(dev);
764-
if (args->np != phy->dev.of_node)
765-
continue;
758+
struct device *target_dev;
766759

767-
class_dev_iter_exit(&iter);
768-
return phy;
769-
}
760+
target_dev = class_find_device_by_of_node(&phy_class, args->np);
761+
if (!target_dev)
762+
return ERR_PTR(-ENODEV);
770763

771-
class_dev_iter_exit(&iter);
772-
return ERR_PTR(-ENODEV);
764+
put_device(target_dev);
765+
return to_phy(target_dev);
773766
}
774767
EXPORT_SYMBOL_GPL(of_phy_simple_xlate);
775768

0 commit comments

Comments
 (0)