|
@@ -775,7 +775,7 @@ static void stmmac_adjust_link(struct net_device *dev)
|
|
|
struct stmmac_priv *priv = netdev_priv(dev);
|
|
|
struct phy_device *phydev = dev->phydev;
|
|
|
unsigned long flags;
|
|
|
- int new_state = 0;
|
|
|
+ bool new_state = false;
|
|
|
|
|
|
if (!phydev)
|
|
|
return;
|
|
@@ -788,8 +788,8 @@ static void stmmac_adjust_link(struct net_device *dev)
|
|
|
/* Now we make sure that we can be in full duplex mode.
|
|
|
* If not, we operate in half-duplex mode. */
|
|
|
if (phydev->duplex != priv->oldduplex) {
|
|
|
- new_state = 1;
|
|
|
- if (!(phydev->duplex))
|
|
|
+ new_state = true;
|
|
|
+ if (!phydev->duplex)
|
|
|
ctrl &= ~priv->hw->link.duplex;
|
|
|
else
|
|
|
ctrl |= priv->hw->link.duplex;
|
|
@@ -800,30 +800,17 @@ static void stmmac_adjust_link(struct net_device *dev)
|
|
|
stmmac_mac_flow_ctrl(priv, phydev->duplex);
|
|
|
|
|
|
if (phydev->speed != priv->speed) {
|
|
|
- new_state = 1;
|
|
|
+ new_state = true;
|
|
|
+ ctrl &= ~priv->hw->link.speed_mask;
|
|
|
switch (phydev->speed) {
|
|
|
- case 1000:
|
|
|
- if (priv->plat->has_gmac ||
|
|
|
- priv->plat->has_gmac4)
|
|
|
- ctrl &= ~priv->hw->link.port;
|
|
|
+ case SPEED_1000:
|
|
|
+ ctrl |= priv->hw->link.speed1000;
|
|
|
break;
|
|
|
- case 100:
|
|
|
- if (priv->plat->has_gmac ||
|
|
|
- priv->plat->has_gmac4) {
|
|
|
- ctrl |= priv->hw->link.port;
|
|
|
- ctrl |= priv->hw->link.speed;
|
|
|
- } else {
|
|
|
- ctrl &= ~priv->hw->link.port;
|
|
|
- }
|
|
|
+ case SPEED_100:
|
|
|
+ ctrl |= priv->hw->link.speed100;
|
|
|
break;
|
|
|
- case 10:
|
|
|
- if (priv->plat->has_gmac ||
|
|
|
- priv->plat->has_gmac4) {
|
|
|
- ctrl |= priv->hw->link.port;
|
|
|
- ctrl &= ~(priv->hw->link.speed);
|
|
|
- } else {
|
|
|
- ctrl &= ~priv->hw->link.port;
|
|
|
- }
|
|
|
+ case SPEED_10:
|
|
|
+ ctrl |= priv->hw->link.speed10;
|
|
|
break;
|
|
|
default:
|
|
|
netif_warn(priv, link, priv->dev,
|
|
@@ -839,12 +826,12 @@ static void stmmac_adjust_link(struct net_device *dev)
|
|
|
writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
|
|
|
|
|
|
if (!priv->oldlink) {
|
|
|
- new_state = 1;
|
|
|
- priv->oldlink = 1;
|
|
|
+ new_state = true;
|
|
|
+ priv->oldlink = true;
|
|
|
}
|
|
|
} else if (priv->oldlink) {
|
|
|
- new_state = 1;
|
|
|
- priv->oldlink = 0;
|
|
|
+ new_state = true;
|
|
|
+ priv->oldlink = false;
|
|
|
priv->speed = SPEED_UNKNOWN;
|
|
|
priv->oldduplex = DUPLEX_UNKNOWN;
|
|
|
}
|
|
@@ -907,7 +894,7 @@ static int stmmac_init_phy(struct net_device *dev)
|
|
|
char bus_id[MII_BUS_ID_SIZE];
|
|
|
int interface = priv->plat->interface;
|
|
|
int max_speed = priv->plat->max_speed;
|
|
|
- priv->oldlink = 0;
|
|
|
+ priv->oldlink = false;
|
|
|
priv->speed = SPEED_UNKNOWN;
|
|
|
priv->oldduplex = DUPLEX_UNKNOWN;
|
|
|
|
|
@@ -4291,7 +4278,7 @@ int stmmac_suspend(struct device *dev)
|
|
|
}
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
|
|
- priv->oldlink = 0;
|
|
|
+ priv->oldlink = false;
|
|
|
priv->speed = SPEED_UNKNOWN;
|
|
|
priv->oldduplex = DUPLEX_UNKNOWN;
|
|
|
return 0;
|