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

net: macb: fix for fixed-link mode

This patch fix the issue with fixed link. With fixed-link
device opening fails due to macb_phylink_connect not
handling fixed-link mode, in which case no MAC-PHY connection
is needed and phylink_connect return success (0), however
in current driver attempt is made to search and connect to
PHY even for fixed-link.

Fixes: 7897b071ac3b ("net: macb: convert to phylink")
Signed-off-by: Milind Parab <mparab@cadence.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Milind Parab and committed by
Jakub Kicinski
fd2a8914 c9f53049

+17 -13
+17 -13
drivers/net/ethernet/cadence/macb_main.c
··· 611 611 .mac_link_up = macb_mac_link_up, 612 612 }; 613 613 614 + static bool macb_phy_handle_exists(struct device_node *dn) 615 + { 616 + dn = of_parse_phandle(dn, "phy-handle", 0); 617 + of_node_put(dn); 618 + return dn != NULL; 619 + } 620 + 614 621 static int macb_phylink_connect(struct macb *bp) 615 622 { 623 + struct device_node *dn = bp->pdev->dev.of_node; 616 624 struct net_device *dev = bp->dev; 617 625 struct phy_device *phydev; 618 626 int ret; 619 627 620 - if (bp->pdev->dev.of_node && 621 - of_parse_phandle(bp->pdev->dev.of_node, "phy-handle", 0)) { 622 - ret = phylink_of_phy_connect(bp->phylink, bp->pdev->dev.of_node, 623 - 0); 624 - if (ret) { 625 - netdev_err(dev, "Could not attach PHY (%d)\n", ret); 626 - return ret; 627 - } 628 - } else { 628 + if (dn) 629 + ret = phylink_of_phy_connect(bp->phylink, dn, 0); 630 + 631 + if (!dn || (ret && !macb_phy_handle_exists(dn))) { 629 632 phydev = phy_find_first(bp->mii_bus); 630 633 if (!phydev) { 631 634 netdev_err(dev, "no PHY found\n"); ··· 637 634 638 635 /* attach the mac to the phy */ 639 636 ret = phylink_connect_phy(bp->phylink, phydev); 640 - if (ret) { 641 - netdev_err(dev, "Could not attach to PHY (%d)\n", ret); 642 - return ret; 643 - } 637 + } 638 + 639 + if (ret) { 640 + netdev_err(dev, "Could not attach PHY (%d)\n", ret); 641 + return ret; 644 642 } 645 643 646 644 phylink_start(bp->phylink);