Skip to content

Commit 2624b58

Browse files
oleremNipaLocal
authored andcommitted
net: usb: lan78xx: port link settings to phylink API
Refactor lan78xx_get_link_ksettings and lan78xx_set_link_ksettings to use the phylink API (phylink_ethtool_ksettings_get and phylink_ethtool_ksettings_set) instead of directly interfacing with the PHY. This change simplifies the code and ensures better integration with the phylink framework for link management. Additionally, the explicit calls to usb_autopm_get_interface() and usb_autopm_put_interface() have been removed. These were originally needed to manage USB power management during register accesses. However, lan78xx_mdiobus_read() and lan78xx_mdiobus_write() already handle USB auto power management internally, ensuring that the interface remains active when necessary. Since there are no other direct register accesses in these functions that require explicit power management handling, the extra calls have become redundant and are no longer needed. Signed-off-by: Oleksij Rempel <[email protected]> Reviewed-by: Maxime Chevallier <[email protected]> Reviewed-by: Russell King (Oracle) <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 8d417fd commit 2624b58

File tree

1 file changed

+2
-32
lines changed

1 file changed

+2
-32
lines changed

drivers/net/usb/lan78xx.c

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,46 +1866,16 @@ static int lan78xx_get_link_ksettings(struct net_device *net,
18661866
struct ethtool_link_ksettings *cmd)
18671867
{
18681868
struct lan78xx_net *dev = netdev_priv(net);
1869-
struct phy_device *phydev = net->phydev;
1870-
int ret;
1871-
1872-
ret = usb_autopm_get_interface(dev->intf);
1873-
if (ret < 0)
1874-
return ret;
18751869

1876-
phy_ethtool_ksettings_get(phydev, cmd);
1877-
1878-
usb_autopm_put_interface(dev->intf);
1879-
1880-
return ret;
1870+
return phylink_ethtool_ksettings_get(dev->phylink, cmd);
18811871
}
18821872

18831873
static int lan78xx_set_link_ksettings(struct net_device *net,
18841874
const struct ethtool_link_ksettings *cmd)
18851875
{
18861876
struct lan78xx_net *dev = netdev_priv(net);
1887-
struct phy_device *phydev = net->phydev;
1888-
int ret = 0;
1889-
int temp;
1890-
1891-
ret = usb_autopm_get_interface(dev->intf);
1892-
if (ret < 0)
1893-
return ret;
1894-
1895-
/* change speed & duplex */
1896-
ret = phy_ethtool_ksettings_set(phydev, cmd);
18971877

1898-
if (!cmd->base.autoneg) {
1899-
/* force link down */
1900-
temp = phy_read(phydev, MII_BMCR);
1901-
phy_write(phydev, MII_BMCR, temp | BMCR_LOOPBACK);
1902-
mdelay(1);
1903-
phy_write(phydev, MII_BMCR, temp);
1904-
}
1905-
1906-
usb_autopm_put_interface(dev->intf);
1907-
1908-
return ret;
1878+
return phylink_ethtool_ksettings_set(dev->phylink, cmd);
19091879
}
19101880

19111881
static void lan78xx_get_pause(struct net_device *net,

0 commit comments

Comments
 (0)