Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions drivers/net/phy/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
* phy_ethtool_set_eee_noneg - Adjusts MAC LPI configuration without PHY
* renegotiation
* @phydev: pointer to the target PHY device structure
* @data: pointer to the ethtool_keee structure containing the new EEE settings
* @old_cfg: pointer to the eee_config structure containing the old EEE settings
*
* This function updates the Energy Efficient Ethernet (EEE) configuration
* for cases where only the MAC's Low Power Idle (LPI) configuration changes,
Expand All @@ -1739,11 +1739,10 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
* configuration.
*/
static void phy_ethtool_set_eee_noneg(struct phy_device *phydev,
struct ethtool_keee *data)
const struct eee_config *old_cfg)
{
if (phydev->eee_cfg.tx_lpi_enabled != data->tx_lpi_enabled ||
phydev->eee_cfg.tx_lpi_timer != data->tx_lpi_timer) {
eee_to_eeecfg(&phydev->eee_cfg, data);
if (phydev->eee_cfg.tx_lpi_enabled != old_cfg->tx_lpi_enabled ||
phydev->eee_cfg.tx_lpi_timer != old_cfg->tx_lpi_timer) {
phydev->enable_tx_lpi = eeecfg_mac_can_tx_lpi(&phydev->eee_cfg);
if (phydev->link) {
phydev->link = false;
Expand All @@ -1763,18 +1762,23 @@ static void phy_ethtool_set_eee_noneg(struct phy_device *phydev,
*/
int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_keee *data)
{
struct eee_config old_cfg;
int ret;

if (!phydev->drv)
return -EIO;

mutex_lock(&phydev->lock);

old_cfg = phydev->eee_cfg;
eee_to_eeecfg(&phydev->eee_cfg, data);

ret = genphy_c45_ethtool_set_eee(phydev, data);
if (ret >= 0) {
if (ret == 0)
phy_ethtool_set_eee_noneg(phydev, data);
eee_to_eeecfg(&phydev->eee_cfg, data);
}
if (ret == 0)
phy_ethtool_set_eee_noneg(phydev, &old_cfg);
else if (ret < 0)
phydev->eee_cfg = old_cfg;

mutex_unlock(&phydev->lock);

return ret < 0 ? ret : 0;
Expand Down