Commit 58056c1e authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller
Browse files

net: ethernet: Use phy_set_max_speed() to limit advertised speed



Many Ethernet MAC drivers want to limit the PHY to only advertise a
maximum speed of 100Mbs or 1Gbps. Rather than using a mask, make use
of the helper function phy_set_max_speed().

Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 15d8daf7
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -377,9 +377,7 @@ static int ax_mii_probe(struct net_device *dev)
		return ret;
	}

	/* mask with MAC supported features */
	phy_dev->supported &= PHY_BASIC_FEATURES;
	phy_dev->advertising = phy_dev->supported;
	phy_set_max_speed(phy_dev, SPEED_100);

	netdev_info(dev, "PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
		    phy_dev->drv->name, phydev_name(phy_dev), phy_dev->irq);
+2 −2
Original line number Diff line number Diff line
@@ -1279,9 +1279,9 @@ static int greth_mdio_probe(struct net_device *dev)
	}

	if (greth->gbit_mac)
		phy->supported &= PHY_GBIT_FEATURES;
		phy_set_max_speed(phy, SPEED_1000);
	else
		phy->supported &= PHY_BASIC_FEATURES;
		phy_set_max_speed(phy, SPEED_100);

	phy->advertising = phy->supported;

+2 −10
Original line number Diff line number Diff line
@@ -3258,19 +3258,11 @@ static int et131x_mii_probe(struct net_device *netdev)
		return PTR_ERR(phydev);
	}

	phydev->supported &= (SUPPORTED_10baseT_Half |
			      SUPPORTED_10baseT_Full |
			      SUPPORTED_100baseT_Half |
			      SUPPORTED_100baseT_Full |
			      SUPPORTED_Autoneg |
			      SUPPORTED_MII |
			      SUPPORTED_TP);
	phy_set_max_speed(phydev, SPEED_100);

	if (adapter->pdev->device != ET131X_PCI_DEVICE_ID_FAST)
		phydev->supported |= SUPPORTED_1000baseT_Half |
				     SUPPORTED_1000baseT_Full;
		phy_set_max_speed(phydev, SPEED_1000);

	phydev->advertising = phydev->supported;
	phydev->autoneg = AUTONEG_ENABLE;

	phy_attached_info(phydev);
+1 −2
Original line number Diff line number Diff line
@@ -172,8 +172,7 @@ static int emac_mdio_probe(struct net_device *dev)
	}

	/* mask with MAC supported features */
	phydev->supported &= PHY_BASIC_FEATURES;
	phydev->advertising = phydev->supported;
	phy_set_max_speed(phydev, SPEED_100);

	db->link = 0;
	db->speed = 0;
+1 −4
Original line number Diff line number Diff line
@@ -835,13 +835,10 @@ static int init_phy(struct net_device *dev)
	}

	/* Stop Advertising 1000BASE Capability if interface is not GMII
	 * Note: Checkpatch throws CHECKs for the camel case defines below,
	 * it's ok to ignore.
	 */
	if ((priv->phy_iface == PHY_INTERFACE_MODE_MII) ||
	    (priv->phy_iface == PHY_INTERFACE_MODE_RMII))
		phydev->advertising &= ~(SUPPORTED_1000baseT_Half |
					 SUPPORTED_1000baseT_Full);
		phy_set_max_speed(phydev, SPEED_100);

	/* Broken HW is sometimes missing the pull-up resistor on the
	 * MDIO line, which results in reads to non-existent devices returning
Loading