Skip to content

Commit 653a180

Browse files
michaelsit-iotgdavem330
authored andcommitted
net: phylink: add phylink_expects_phy() method
Provide phylink_expects_phy() to allow MAC drivers to check if it is expecting a PHY to attach to. Since fixed-linked setups do not need to attach to a PHY. Provides a boolean value as to if the MAC should expect a PHY. Returns true if a PHY is expected. Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 44d8073 commit 653a180

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

drivers/net/phy/phylink.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,25 @@ void phylink_destroy(struct phylink *pl)
15861586
}
15871587
EXPORT_SYMBOL_GPL(phylink_destroy);
15881588

1589+
/**
1590+
* phylink_expects_phy() - Determine if phylink expects a phy to be attached
1591+
* @pl: a pointer to a &struct phylink returned from phylink_create()
1592+
*
1593+
* When using fixed-link mode, or in-band mode with 1000base-X or 2500base-X,
1594+
* no PHY is needed.
1595+
*
1596+
* Returns true if phylink will be expecting a PHY.
1597+
*/
1598+
bool phylink_expects_phy(struct phylink *pl)
1599+
{
1600+
if (pl->cfg_link_an_mode == MLO_AN_FIXED ||
1601+
(pl->cfg_link_an_mode == MLO_AN_INBAND &&
1602+
phy_interface_mode_is_8023z(pl->link_config.interface)))
1603+
return false;
1604+
return true;
1605+
}
1606+
EXPORT_SYMBOL_GPL(phylink_expects_phy);
1607+
15891608
static void phylink_phy_change(struct phy_device *phydev, bool up)
15901609
{
15911610
struct phylink *pl = phydev->phylink;

include/linux/phylink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *,
574574
phy_interface_t iface,
575575
const struct phylink_mac_ops *mac_ops);
576576
void phylink_destroy(struct phylink *);
577+
bool phylink_expects_phy(struct phylink *pl);
577578

578579
int phylink_connect_phy(struct phylink *, struct phy_device *);
579580
int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags);

0 commit comments

Comments
 (0)