Skip to content

Commit 20cb18e

Browse files
milindcdnsclaudiubeznea
authored andcommitted
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: 7897b07 ("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>
1 parent 922071b commit 20cb18e

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -611,21 +611,24 @@ static const struct phylink_mac_ops macb_phylink_ops = {
611611
.mac_link_up = macb_mac_link_up,
612612
};
613613

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+
614621
static int macb_phylink_connect(struct macb *bp)
615622
{
623+
struct device_node *dn = bp->pdev->dev.of_node;
616624
struct net_device *dev = bp->dev;
617625
struct phy_device *phydev;
618626
int ret;
619627

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))) {
629632
phydev = phy_find_first(bp->mii_bus);
630633
if (!phydev) {
631634
netdev_err(dev, "no PHY found\n");
@@ -634,10 +637,11 @@ static int macb_phylink_connect(struct macb *bp)
634637

635638
/* attach the mac to the phy */
636639
ret = phylink_connect_phy(bp->phylink, phydev);
637-
if (ret) {
638-
netdev_err(dev, "Could not attach to PHY (%d)\n", ret);
639-
return ret;
640-
}
640+
}
641+
642+
if (ret) {
643+
netdev_err(dev, "Could not attach PHY (%d)\n", ret);
644+
return ret;
641645
}
642646

643647
phylink_start(bp->phylink);

0 commit comments

Comments
 (0)