diff options
Diffstat (limited to 'drivers/net/phy/phylink.c')
| -rw-r--r-- | drivers/net/phy/phylink.c | 78 | 
1 files changed, 31 insertions, 47 deletions
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 3ba5cf2a8a5f..9b8dd0d0ee42 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -68,33 +68,6 @@ struct phylink {  	struct sfp_bus *sfp_bus;  }; -static inline void linkmode_zero(unsigned long *dst) -{ -	bitmap_zero(dst, __ETHTOOL_LINK_MODE_MASK_NBITS); -} - -static inline void linkmode_copy(unsigned long *dst, const unsigned long *src) -{ -	bitmap_copy(dst, src, __ETHTOOL_LINK_MODE_MASK_NBITS); -} - -static inline void linkmode_and(unsigned long *dst, const unsigned long *a, -				const unsigned long *b) -{ -	bitmap_and(dst, a, b, __ETHTOOL_LINK_MODE_MASK_NBITS); -} - -static inline void linkmode_or(unsigned long *dst, const unsigned long *a, -				const unsigned long *b) -{ -	bitmap_or(dst, a, b, __ETHTOOL_LINK_MODE_MASK_NBITS); -} - -static inline bool linkmode_empty(const unsigned long *src) -{ -	return bitmap_empty(src, __ETHTOOL_LINK_MODE_MASK_NBITS); -} -  /**   * phylink_set_port_modes() - set the port type modes in the ethtool mask   * @mask: ethtool link mode mask @@ -717,6 +690,30 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy)  	return 0;  } +static int __phylink_connect_phy(struct phylink *pl, struct phy_device *phy, +		phy_interface_t interface) +{ +	int ret; + +	if (WARN_ON(pl->link_an_mode == MLO_AN_FIXED || +		    (pl->link_an_mode == MLO_AN_INBAND && +		     phy_interface_mode_is_8023z(interface)))) +		return -EINVAL; + +	if (pl->phydev) +		return -EBUSY; + +	ret = phy_attach_direct(pl->netdev, phy, 0, interface); +	if (ret) +		return ret; + +	ret = phylink_bringup_phy(pl, phy); +	if (ret) +		phy_detach(phy); + +	return ret; +} +  /**   * phylink_connect_phy() - connect a PHY to the phylink instance   * @pl: a pointer to a &struct phylink returned from phylink_create() @@ -734,31 +731,13 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy)   */  int phylink_connect_phy(struct phylink *pl, struct phy_device *phy)  { -	int ret; - -	if (WARN_ON(pl->link_an_mode == MLO_AN_FIXED || -		    (pl->link_an_mode == MLO_AN_INBAND && -		     phy_interface_mode_is_8023z(pl->link_interface)))) -		return -EINVAL; - -	if (pl->phydev) -		return -EBUSY; -  	/* Use PHY device/driver interface */  	if (pl->link_interface == PHY_INTERFACE_MODE_NA) {  		pl->link_interface = phy->interface;  		pl->link_config.interface = pl->link_interface;  	} -	ret = phy_attach_direct(pl->netdev, phy, 0, pl->link_interface); -	if (ret) -		return ret; - -	ret = phylink_bringup_phy(pl, phy); -	if (ret) -		phy_detach(phy); - -	return ret; +	return __phylink_connect_phy(pl, phy, pl->link_interface);  }  EXPORT_SYMBOL_GPL(phylink_connect_phy); @@ -901,6 +880,9 @@ void phylink_start(struct phylink *pl)  		    phylink_an_mode_str(pl->link_an_mode),  		    phy_modes(pl->link_config.interface)); +	/* Always set the carrier off */ +	netif_carrier_off(pl->netdev); +  	/* Apply the link configuration to the MAC when starting. This allows  	 * a fixed-link to start with the correct parameters, and also  	 * ensures that we set the appropriate advertisement for Serdes links. @@ -1672,7 +1654,9 @@ static void phylink_sfp_link_up(void *upstream)  static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy)  { -	return phylink_connect_phy(upstream, phy); +	struct phylink *pl = upstream; + +	return __phylink_connect_phy(upstream, phy, pl->link_config.interface);  }  static void phylink_sfp_disconnect_phy(void *upstream)  | 
