From: Viorel Suman <redacted>
Before 7beecaf7d507b ("net: phy: at803x: improve the WOL feature") patch
"at803x_get_wol" implementation used AT803X_INTR_ENABLE_WOL value to set
WAKE_MAGIC flag, and now AT803X_WOL_EN value is used for the same purpose.
The problem here is that the value of these two bits is different after
hardware reset: AT803X_INTR_ENABLE_WOL=0 after hardware reset, but
AT803X_WOL_EN=1. So now, if called right after boot, "at803x_get_wol" will
set WAKE_MAGIC flag, even if WOL function is not enabled via
"at803x_set_wol" call. The patch disables WOL function on probe using
"at803x_set_wol" call thus the behavior is consistent.
Fixes: 7beecaf7d507b ("net: phy: at803x: improve the WOL feature")
Signed-off-by: Viorel Suman <redacted>
---
drivers/net/phy/at803x.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
@@ -443,10 +443,10 @@ static int at803x_set_wol(struct phy_device *phydev,AT803X_LOC_MAC_ADDR_0_15_OFFSET,};-if(!ndev)-return-ENODEV;-if(wol->wolopts&WAKE_MAGIC){+if(!ndev)+return-ENODEV;+mac=(constu8*)ndev->dev_addr;if(!is_valid_ether_addr(mac))
@@ -857,6 +857,9 @@ static int at803x_probe(struct phy_device *phydev)if(phydev->drv->phy_id==ATH8031_PHY_ID){intccr=phy_read(phydev,AT803X_REG_CHIP_CONFIG);intmode_cfg;+structethtool_wolinfowol={+.wolopts=0,+};if(ccr<0)gotoerr;
@@ -872,6 +875,13 @@ static int at803x_probe(struct phy_device *phydev)priv->is_fiber=true;break;}++/* Disable WOL by default */+ret=at803x_set_wol(phydev,&wol);+if(ret<0){+phydev_err(phydev,"failed to disable WOL on probe: %d\n",ret);+returnret;+}}return0;
@@ -443,10 +443,10 @@ static int at803x_set_wol(struct phy_device *phydev,AT803X_LOC_MAC_ADDR_0_15_OFFSET,};-if(!ndev)-return-ENODEV;-if(wol->wolopts&WAKE_MAGIC){+if(!ndev)+return-ENODEV;
Please move the ndev variable into the scope.
It'll make it clear that it can't be used elsewhere
in this function.
quoted hunk
mac = (const u8 *) ndev->dev_addr;
if (!is_valid_ether_addr(mac))
@@ -857,6 +857,9 @@ static int at803x_probe(struct phy_device *phydev) if (phydev->drv->phy_id == ATH8031_PHY_ID) { int ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG); int mode_cfg;+ struct ethtool_wolinfo wol = {+ .wolopts = 0,+ }; if (ccr < 0) goto err;
@@ -872,6 +875,13 @@ static int at803x_probe(struct phy_device *phydev) priv->is_fiber = true; break; }++ /* Disable WOL by default */+ ret = at803x_set_wol(phydev, &wol);+ if (ret < 0) {+ phydev_err(phydev, "failed to disable WOL on probe: %d\n", ret);+ return ret;
@@ -443,10 +443,10 @@ static int at803x_set_wol(struct phy_device *phydev,AT803X_LOC_MAC_ADDR_0_15_OFFSET,};-if(!ndev)-return-ENODEV;-if(wol->wolopts&WAKE_MAGIC){+if(!ndev)+return-ENODEV;
Please move the ndev variable into the scope.
It'll make it clear that it can't be used elsewhere
in this function.
Thank you for review, done in v2.
quoted
mac = (const u8 *) ndev->dev_addr;
if (!is_valid_ether_addr(mac))
@@ -857,6 +857,9 @@ static int at803x_probe(struct phy_device *phydev) if (phydev->drv->phy_id == ATH8031_PHY_ID) { int ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG); int mode_cfg;+ struct ethtool_wolinfo wol = {+ .wolopts = 0,+ }; if (ccr < 0) goto err;
@@ -872,6 +875,13 @@ static int at803x_probe(struct phy_device *phydev) priv->is_fiber = true; break; }++ /* Disable WOL by default */+ ret = at803x_set_wol(phydev, &wol);+ if (ret < 0) {+ phydev_err(phydev, "failed to disable WOL on probe: %d\n", ret);+ return ret;