All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Woojung Huh <woojung.huh@microchip.com>,
	UNGLinuxDriver@microchip.com, Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vladimir Oltean <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Oleksij Rempel <o.rempel@pengutronix.de>,
	kernel@pengutronix.de, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, Arun.Ramadoss@microchip.com
Subject: [PATCH net-next v3 08/15] net: phy: start using genphy_c45_ethtool_get/set_eee()
Date: Mon, 30 Jan 2023 09:07:07 +0100	[thread overview]
Message-ID: <20230130080714.139492-9-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20230130080714.139492-1-o.rempel@pengutronix.de>

All preparations are done. Now we can start using new functions and remove
the old code.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/phy/phy.c | 60 ++-----------------------------------------
 1 file changed, 2 insertions(+), 58 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 41cfb24c48c1..54b62a604238 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1578,33 +1578,10 @@ EXPORT_SYMBOL(phy_get_eee_err);
  */
 int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data)
 {
-	int val;
-
 	if (!phydev->drv)
 		return -EIO;
 
-	/* Get Supported EEE */
-	val = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
-	if (val < 0)
-		return val;
-	data->supported = mmd_eee_cap_to_ethtool_sup_t(val);
-
-	/* Get advertisement EEE */
-	val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
-	if (val < 0)
-		return val;
-	data->advertised = mmd_eee_adv_to_ethtool_adv_t(val);
-	data->eee_enabled = !!data->advertised;
-
-	/* Get LP advertisement EEE */
-	val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_LPABLE);
-	if (val < 0)
-		return val;
-	data->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(val);
-
-	data->eee_active = !!(data->advertised & data->lp_advertised);
-
-	return 0;
+	return genphy_c45_ethtool_get_eee(phydev, data);
 }
 EXPORT_SYMBOL(phy_ethtool_get_eee);
 
@@ -1617,43 +1594,10 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
  */
 int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
 {
-	int cap, old_adv, adv = 0, ret;
-
 	if (!phydev->drv)
 		return -EIO;
 
-	/* Get Supported EEE */
-	cap = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
-	if (cap < 0)
-		return cap;
-
-	old_adv = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
-	if (old_adv < 0)
-		return old_adv;
-
-	if (data->eee_enabled) {
-		adv = !data->advertised ? cap :
-		      ethtool_adv_to_mmd_eee_adv_t(data->advertised) & cap;
-		/* Mask prohibited EEE modes */
-		adv &= ~phydev->eee_broken_modes;
-	}
-
-	if (old_adv != adv) {
-		ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
-		if (ret < 0)
-			return ret;
-
-		/* Restart autonegotiation so the new modes get sent to the
-		 * link partner.
-		 */
-		if (phydev->autoneg == AUTONEG_ENABLE) {
-			ret = phy_restart_aneg(phydev);
-			if (ret < 0)
-				return ret;
-		}
-	}
-
-	return 0;
+	return genphy_c45_ethtool_set_eee(phydev, data);
 }
 EXPORT_SYMBOL(phy_ethtool_set_eee);
 
-- 
2.30.2


  parent reply	other threads:[~2023-01-30  8:07 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-30  8:06 [PATCH net-next v3 00/15] net: add EEE support for KSZ9477 and AR8035 with i.MX6 Oleksij Rempel
2023-01-30  8:07 ` [PATCH net-next v3 01/15] net: dsa: microchip: enable EEE support Oleksij Rempel
2023-01-30 17:59   ` Vladimir Oltean
2023-01-30  8:07 ` [PATCH net-next v3 02/15] net: phy: add genphy_c45_read_eee_abilities() function Oleksij Rempel
2023-01-30 21:55   ` Andrew Lunn
2023-01-30  8:07 ` [PATCH net-next v3 03/15] net: phy: micrel: add ksz9477_get_features() Oleksij Rempel
2023-01-30  8:07 ` [PATCH net-next v3 04/15] net: phy: export phy_check_valid() function Oleksij Rempel
2023-01-30  8:07 ` [PATCH net-next v3 05/15] net: phy: add genphy_c45_ethtool_get/set_eee() support Oleksij Rempel
2023-01-30 22:06   ` Andrew Lunn
2023-01-30  8:07 ` [PATCH net-next v3 06/15] net: phy: c22: migrate to genphy_c45_write_eee_adv() Oleksij Rempel
2023-01-30  8:07 ` [PATCH net-next v3 07/15] net: phy: c45: " Oleksij Rempel
2023-01-30  8:07 ` Oleksij Rempel [this message]
2023-01-30  8:07 ` [PATCH net-next v3 09/15] net: phy: add driver specific get/set_eee support Oleksij Rempel
2023-01-30  8:07 ` [PATCH net-next v3 10/15] net: phy: at803x: implement ethtool access to SmartEEE functionality Oleksij Rempel
2023-01-30  8:07 ` [PATCH net-next v3 11/15] net: phy: at803x: ar8035: fix EEE support for half duplex links Oleksij Rempel
2023-01-30  8:07 ` [PATCH net-next v3 12/15] net: phy: add PHY specifica flag to signal SmartEEE support Oleksij Rempel
2023-01-30  8:07 ` [PATCH net-next v3 13/15] net: phy: at803x: add PHY_SMART_EEE flag to AR8035 Oleksij Rempel
2023-01-30  8:07 ` [PATCH net-next v3 14/15] net: phy: add phy_has_smarteee() helper Oleksij Rempel
2023-01-30  8:07 ` [PATCH net-next v3 15/15] net: fec: add support for PHYs with SmartEEE support Oleksij Rempel
2023-01-31 20:52   ` Vladimir Oltean
2023-02-01 12:45     ` Oleksij Rempel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230130080714.139492-9-o.rempel@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=Arun.Ramadoss@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=vivien.didelot@gmail.com \
    --cc=woojung.huh@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.