]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: ftgmac100: refactor getting phy device handle
authorJacky Chou <jacky_chou@aspeedtech.com>
Tue, 22 Oct 2024 08:42:14 +0000 (16:42 +0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 29 Oct 2024 22:41:16 +0000 (15:41 -0700)
Consolidate the handling of dedicated PHY and fixed-link phy by taking
advantage of logic in of_phy_get_and_connect() which handles both of
these cases, rather than open coding the same logic in ftgmac100_probe().

Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20241022084214.1261174-1-jacky_chou@aspeedtech.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/faraday/ftgmac100.c

index 10c1a2f1100057ffa744bbb81743e50222fd9169..17ec35e75a65632da0255780bd5e456effeb076f 100644 (file)
@@ -1918,35 +1918,17 @@ static int ftgmac100_probe(struct platform_device *pdev)
                        dev_err(&pdev->dev, "Connecting PHY failed\n");
                        goto err_phy_connect;
                }
-       } else if (np && of_phy_is_fixed_link(np)) {
-               struct phy_device *phy;
-
-               err = of_phy_register_fixed_link(np);
-               if (err) {
-                       dev_err(&pdev->dev, "Failed to register fixed PHY\n");
-                       goto err_phy_connect;
-               }
-
-               phy = of_phy_get_and_connect(priv->netdev, np,
-                                            &ftgmac100_adjust_link);
-               if (!phy) {
-                       dev_err(&pdev->dev, "Failed to connect to fixed PHY\n");
-                       of_phy_deregister_fixed_link(np);
-                       err = -EINVAL;
-                       goto err_phy_connect;
-               }
-
-               /* Display what we found */
-               phy_attached_info(phy);
-       } else if (np && of_get_property(np, "phy-handle", NULL)) {
+       } else if (np && (of_phy_is_fixed_link(np) ||
+                         of_get_property(np, "phy-handle", NULL))) {
                struct phy_device *phy;
 
                /* Support "mdio"/"phy" child nodes for ast2400/2500 with
                 * an embedded MDIO controller. Automatically scan the DTS for
                 * available PHYs and register them.
                 */
-               if (of_device_is_compatible(np, "aspeed,ast2400-mac") ||
-                   of_device_is_compatible(np, "aspeed,ast2500-mac")) {
+               if (of_get_property(np, "phy-handle", NULL) &&
+                   (of_device_is_compatible(np, "aspeed,ast2400-mac") ||
+                    of_device_is_compatible(np, "aspeed,ast2500-mac"))) {
                        err = ftgmac100_setup_mdio(netdev);
                        if (err)
                                goto err_setup_mdio;