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

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Zijun Hu and committed by
Vinod Koul
e6625db6 b6096751

+8 -15
+8 -15
drivers/phy/phy-core.c
··· 744 744 745 745 /** 746 746 * 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 749 749 * 750 750 * Intended to be used by phy provider for the common case where #phy-cells is 751 751 * 0. For other cases where #phy-cells is greater than '0', the phy provider ··· 755 755 struct phy *of_phy_simple_xlate(struct device *dev, 756 756 const struct of_phandle_args *args) 757 757 { 758 - struct phy *phy; 759 - struct class_dev_iter iter; 758 + struct device *target_dev; 760 759 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; 760 + target_dev = class_find_device_by_of_node(&phy_class, args->np); 761 + if (!target_dev) 762 + return ERR_PTR(-ENODEV); 766 763 767 - class_dev_iter_exit(&iter); 768 - return phy; 769 - } 770 - 771 - class_dev_iter_exit(&iter); 772 - return ERR_PTR(-ENODEV); 764 + put_device(target_dev); 765 + return to_phy(target_dev); 773 766 } 774 767 EXPORT_SYMBOL_GPL(of_phy_simple_xlate); 775 768