Skip to content

Commit cf4f267

Browse files
Russell Kingdavem330
authored andcommitted
phylink: merge SGMII and 802.3z handling
The code handling SGMII and 802.3z is essentially the same, except that we assume 802.3z has no PHY. Re-organise the code such that these cases are merged, and exclude 802.3z mode from having a PHY attached. This results in the same link handling behaviour as before. Signed-off-by: Russell King <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 365c1e6 commit cf4f267

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/net/phy/phylink.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ static void phylink_resolve(struct work_struct *w)
423423
break;
424424

425425
case MLO_AN_SGMII:
426+
case MLO_AN_8023Z:
426427
phylink_get_mac_state(pl, &link_state);
427428
if (pl->phydev) {
428429
bool changed = false;
@@ -448,10 +449,6 @@ static void phylink_resolve(struct work_struct *w)
448449
}
449450
}
450451
break;
451-
452-
case MLO_AN_8023Z:
453-
phylink_get_mac_state(pl, &link_state);
454-
break;
455452
}
456453
}
457454

@@ -656,6 +653,10 @@ int phylink_connect_phy(struct phylink *pl, struct phy_device *phy)
656653
{
657654
int ret;
658655

656+
if (WARN_ON(pl->link_an_mode == MLO_AN_FIXED ||
657+
pl->link_an_mode == MLO_AN_8023Z))
658+
return -EINVAL;
659+
659660
ret = phy_attach_direct(pl->netdev, phy, 0, pl->link_interface);
660661
if (ret)
661662
return ret;
@@ -674,8 +675,9 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn)
674675
struct phy_device *phy_dev;
675676
int ret;
676677

677-
/* Fixed links are handled without needing a PHY */
678-
if (pl->link_an_mode == MLO_AN_FIXED)
678+
/* Fixed links and 802.3z are handled without needing a PHY */
679+
if (pl->link_an_mode == MLO_AN_FIXED ||
680+
pl->link_an_mode == MLO_AN_8023Z)
679681
return 0;
680682

681683
phy_node = of_parse_phandle(dn, "phy-handle", 0);
@@ -850,13 +852,13 @@ int phylink_ethtool_ksettings_get(struct phylink *pl,
850852
break;
851853

852854
case MLO_AN_SGMII:
855+
case MLO_AN_8023Z:
853856
/* If there is a phy attached, then use the reported
854857
* settings from the phy with no modification.
855858
*/
856859
if (pl->phydev)
857860
break;
858861

859-
case MLO_AN_8023Z:
860862
phylink_get_mac_state(pl, &link_state);
861863

862864
/* The MAC is reporting the link results from its own PCS

0 commit comments

Comments
 (0)