Commit fd2a8914 authored by Milind Parab's avatar Milind Parab Committed by Jakub Kicinski

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: 7897b071 ("net: macb: convert to phylink")
Signed-off-by: default avatarMilind Parab <mparab@cadence.com>
Reviewed-by: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c9f53049
...@@ -611,21 +611,24 @@ static const struct phylink_mac_ops macb_phylink_ops = { ...@@ -611,21 +611,24 @@ static const struct phylink_mac_ops macb_phylink_ops = {
.mac_link_up = macb_mac_link_up, .mac_link_up = macb_mac_link_up,
}; };
static bool macb_phy_handle_exists(struct device_node *dn)
{
dn = of_parse_phandle(dn, "phy-handle", 0);
of_node_put(dn);
return dn != NULL;
}
static int macb_phylink_connect(struct macb *bp) static int macb_phylink_connect(struct macb *bp)
{ {
struct device_node *dn = bp->pdev->dev.of_node;
struct net_device *dev = bp->dev; struct net_device *dev = bp->dev;
struct phy_device *phydev; struct phy_device *phydev;
int ret; int ret;
if (bp->pdev->dev.of_node && if (dn)
of_parse_phandle(bp->pdev->dev.of_node, "phy-handle", 0)) { ret = phylink_of_phy_connect(bp->phylink, dn, 0);
ret = phylink_of_phy_connect(bp->phylink, bp->pdev->dev.of_node,
0); if (!dn || (ret && !macb_phy_handle_exists(dn))) {
if (ret) {
netdev_err(dev, "Could not attach PHY (%d)\n", ret);
return ret;
}
} else {
phydev = phy_find_first(bp->mii_bus); phydev = phy_find_first(bp->mii_bus);
if (!phydev) { if (!phydev) {
netdev_err(dev, "no PHY found\n"); netdev_err(dev, "no PHY found\n");
...@@ -634,10 +637,11 @@ static int macb_phylink_connect(struct macb *bp) ...@@ -634,10 +637,11 @@ static int macb_phylink_connect(struct macb *bp)
/* attach the mac to the phy */ /* attach the mac to the phy */
ret = phylink_connect_phy(bp->phylink, phydev); ret = phylink_connect_phy(bp->phylink, phydev);
if (ret) { }
netdev_err(dev, "Could not attach to PHY (%d)\n", ret);
return ret; if (ret) {
} netdev_err(dev, "Could not attach PHY (%d)\n", ret);
return ret;
} }
phylink_start(bp->phylink); phylink_start(bp->phylink);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment