From nobody Thu Oct 9 08:54:04 2025 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24AFB27F16C for ; Wed, 18 Jun 2025 12:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750249572; cv=none; b=qQc7Hu4l6CobJdknElE9gZxv40aK2chAC+l4Wco0P1qsi9XTD/dCv1myddpcwUv0DvvuP42WeToUMpSNwTzF+xm9w/m06U4xDAdFyA5WNITbij7EQZpvp6HyPqWp0Eskk1GdvyZtqyaGX5NX2SvyTQDYP+mGYPgL5GHG2bgWOYI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750249572; c=relaxed/simple; bh=U/U7iAZLQyV2QekzUH0bP3G5BFfFJqldYl8IDa4EX7c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Auz00tR8RDUf4qp4FZO4wHpm+kz0oxnFdwCky+tD3K1VzPxC+Qs1z0sEyNPzrXtc9IF/1IFEptVOpLXtON39h5QgyAju+YuxJlHntU07jR9eWwhcOs9pn2sAI9H0ucTvSD5YgIoJQ/+CIR0GVkuuaAydC407D7WtLt7+gQdVo+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uRrrg-00007h-UX; Wed, 18 Jun 2025 14:26:04 +0200 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uRrrf-0048Up-1j; Wed, 18 Jun 2025 14:26:03 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1uRrrf-00DFCp-1I; Wed, 18 Jun 2025 14:26:03 +0200 From: Oleksij Rempel To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Woojung Huh , Andrew Lunn , Russell King , Thangaraj Samynathan , Rengarajan Sundararajan Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Phil Elwell , Maxime Chevallier , Simon Horman Subject: [PATCH net-next v8 1/6] net: usb: lan78xx: Convert to PHYLINK for improved PHY and MAC management Date: Wed, 18 Jun 2025 14:25:57 +0200 Message-Id: <20250618122602.3156678-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618122602.3156678-1-o.rempel@pengutronix.de> References: <20250618122602.3156678-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Convert the LAN78xx USB Ethernet driver to use the PHYLINK framework for managing PHY and MAC interactions. This improves consistency with other network drivers, simplifies pause frame handling, and enables cleaner suspend/resume support. Key changes: - Replace all PHYLIB-based logic with PHYLINK equivalents: - Replace phy_connect()/phy_disconnect() with phylink_connect_phy() - Replace phy_start()/phy_stop() with phylink_start()/phylink_stop() - Replace pauseparam handling with phylink_ethtool_get/set_pauseparam() - Introduce lan78xx_phylink_setup() to configure PHYLINK - Add phylink MAC operations: - lan78xx_mac_config() - lan78xx_mac_link_up() - lan78xx_mac_link_down() - Remove legacy link state handling: - lan78xx_link_status_change() - lan78xx_link_reset() - Handle fixed-link fallback for LAN7801 using phylink_set_fixed_link() - Replace deprecated flow control handling with phylink-managed logic Power management: - Switch suspend/resume paths to use phylink_suspend()/phylink_resume() - Ensure proper use of rtnl_lock() where required - Note: full runtime testing of power management is currently limited due to hardware setup constraints Note: Conversion of EEE (Energy Efficient Ethernet) handling to the PHYLINK-managed API will be done in a follow-up patch. For now, the legacy EEE enable logic is preserved in mac_link_up(). Signed-off-by: Oleksij Rempel Reviewed-by: Russell King (Oracle) --- changes v8: - Move netif_start_queue() from open() to the end of lan78xx_mac_link_up() - Move netif_stop_queue() from close() to the start of lan78xx_mac_link_dow= n() - lan78xx_mac_link_up: add blank line before link_up_fail - lan78xx_phy_init: do error cleanup in the function - Revert EVENT_LINK_RESET rename and move it to a separate, earlier patch changes v6: - move functional interface changes and refactoring to separate patches - switch suspend/resume to use phylink_suspend/resume with correct locking - avoid setting phydev->interface manually; rely on phylink negotiation - remove legacy pause/aneg setup and dead code (e.g. lan78xx_link_status_ch= ange) - EEE conversion postponed to follow-up patch - note that power management testing is limited due to HW constraints changes v5: - merge ethtool pause interface changes to this patch changes v4: - add PHYLINK dependency - remove PHYLIB and FIXED_PHY, both are replaced by PHYLINK changes v3: - lan78xx_phy_init: drop phy_suspend() - lan78xx_phylink_setup: use phy_interface_set_rgmii() changes v2: - lan78xx_mac_config: remove unused rgmii_id - lan78xx_mac_config: PHY_INTERFACE_MODE_RGMII* variants - lan78xx_mac_config: remove auto-speed and duplex configuration - lan78xx_phylink_setup: set link_interface to PHY_INTERFACE_MODE_RGMII_ID instead of PHY_INTERFACE_MODE_NA. - lan78xx_phy_init: use phylink_set_fixed_link() instead of allocating fixed PHY. - lan78xx_configure_usb: move function values to separate variables --- drivers/net/usb/Kconfig | 3 +- drivers/net/usb/lan78xx.c | 547 ++++++++++++++++++-------------------- 2 files changed, 262 insertions(+), 288 deletions(-) diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig index 370b32fc2588..0a678e31cfaa 100644 --- a/drivers/net/usb/Kconfig +++ b/drivers/net/usb/Kconfig @@ -113,9 +113,8 @@ config USB_RTL8152 config USB_LAN78XX tristate "Microchip LAN78XX Based USB Ethernet Adapters" select MII - select PHYLIB + select PHYLINK select MICROCHIP_PHY - select FIXED_PHY select CRC32 help This option adds support for Microchip LAN78XX based USB 2 diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 64e2597c77cc..61b2a7c26f60 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -455,7 +456,6 @@ struct lan78xx_net { =20 unsigned long data[5]; =20 - int link_on; u8 mdix_ctrl; =20 u32 chipid; @@ -463,13 +463,13 @@ struct lan78xx_net { struct mii_bus *mdiobus; phy_interface_t interface; =20 - int fc_autoneg; - u8 fc_request_control; - int delta; struct statstage stats; =20 struct irq_domain_data domain_data; + + struct phylink *phylink; + struct phylink_config phylink_config; }; =20 /* use ethtool to change the level for any given device */ @@ -1554,28 +1554,6 @@ static void lan78xx_set_multicast(struct net_device = *netdev) schedule_work(&pdata->set_multicast); } =20 -static int lan78xx_configure_flowcontrol(struct lan78xx_net *dev, - bool tx_pause, bool rx_pause); - -static int lan78xx_update_flowcontrol(struct lan78xx_net *dev, u8 duplex, - u16 lcladv, u16 rmtadv) -{ - u8 cap; - - if (dev->fc_autoneg) - cap =3D mii_resolve_flowctrl_fdx(lcladv, rmtadv); - else - cap =3D dev->fc_request_control; - - netif_dbg(dev, link, dev->net, "rx pause %s, tx pause %s", - (cap & FLOW_CTRL_RX ? "enabled" : "disabled"), - (cap & FLOW_CTRL_TX ? "enabled" : "disabled")); - - return lan78xx_configure_flowcontrol(dev, - cap & FLOW_CTRL_TX, - cap & FLOW_CTRL_RX); -} - static void lan78xx_rx_urb_submit_all(struct lan78xx_net *dev); =20 static int lan78xx_mac_reset(struct lan78xx_net *dev) @@ -1638,75 +1616,6 @@ static int lan78xx_phy_int_ack(struct lan78xx_net *d= ev) return lan78xx_write_reg(dev, INT_STS, INT_STS_PHY_INT_); } =20 -static int lan78xx_configure_usb(struct lan78xx_net *dev, int speed); - -static int lan78xx_link_reset(struct lan78xx_net *dev) -{ - struct phy_device *phydev =3D dev->net->phydev; - struct ethtool_link_ksettings ecmd; - int ladv, radv, ret, link; - - /* clear LAN78xx interrupt status */ - ret =3D lan78xx_phy_int_ack(dev); - if (unlikely(ret < 0)) - return ret; - - mutex_lock(&phydev->lock); - phy_read_status(phydev); - link =3D phydev->link; - mutex_unlock(&phydev->lock); - - if (!link && dev->link_on) { - dev->link_on =3D false; - - /* reset MAC */ - ret =3D lan78xx_mac_reset(dev); - if (ret < 0) - return ret; - - timer_delete(&dev->stat_monitor); - } else if (link && !dev->link_on) { - dev->link_on =3D true; - - phy_ethtool_ksettings_get(phydev, &ecmd); - - ret =3D lan78xx_configure_usb(dev, ecmd.base.speed); - if (ret < 0) - return ret; - - ladv =3D phy_read(phydev, MII_ADVERTISE); - if (ladv < 0) - return ladv; - - radv =3D phy_read(phydev, MII_LPA); - if (radv < 0) - return radv; - - netif_dbg(dev, link, dev->net, - "speed: %u duplex: %d anadv: 0x%04x anlpa: 0x%04x", - ecmd.base.speed, ecmd.base.duplex, ladv, radv); - - ret =3D lan78xx_update_flowcontrol(dev, ecmd.base.duplex, ladv, - radv); - if (ret < 0) - return ret; - - if (!timer_pending(&dev->stat_monitor)) { - dev->delta =3D 1; - mod_timer(&dev->stat_monitor, - jiffies + STAT_UPDATE_TIMER); - } - - lan78xx_rx_urb_submit_all(dev); - - local_bh_disable(); - napi_schedule(&dev->napi); - local_bh_enable(); - } - - return 0; -} - /* some work can't be done in tasklets, so we use keventd * * NOTE: annoying asymmetry: if it's active, schedule_work() fails, @@ -2015,63 +1924,16 @@ static void lan78xx_get_pause(struct net_device *ne= t, struct ethtool_pauseparam *pause) { struct lan78xx_net *dev =3D netdev_priv(net); - struct phy_device *phydev =3D net->phydev; - struct ethtool_link_ksettings ecmd; =20 - phy_ethtool_ksettings_get(phydev, &ecmd); - - pause->autoneg =3D dev->fc_autoneg; - - if (dev->fc_request_control & FLOW_CTRL_TX) - pause->tx_pause =3D 1; - - if (dev->fc_request_control & FLOW_CTRL_RX) - pause->rx_pause =3D 1; + phylink_ethtool_get_pauseparam(dev->phylink, pause); } =20 static int lan78xx_set_pause(struct net_device *net, struct ethtool_pauseparam *pause) { struct lan78xx_net *dev =3D netdev_priv(net); - struct phy_device *phydev =3D net->phydev; - struct ethtool_link_ksettings ecmd; - int ret; - - phy_ethtool_ksettings_get(phydev, &ecmd); - - if (pause->autoneg && !ecmd.base.autoneg) { - ret =3D -EINVAL; - goto exit; - } - - dev->fc_request_control =3D 0; - if (pause->rx_pause) - dev->fc_request_control |=3D FLOW_CTRL_RX; - - if (pause->tx_pause) - dev->fc_request_control |=3D FLOW_CTRL_TX; - - if (ecmd.base.autoneg) { - __ETHTOOL_DECLARE_LINK_MODE_MASK(fc) =3D { 0, }; - u32 mii_adv; - - linkmode_clear_bit(ETHTOOL_LINK_MODE_Pause_BIT, - ecmd.link_modes.advertising); - linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, - ecmd.link_modes.advertising); - mii_adv =3D (u32)mii_advertise_flowctrl(dev->fc_request_control); - mii_adv_to_linkmode_adv_t(fc, mii_adv); - linkmode_or(ecmd.link_modes.advertising, fc, - ecmd.link_modes.advertising); - - phy_ethtool_ksettings_set(phydev, &ecmd); - } - - dev->fc_autoneg =3D pause->autoneg; =20 - ret =3D 0; -exit: - return ret; + return phylink_ethtool_set_pauseparam(dev->phylink, pause); } =20 static int lan78xx_get_regs_len(struct net_device *netdev) @@ -2332,26 +2194,6 @@ static void lan78xx_remove_mdio(struct lan78xx_net *= dev) mdiobus_free(dev->mdiobus); } =20 -static void lan78xx_link_status_change(struct net_device *net) -{ - struct lan78xx_net *dev =3D netdev_priv(net); - struct phy_device *phydev =3D net->phydev; - u32 data; - int ret; - - ret =3D lan78xx_read_reg(dev, MAC_CR, &data); - if (ret < 0) - return; - - if (phydev->enable_tx_lpi) - data |=3D MAC_CR_EEE_EN_; - else - data &=3D ~MAC_CR_EEE_EN_; - lan78xx_write_reg(dev, MAC_CR, data); - - phy_print_status(phydev); -} - static int irq_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hwirq) { @@ -2481,6 +2323,77 @@ static void lan78xx_remove_irq_domain(struct lan78xx= _net *dev) dev->domain_data.irqdomain =3D NULL; } =20 +static void lan78xx_mac_config(struct phylink_config *config, unsigned int= mode, + const struct phylink_link_state *state) +{ + struct net_device *net =3D to_net_dev(config->dev); + struct lan78xx_net *dev =3D netdev_priv(net); + u32 mac_cr =3D 0; + int ret; + + /* Check if the mode is supported */ + if (mode !=3D MLO_AN_FIXED && mode !=3D MLO_AN_PHY) { + netdev_err(net, "Unsupported negotiation mode: %u\n", mode); + return; + } + + switch (state->interface) { + case PHY_INTERFACE_MODE_GMII: + mac_cr |=3D MAC_CR_GMII_EN_; + break; + case PHY_INTERFACE_MODE_RGMII: + case PHY_INTERFACE_MODE_RGMII_ID: + case PHY_INTERFACE_MODE_RGMII_TXID: + case PHY_INTERFACE_MODE_RGMII_RXID: + break; + default: + netdev_warn(net, "Unsupported interface mode: %d\n", + state->interface); + return; + } + + ret =3D lan78xx_update_reg(dev, MAC_CR, MAC_CR_GMII_EN_, mac_cr); + if (ret < 0) + netdev_err(net, "Failed to config MAC with error %pe\n", + ERR_PTR(ret)); +} + +static void lan78xx_mac_link_down(struct phylink_config *config, + unsigned int mode, phy_interface_t interface) +{ + struct net_device *net =3D to_net_dev(config->dev); + struct lan78xx_net *dev =3D netdev_priv(net); + int ret; + + netif_stop_queue(net); + + /* MAC reset will not de-assert TXEN/RXEN, we need to stop them + * manually before reset. TX and RX should be disabled before running + * link_up sequence. + */ + ret =3D lan78xx_stop_tx_path(dev); + if (ret < 0) + goto link_down_fail; + + ret =3D lan78xx_stop_rx_path(dev); + if (ret < 0) + goto link_down_fail; + + /* MAC reset seems to not affect MAC configuration, no idea if it is + * really needed, but it was done in previous driver version. So, leave + * it here. + */ + ret =3D lan78xx_mac_reset(dev); + if (ret < 0) + goto link_down_fail; + + return; + +link_down_fail: + netdev_err(dev->net, "Failed to set MAC down with error %pe\n", + ERR_PTR(ret)); +} + /** * lan78xx_configure_usb - Configure USB link power settings * @dev: pointer to the LAN78xx device structure @@ -2616,28 +2529,103 @@ static int lan78xx_configure_flowcontrol(struct la= n78xx_net *dev, return lan78xx_write_reg(dev, FLOW, flow); } =20 +static void lan78xx_mac_link_up(struct phylink_config *config, + struct phy_device *phy, + unsigned int mode, phy_interface_t interface, + int speed, int duplex, + bool tx_pause, bool rx_pause) +{ + struct net_device *net =3D to_net_dev(config->dev); + struct lan78xx_net *dev =3D netdev_priv(net); + u32 mac_cr =3D 0; + int ret; + + switch (speed) { + case SPEED_1000: + mac_cr |=3D MAC_CR_SPEED_1000_; + break; + case SPEED_100: + mac_cr |=3D MAC_CR_SPEED_100_; + break; + case SPEED_10: + mac_cr |=3D MAC_CR_SPEED_10_; + break; + default: + netdev_err(dev->net, "Unsupported speed %d\n", speed); + return; + } + + if (duplex =3D=3D DUPLEX_FULL) + mac_cr |=3D MAC_CR_FULL_DUPLEX_; + + /* make sure TXEN and RXEN are disabled before reconfiguring MAC */ + ret =3D lan78xx_update_reg(dev, MAC_CR, MAC_CR_SPEED_MASK_ | + MAC_CR_FULL_DUPLEX_ | MAC_CR_EEE_EN_, mac_cr); + if (ret < 0) + goto link_up_fail; + + ret =3D lan78xx_configure_flowcontrol(dev, tx_pause, rx_pause); + if (ret < 0) + goto link_up_fail; + + ret =3D lan78xx_configure_usb(dev, speed); + if (ret < 0) + goto link_up_fail; + + lan78xx_rx_urb_submit_all(dev); + + ret =3D lan78xx_flush_rx_fifo(dev); + if (ret < 0) + goto link_up_fail; + + ret =3D lan78xx_flush_tx_fifo(dev); + if (ret < 0) + goto link_up_fail; + + ret =3D lan78xx_start_tx_path(dev); + if (ret < 0) + goto link_up_fail; + + ret =3D lan78xx_start_rx_path(dev); + if (ret < 0) + goto link_up_fail; + + netif_start_queue(net); + + return; + +link_up_fail: + netdev_err(dev->net, "Failed to set MAC up with error %pe\n", + ERR_PTR(ret)); +} + +static const struct phylink_mac_ops lan78xx_phylink_mac_ops =3D { + .mac_config =3D lan78xx_mac_config, + .mac_link_down =3D lan78xx_mac_link_down, + .mac_link_up =3D lan78xx_mac_link_up, +}; + /** - * lan78xx_register_fixed_phy() - Register a fallback fixed PHY + * lan78xx_set_fixed_link() - Set fixed link configuration for LAN7801 * @dev: LAN78xx device * - * Registers a fixed PHY with 1 Gbps full duplex. This is used in special = cases - * like EVB-KSZ9897-1, where LAN7801 acts as a USB-to-Ethernet interface t= o a - * switch without a visible PHY. + * Use fixed link configuration with 1 Gbps full duplex. This is used in s= pecial + * cases like EVB-KSZ9897-1, where LAN7801 acts as a USB-to-Ethernet inter= face + * to a switch without a visible PHY. * * Return: pointer to the registered fixed PHY, or ERR_PTR() on error. */ -static struct phy_device *lan78xx_register_fixed_phy(struct lan78xx_net *d= ev) +static int lan78xx_set_fixed_link(struct lan78xx_net *dev) { - static const struct fixed_phy_status fphy_status =3D { - .link =3D 1, + static const struct phylink_link_state state =3D { .speed =3D SPEED_1000, .duplex =3D DUPLEX_FULL, }; =20 netdev_info(dev->net, - "No PHY found on LAN7801 =E2=80=93 registering fixed PHY (e.g. EVB-K= SZ9897-1)\n"); + "No PHY found on LAN7801 =E2=80=93 using fixed link instead (e.g. EV= B-KSZ9897-1)\n"); =20 - return fixed_phy_register(&fphy_status, NULL); + return phylink_set_fixed_link(dev->phylink, &state); } =20 /** @@ -2673,7 +2661,7 @@ static struct phy_device *lan78xx_get_phy(struct lan7= 8xx_net *dev) =20 dev->interface =3D PHY_INTERFACE_MODE_RGMII; /* No PHY found =E2=80=93 fallback to fixed PHY (e.g. KSZ switch board) = */ - return lan78xx_register_fixed_phy(dev); + return NULL; =20 case ID_REV_CHIP_ID_7800_: case ID_REV_CHIP_ID_7850_: @@ -2800,20 +2788,72 @@ static int lan78xx_configure_leds_from_dt(struct la= n78xx_net *dev, return lan78xx_write_reg(dev, HW_CFG, reg); } =20 +static int lan78xx_phylink_setup(struct lan78xx_net *dev) +{ + struct phylink_config *pc =3D &dev->phylink_config; + struct phylink *phylink; + + pc->dev =3D &dev->net->dev; + pc->type =3D PHYLINK_NETDEV; + pc->mac_capabilities =3D MAC_SYM_PAUSE | MAC_ASYM_PAUSE | MAC_10 | + MAC_100 | MAC_1000FD; + pc->mac_managed_pm =3D true; + + if (dev->chipid =3D=3D ID_REV_CHIP_ID_7801_) + phy_interface_set_rgmii(pc->supported_interfaces); + else + __set_bit(PHY_INTERFACE_MODE_GMII, pc->supported_interfaces); + + phylink =3D phylink_create(pc, dev->net->dev.fwnode, + dev->interface, &lan78xx_phylink_mac_ops); + if (IS_ERR(phylink)) + return PTR_ERR(phylink); + + dev->phylink =3D phylink; + + return 0; +} + +static void lan78xx_phy_uninit(struct lan78xx_net *dev) +{ + if (dev->phylink) { + phylink_disconnect_phy(dev->phylink); + phylink_destroy(dev->phylink); + dev->phylink =3D NULL; + } +} + static int lan78xx_phy_init(struct lan78xx_net *dev) { - __ETHTOOL_DECLARE_LINK_MODE_MASK(fc) =3D { 0, }; - int ret; - u32 mii_adv; struct phy_device *phydev; + int ret; =20 phydev =3D lan78xx_get_phy(dev); + /* phydev can be NULL if no PHY is found and the chip is LAN7801, + * which will use a fixed link later. + * If an error occurs, return the error code immediately. + */ if (IS_ERR(phydev)) return PTR_ERR(phydev); =20 + ret =3D lan78xx_phylink_setup(dev); + if (ret < 0) + return ret; + + /* If no PHY is found, set up a fixed link. It is very specific to + * the LAN7801 and is used in special cases like EVB-KSZ9897-1 where + * LAN7801 acts as a USB-to-Ethernet interface to a switch without + * a visible PHY. + */ + if (!phydev) { + ret =3D lan78xx_set_fixed_link(dev); + if (ret < 0) + goto phylink_uninit; + } + ret =3D lan78xx_mac_prepare_for_phy(dev); if (ret < 0) - goto free_phy; + goto phylink_uninit; =20 /* if phyirq is not set, use polling mode in phylib */ if (dev->domain_data.phyirq > 0) @@ -2822,54 +2862,23 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) phydev->irq =3D PHY_POLL; netdev_dbg(dev->net, "phydev->irq =3D %d\n", phydev->irq); =20 - /* set to AUTOMDIX */ - phydev->mdix =3D ETH_TP_MDI_AUTO; - - ret =3D phy_connect_direct(dev->net, phydev, - lan78xx_link_status_change, - dev->interface); + ret =3D phylink_connect_phy(dev->phylink, phydev); if (ret) { - netdev_err(dev->net, "can't attach PHY to %s\n", - dev->mdiobus->id); - if (dev->chipid =3D=3D ID_REV_CHIP_ID_7801_) { - if (phy_is_pseudo_fixed_link(phydev)) { - fixed_phy_unregister(phydev); - phy_device_free(phydev); - } - } - return -EIO; + netdev_err(dev->net, "can't attach PHY to %s, error %pe\n", + dev->mdiobus->id, ERR_PTR(ret)); + goto phylink_uninit; } =20 - /* MAC doesn't support 1000T Half */ - phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT); - - /* support both flow controls */ - dev->fc_request_control =3D (FLOW_CTRL_RX | FLOW_CTRL_TX); - linkmode_clear_bit(ETHTOOL_LINK_MODE_Pause_BIT, - phydev->advertising); - linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, - phydev->advertising); - mii_adv =3D (u32)mii_advertise_flowctrl(dev->fc_request_control); - mii_adv_to_linkmode_adv_t(fc, mii_adv); - linkmode_or(phydev->advertising, fc, phydev->advertising); - phy_support_eee(phydev); =20 ret =3D lan78xx_configure_leds_from_dt(dev, phydev); - if (ret) - goto free_phy; - - genphy_config_aneg(phydev); - - dev->fc_autoneg =3D phydev->autoneg; + if (ret < 0) + goto phylink_uninit; =20 return 0; =20 -free_phy: - if (phy_is_pseudo_fixed_link(phydev)) { - fixed_phy_unregister(phydev); - phy_device_free(phydev); - } +phylink_uninit: + lan78xx_phy_uninit(dev); =20 return ret; } @@ -3210,7 +3219,6 @@ static int lan78xx_reset(struct lan78xx_net *dev) unsigned long timeout; int ret; u32 buf; - u8 sig; =20 ret =3D lan78xx_read_reg(dev, HW_CFG, &buf); if (ret < 0) @@ -3367,22 +3375,12 @@ static int lan78xx_reset(struct lan78xx_net *dev) if (ret < 0) return ret; =20 + buf &=3D ~(MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_); + /* LAN7801 only has RGMII mode */ - if (dev->chipid =3D=3D ID_REV_CHIP_ID_7801_) { + if (dev->chipid =3D=3D ID_REV_CHIP_ID_7801_) buf &=3D ~MAC_CR_GMII_EN_; - /* Enable Auto Duplex and Auto speed */ - buf |=3D MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_; - } =20 - if (dev->chipid =3D=3D ID_REV_CHIP_ID_7800_ || - dev->chipid =3D=3D ID_REV_CHIP_ID_7850_) { - ret =3D lan78xx_read_raw_eeprom(dev, 0, 1, &sig); - if (!ret && sig !=3D EEPROM_INDICATOR) { - /* Implies there is no external eeprom. Set mac speed */ - netdev_info(dev->net, "No External EEPROM. Setting MAC Speed\n"); - buf |=3D MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_; - } - } ret =3D lan78xx_write_reg(dev, MAC_CR, buf); if (ret < 0) return ret; @@ -3432,9 +3430,11 @@ static int lan78xx_open(struct net_device *net) =20 mutex_lock(&dev->dev_mutex); =20 - phy_start(net->phydev); + lan78xx_init_stats(dev); + + napi_enable(&dev->napi); =20 - netif_dbg(dev, ifup, dev->net, "phy initialised successfully"); + set_bit(EVENT_DEV_OPEN, &dev->flags); =20 /* for Link Check */ if (dev->urb_intr) { @@ -3446,31 +3446,8 @@ static int lan78xx_open(struct net_device *net) } } =20 - ret =3D lan78xx_flush_rx_fifo(dev); - if (ret < 0) - goto done; - ret =3D lan78xx_flush_tx_fifo(dev); - if (ret < 0) - goto done; + phylink_start(dev->phylink); =20 - ret =3D lan78xx_start_tx_path(dev); - if (ret < 0) - goto done; - ret =3D lan78xx_start_rx_path(dev); - if (ret < 0) - goto done; - - lan78xx_init_stats(dev); - - set_bit(EVENT_DEV_OPEN, &dev->flags); - - netif_start_queue(net); - - dev->link_on =3D false; - - napi_enable(&dev->napi); - - lan78xx_defer_kevent(dev, EVENT_LINK_RESET); done: mutex_unlock(&dev->dev_mutex); =20 @@ -3528,7 +3505,6 @@ static int lan78xx_stop(struct net_device *net) timer_delete_sync(&dev->stat_monitor); =20 clear_bit(EVENT_DEV_OPEN, &dev->flags); - netif_stop_queue(net); napi_disable(&dev->napi); =20 lan78xx_terminate_urbs(dev); @@ -3538,12 +3514,7 @@ static int lan78xx_stop(struct net_device *net) net->stats.rx_packets, net->stats.tx_packets, net->stats.rx_errors, net->stats.tx_errors); =20 - /* ignore errors that occur stopping the Tx and Rx data paths */ - lan78xx_stop_tx_path(dev); - lan78xx_stop_rx_path(dev); - - if (net->phydev) - phy_stop(net->phydev); + phylink_stop(dev->phylink); =20 usb_kill_urb(dev->urb_intr); =20 @@ -4481,10 +4452,10 @@ static void lan78xx_delayedwork(struct work_struct = *work) int ret =3D 0; =20 clear_bit(EVENT_LINK_RESET, &dev->flags); - if (lan78xx_link_reset(dev) < 0) { - netdev_info(dev->net, "link reset failed (%d)\n", - ret); - } + ret =3D lan78xx_phy_int_ack(dev); + if (ret) + netdev_info(dev->net, "PHY INT ack failed (%pe)\n", + ERR_PTR(ret)); } =20 if (test_bit(EVENT_STAT_UPDATE, &dev->flags)) { @@ -4558,32 +4529,29 @@ static void lan78xx_disconnect(struct usb_interface= *intf) struct lan78xx_net *dev; struct usb_device *udev; struct net_device *net; - struct phy_device *phydev; =20 dev =3D usb_get_intfdata(intf); usb_set_intfdata(intf, NULL); if (!dev) return; =20 - netif_napi_del(&dev->napi); - udev =3D interface_to_usbdev(intf); net =3D dev->net; =20 + rtnl_lock(); + phylink_stop(dev->phylink); + phylink_disconnect_phy(dev->phylink); + rtnl_unlock(); + + netif_napi_del(&dev->napi); + unregister_netdev(net); =20 timer_shutdown_sync(&dev->stat_monitor); set_bit(EVENT_DEV_DISCONNECT, &dev->flags); cancel_delayed_work_sync(&dev->wq); =20 - phydev =3D net->phydev; - - phy_disconnect(net->phydev); - - if (phy_is_pseudo_fixed_link(phydev)) { - fixed_phy_unregister(phydev); - phy_device_free(phydev); - } + phylink_destroy(dev->phylink); =20 usb_scuttle_anchored_urbs(&dev->deferred); =20 @@ -4667,7 +4635,6 @@ static int lan78xx_probe(struct usb_interface *intf, goto out1; } =20 - /* netdev_printk() needs this */ SET_NETDEV_DEV(netdev, &intf->dev); =20 dev =3D netdev_priv(netdev); @@ -4786,7 +4753,7 @@ static int lan78xx_probe(struct usb_interface *intf, ret =3D register_netdev(netdev); if (ret !=3D 0) { netif_err(dev, probe, netdev, "couldn't register the device\n"); - goto out8; + goto phy_uninit; } =20 usb_set_intfdata(intf, dev); @@ -4801,8 +4768,8 @@ static int lan78xx_probe(struct usb_interface *intf, =20 return 0; =20 -out8: - phy_disconnect(netdev->phydev); +phy_uninit: + lan78xx_phy_uninit(dev); free_urbs: usb_free_urb(dev->urb_intr); out5: @@ -5137,6 +5104,10 @@ static int lan78xx_suspend(struct usb_interface *int= f, pm_message_t message) spin_unlock_irq(&dev->txq.lock); } =20 + rtnl_lock(); + phylink_suspend(dev->phylink, false); + rtnl_unlock(); + /* stop RX */ ret =3D lan78xx_stop_rx_path(dev); if (ret < 0) @@ -5364,11 +5335,15 @@ static int lan78xx_reset_resume(struct usb_interfac= e *intf) if (ret < 0) return ret; =20 - phy_start(dev->net->phydev); - ret =3D lan78xx_resume(intf); + if (ret < 0) + return ret; =20 - return ret; + rtnl_lock(); + phylink_resume(dev->phylink); + rtnl_unlock(); + + return 0; } =20 static const struct usb_device_id products[] =3D { --=20 2.39.5 From nobody Thu Oct 9 08:54:04 2025 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24A971A5BAF for ; Wed, 18 Jun 2025 12:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750249571; cv=none; b=pzNPgoAPXIw43msTqt9HYkuukwo1cbJp72wAITyf68SX8wP7l0N0nJ+/BAA8HVhDwSKxd2fpYbGh+3+glZdF8cPC4/ANndR0a5nV1LCNZnLa+RZg0wK3bVlfZru3RV69/LNQpK+9CERvrna8xkLrxl30H033fhLB/KGhSSVbbXM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750249571; c=relaxed/simple; bh=IDD9v6cYS1E9fCQrM9ecA0zZ84fSUhOa0K+YmkkRkZw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ezRJSYgSHKRaw4tQrToK+GnQCFIQfxz85cmldRkbcWtbkKMdAUHat72V79lyuW7N6VprR5pWClW+QqaTGtLusVWOdOkOuX8qWHXeoscyI+qrCltL33bFAuHVKRPNDoKaPb5P/XygbitACFcsVJqqlKUJsbumt/8bRJZNL2cL49k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uRrrg-00007i-UW; Wed, 18 Jun 2025 14:26:04 +0200 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uRrrf-0048Uq-1r; Wed, 18 Jun 2025 14:26:03 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1uRrrf-00DFCy-1R; Wed, 18 Jun 2025 14:26:03 +0200 From: Oleksij Rempel To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Woojung Huh , Andrew Lunn , Russell King , Thangaraj Samynathan , Rengarajan Sundararajan Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Phil Elwell , Maxime Chevallier , Simon Horman Subject: [PATCH net-next v8 2/6] net: usb: lan78xx: Rename EVENT_LINK_RESET to EVENT_PHY_INT_ACK Date: Wed, 18 Jun 2025 14:25:58 +0200 Message-Id: <20250618122602.3156678-3-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618122602.3156678-1-o.rempel@pengutronix.de> References: <20250618122602.3156678-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The EVENT_LINK_RESET macro currently triggers deferred work after a PHY interrupt. Prior to PHYLINK conversion, this work included reconfiguring the MAC and PHY, effectively performing a 'link reset'. However, after porting the driver to the PHYLINK framework, the logic associated with this event now solely handles the acknowledgment of the PHY interrupt. The MAC and PHY reconfiguration is now managed by PHYLINK's dedicated callbacks. To accurately reflect its current, narrowed functionality, rename EVENT_LINK_RESET to EVENT_PHY_INT_ACK. Signed-off-by: Oleksij Rempel Reviewed-by: Russell King (Oracle) --- drivers/net/usb/lan78xx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 61b2a7c26f60..18402a3922a6 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -385,7 +385,7 @@ struct skb_data { /* skb->cb is one of these */ #define EVENT_RX_HALT 1 #define EVENT_RX_MEMORY 2 #define EVENT_STS_SPLIT 3 -#define EVENT_LINK_RESET 4 +#define EVENT_PHY_INT_ACK 4 #define EVENT_RX_PAUSED 5 #define EVENT_DEV_WAKING 6 #define EVENT_DEV_ASLEEP 7 @@ -1642,7 +1642,7 @@ static void lan78xx_status(struct lan78xx_net *dev, s= truct urb *urb) =20 if (intdata & INT_ENP_PHY_INT) { netif_dbg(dev, link, dev->net, "PHY INTR: 0x%08x\n", intdata); - lan78xx_defer_kevent(dev, EVENT_LINK_RESET); + lan78xx_defer_kevent(dev, EVENT_PHY_INT_ACK); =20 if (dev->domain_data.phyirq > 0) generic_handle_irq_safe(dev->domain_data.phyirq); @@ -3524,7 +3524,7 @@ static int lan78xx_stop(struct net_device *net) */ clear_bit(EVENT_TX_HALT, &dev->flags); clear_bit(EVENT_RX_HALT, &dev->flags); - clear_bit(EVENT_LINK_RESET, &dev->flags); + clear_bit(EVENT_PHY_INT_ACK, &dev->flags); clear_bit(EVENT_STAT_UPDATE, &dev->flags); =20 cancel_delayed_work_sync(&dev->wq); @@ -4448,10 +4448,10 @@ static void lan78xx_delayedwork(struct work_struct = *work) } } =20 - if (test_bit(EVENT_LINK_RESET, &dev->flags)) { + if (test_bit(EVENT_PHY_INT_ACK, &dev->flags)) { int ret =3D 0; =20 - clear_bit(EVENT_LINK_RESET, &dev->flags); + clear_bit(EVENT_PHY_INT_ACK, &dev->flags); ret =3D lan78xx_phy_int_ack(dev); if (ret) netdev_info(dev->net, "PHY INT ack failed (%pe)\n", --=20 2.39.5 From nobody Thu Oct 9 08:54:04 2025 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EE6E2951A0 for ; Wed, 18 Jun 2025 12:26:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750249573; cv=none; b=ay34i+SKVYIkW1qvd39jpaPzzB/tqwetcOm5nhmBLdXfhSQ/6SYepUAFHdC0+AXPhk7aRM07/ca2xjkOqMQ0UQErWNqb7hOxfMOeYMvitBpR2Zc+7zR90Ki61xSo4blx1dexq5gS02U8Wrf0PSKkEdrNd6/ShVw4JUkr1DrN/jA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750249573; c=relaxed/simple; bh=pq0r+fx7fW+75RtNymzq+3FY8EA8Ax2oxTXhGJHBHYw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ioxxIjGD+ggjBGRjp0SsdlW65g9OTU59r6LRCVwPG2iPm9yhgMHUIXkxDXw3082o+gt65hGOtiFTscivQtNWTkzVvhWohZt5RA98sU+rIOClYpuFUz+rZCb6Ok6tbX3btnkKvfdMxse6pHPFkZFdwgcSA46iaNqXCsTeGEwZbhQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uRrrg-00007j-UW; Wed, 18 Jun 2025 14:26:04 +0200 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uRrrf-0048Us-1t; Wed, 18 Jun 2025 14:26:03 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1uRrrf-00DFD8-1X; Wed, 18 Jun 2025 14:26:03 +0200 From: Oleksij Rempel To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Woojung Huh , Andrew Lunn , Russell King , Thangaraj Samynathan , Rengarajan Sundararajan Cc: Oleksij Rempel , Maxime Chevallier , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Phil Elwell , Simon Horman Subject: [PATCH net-next v8 3/6] net: usb: lan78xx: Use ethtool_op_get_link to reflect current link status Date: Wed, 18 Jun 2025 14:25:59 +0200 Message-Id: <20250618122602.3156678-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618122602.3156678-1-o.rempel@pengutronix.de> References: <20250618122602.3156678-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace the custom lan78xx_get_link implementation with the standard ethtool_op_get_link helper, which uses netif_carrier_ok to reflect the current link status accurately. Signed-off-by: Oleksij Rempel Reviewed-by: Maxime Chevallier Reviewed-by: Russell King (Oracle) --- drivers/net/usb/lan78xx.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 18402a3922a6..9bb1d2527d0c 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -1839,18 +1839,6 @@ static int lan78xx_set_eee(struct net_device *net, s= truct ethtool_keee *edata) return ret; } =20 -static u32 lan78xx_get_link(struct net_device *net) -{ - u32 link; - - mutex_lock(&net->phydev->lock); - phy_read_status(net->phydev); - link =3D net->phydev->link; - mutex_unlock(&net->phydev->lock); - - return link; -} - static void lan78xx_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info) { @@ -1970,7 +1958,7 @@ lan78xx_get_regs(struct net_device *netdev, struct et= htool_regs *regs, } =20 static const struct ethtool_ops lan78xx_ethtool_ops =3D { - .get_link =3D lan78xx_get_link, + .get_link =3D ethtool_op_get_link, .nway_reset =3D phy_ethtool_nway_reset, .get_drvinfo =3D lan78xx_get_drvinfo, .get_msglevel =3D lan78xx_get_msglevel, --=20 2.39.5 From nobody Thu Oct 9 08:54:04 2025 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8926C27FB06 for ; Wed, 18 Jun 2025 12:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750249572; cv=none; b=X3N4xwqY0Ge046GCYR8rVBvFC+DzYlZkAmavfTSFs53JdAosfqHUHz0yeQfFl0PaS+70gwVCG8LJW7S9j2HUbXaPl9ykDy3mvYknWFWfkAuAVjhOsMFmzpnIKGSb2TiByF6WxVk9jv5EKWEYKUADAEgfY3gUj1DAxHqcz1za2o0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750249572; c=relaxed/simple; bh=K3ZwQtt6dtJ5cPaEh2Q0U2SfPQuD5sf8qnPOtYK5aZs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iPPpSFql8ayY9ZMOz7XcPGS2r5JRLaxoxbZ6pTSUKvTP8HNvhiY9FaivH/QT3DuwVdqV6/vx3ACrvmSYrQbV1ym3LRxii5dV2f7JS6OKJwLf18Oh2G/UZn663uz5huReQOw48wkjUrALBC39RXxUNuH7N3KW9P1OOgtamXZD2Lk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uRrrg-00007k-UV; Wed, 18 Jun 2025 14:26:04 +0200 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uRrrf-0048Uu-21; Wed, 18 Jun 2025 14:26:03 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1uRrrf-00DFDI-1d; Wed, 18 Jun 2025 14:26:03 +0200 From: Oleksij Rempel To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Woojung Huh , Andrew Lunn , Russell King , Thangaraj Samynathan , Rengarajan Sundararajan Cc: Oleksij Rempel , Maxime Chevallier , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Phil Elwell , Simon Horman Subject: [PATCH net-next v8 4/6] net: usb: lan78xx: port link settings to phylink API Date: Wed, 18 Jun 2025 14:26:00 +0200 Message-Id: <20250618122602.3156678-5-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618122602.3156678-1-o.rempel@pengutronix.de> References: <20250618122602.3156678-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Maxime Chevallier Reviewed-by: Russell King (Oracle) --- changes v4: - add explanation why we do not care about usb_autopm in this functions --- drivers/net/usb/lan78xx.c | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 9bb1d2527d0c..8df0a2323fb9 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -1866,46 +1866,16 @@ static int lan78xx_get_link_ksettings(struct net_de= vice *net, struct ethtool_link_ksettings *cmd) { struct lan78xx_net *dev =3D netdev_priv(net); - struct phy_device *phydev =3D net->phydev; - int ret; - - ret =3D usb_autopm_get_interface(dev->intf); - if (ret < 0) - return ret; =20 - phy_ethtool_ksettings_get(phydev, cmd); - - usb_autopm_put_interface(dev->intf); - - return ret; + return phylink_ethtool_ksettings_get(dev->phylink, cmd); } =20 static int lan78xx_set_link_ksettings(struct net_device *net, const struct ethtool_link_ksettings *cmd) { struct lan78xx_net *dev =3D netdev_priv(net); - struct phy_device *phydev =3D net->phydev; - int ret =3D 0; - int temp; - - ret =3D usb_autopm_get_interface(dev->intf); - if (ret < 0) - return ret; - - /* change speed & duplex */ - ret =3D phy_ethtool_ksettings_set(phydev, cmd); =20 - if (!cmd->base.autoneg) { - /* force link down */ - temp =3D phy_read(phydev, MII_BMCR); - phy_write(phydev, MII_BMCR, temp | BMCR_LOOPBACK); - mdelay(1); - phy_write(phydev, MII_BMCR, temp); - } - - usb_autopm_put_interface(dev->intf); - - return ret; + return phylink_ethtool_ksettings_set(dev->phylink, cmd); } =20 static void lan78xx_get_pause(struct net_device *net, --=20 2.39.5 From nobody Thu Oct 9 08:54:04 2025 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24A3F145FE0 for ; Wed, 18 Jun 2025 12:26:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750249572; cv=none; b=Ut7PTff/10Y15uhygOjA593BETMI7yIy1iMmVuypWeQgvBPYltbgYDpigHncHCFG9iFcnq+NAu2J6UkYBRxJ9S/E22VLHY3ggWa9QToFQ7UKL2Wjr0jXIBWjGva/TJ/fFbgzcKQJtF6DXP7cl9AbyLPug1LDKS/1aRAy6y83Jv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750249572; c=relaxed/simple; bh=fSTCWsuQ4XlzfbGhxcmTsVbfyzpWvfkwwQQU+46fHmg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=bD7pLar7czIm/M6IZ+EdhI/oeaSps1KXV19xbouahwA/lxNa1OynGE3+j41BAq5NKpcwe83fbVaPZlawLYpQN/i4QQgUGVUPmhBf39LG4ic037clo7753teGIKUCEmyunMMuNSw2x65mHFKxIOlx16/4FVC8nqFyk3qZ9Sl6pYs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uRrrg-00007l-UV; Wed, 18 Jun 2025 14:26:04 +0200 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uRrrf-0048Uw-23; Wed, 18 Jun 2025 14:26:03 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1uRrrf-00DFDT-1l; Wed, 18 Jun 2025 14:26:03 +0200 From: Oleksij Rempel To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Woojung Huh , Andrew Lunn , Russell King , Thangaraj Samynathan , Rengarajan Sundararajan Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Phil Elwell , Maxime Chevallier , Simon Horman Subject: [PATCH net-next v8 5/6] net: usb: lan78xx: Integrate EEE support with phylink LPI API Date: Wed, 18 Jun 2025 14:26:01 +0200 Message-Id: <20250618122602.3156678-6-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618122602.3156678-1-o.rempel@pengutronix.de> References: <20250618122602.3156678-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Refactor Energy-Efficient Ethernet (EEE) support in the LAN78xx driver to fully integrate with the phylink Low Power Idle (LPI) API. This includes: - Replacing direct calls to `phy_ethtool_get_eee` and `phy_ethtool_set_eee` with `phylink_ethtool_get_eee` and `phylink_ethtool_set_eee`. - Implementing `.mac_enable_tx_lpi` and `.mac_disable_tx_lpi` to control LPI transitions via phylink. - Configuring `lpi_timer_default` to align with recommended values from LAN7800 documentation. - ensure EEE is disabled on controller reset Signed-off-by: Oleksij Rempel Reviewed-by: Russell King (Oracle) --- changes v6: - clarify in lan78xx_mac_eee_enable() comment that MAC_CR_EEE_EN can be modified without disabling TX/RX. I can't recall where the requirement to disable TX/RX came from; may have confused it with nearby MAC_CR bits that require this kind of configuration changes v5: - remove redundant error prints changes v2: - use latest PHYlink TX_LPI API --- drivers/net/usb/lan78xx.c | 123 ++++++++++++++++++++++++-------------- 1 file changed, 79 insertions(+), 44 deletions(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 8df0a2323fb9..3bff1e72a89f 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -1789,54 +1789,15 @@ static int lan78xx_set_wol(struct net_device *netde= v, static int lan78xx_get_eee(struct net_device *net, struct ethtool_keee *ed= ata) { struct lan78xx_net *dev =3D netdev_priv(net); - struct phy_device *phydev =3D net->phydev; - int ret; - u32 buf; - - ret =3D usb_autopm_get_interface(dev->intf); - if (ret < 0) - return ret; - - ret =3D phy_ethtool_get_eee(phydev, edata); - if (ret < 0) - goto exit; =20 - ret =3D lan78xx_read_reg(dev, MAC_CR, &buf); - if (buf & MAC_CR_EEE_EN_) { - /* EEE_TX_LPI_REQ_DLY & tx_lpi_timer are same uSec unit */ - ret =3D lan78xx_read_reg(dev, EEE_TX_LPI_REQ_DLY, &buf); - edata->tx_lpi_timer =3D buf; - } else { - edata->tx_lpi_timer =3D 0; - } - - ret =3D 0; -exit: - usb_autopm_put_interface(dev->intf); - - return ret; + return phylink_ethtool_get_eee(dev->phylink, edata); } =20 static int lan78xx_set_eee(struct net_device *net, struct ethtool_keee *ed= ata) { struct lan78xx_net *dev =3D netdev_priv(net); - int ret; - u32 buf; - - ret =3D usb_autopm_get_interface(dev->intf); - if (ret < 0) - return ret; =20 - ret =3D phy_ethtool_set_eee(net->phydev, edata); - if (ret < 0) - goto out; - - buf =3D (u32)edata->tx_lpi_timer; - ret =3D lan78xx_write_reg(dev, EEE_TX_LPI_REQ_DLY, buf); -out: - usb_autopm_put_interface(dev->intf); - - return ret; + return phylink_ethtool_set_eee(dev->phylink, edata); } =20 static void lan78xx_get_drvinfo(struct net_device *net, @@ -2557,10 +2518,62 @@ static void lan78xx_mac_link_up(struct phylink_conf= ig *config, ERR_PTR(ret)); } =20 +/** + * lan78xx_mac_eee_enable - Enable or disable MAC-side EEE support + * @dev: LAN78xx device + * @enable: true to enable EEE, false to disable + * + * This function sets or clears the MAC_CR_EEE_EN_ bit to control Energy + * Efficient Ethernet (EEE) operation. According to current understanding + * of the LAN7800 documentation, this bit can be modified while TX and RX + * are enabled. No explicit requirement was found to disable data paths + * before changing this bit. + * + * Return: 0 on success or a negative error code + */ +static int lan78xx_mac_eee_enable(struct lan78xx_net *dev, bool enable) +{ + u32 mac_cr =3D 0; + + if (enable) + mac_cr |=3D MAC_CR_EEE_EN_; + + return lan78xx_update_reg(dev, MAC_CR, MAC_CR_EEE_EN_, mac_cr); +} + +static void lan78xx_mac_disable_tx_lpi(struct phylink_config *config) +{ + struct net_device *net =3D to_net_dev(config->dev); + struct lan78xx_net *dev =3D netdev_priv(net); + + lan78xx_mac_eee_enable(dev, false); +} + +static int lan78xx_mac_enable_tx_lpi(struct phylink_config *config, u32 ti= mer, + bool tx_clk_stop) +{ + struct net_device *net =3D to_net_dev(config->dev); + struct lan78xx_net *dev =3D netdev_priv(net); + int ret; + + /* Software should only change this field when Energy Efficient + * Ethernet Enable (EEEEN) is cleared. We ensure that by clearing + * EEEEN during probe, and phylink itself guarantees that + * mac_disable_tx_lpi() will have been previously called. + */ + ret =3D lan78xx_write_reg(dev, EEE_TX_LPI_REQ_DLY, timer); + if (ret < 0) + return ret; + + return lan78xx_mac_eee_enable(dev, true); +} + static const struct phylink_mac_ops lan78xx_phylink_mac_ops =3D { .mac_config =3D lan78xx_mac_config, .mac_link_down =3D lan78xx_mac_link_down, .mac_link_up =3D lan78xx_mac_link_up, + .mac_disable_tx_lpi =3D lan78xx_mac_disable_tx_lpi, + .mac_enable_tx_lpi =3D lan78xx_mac_enable_tx_lpi, }; =20 /** @@ -2756,12 +2769,36 @@ static int lan78xx_phylink_setup(struct lan78xx_net= *dev) pc->mac_capabilities =3D MAC_SYM_PAUSE | MAC_ASYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD; pc->mac_managed_pm =3D true; + pc->lpi_capabilities =3D MAC_100FD | MAC_1000FD; + /* + * Default TX LPI (Low Power Idle) request delay count is set to 50us. + * + * Source: LAN7800 Documentation, DS00001992H, Section 15.1.57, Page 204. + * + * Reasoning: + * According to the application note in the LAN7800 documentation, a + * zero delay may negatively impact the TX data path=E2=80=99s ability to + * support Gigabit operation. A value of 50us is recommended as a + * reasonable default when the part operates at Gigabit speeds, + * balancing stability and power efficiency in EEE mode. This delay can + * be increased based on performance testing, as EEE is designed for + * scenarios with mostly idle links and occasional bursts of full + * bandwidth transmission. The goal is to ensure reliable Gigabit + * performance without overly aggressive power optimization during + * inactive periods. + */ + pc->lpi_timer_default =3D 50; + pc->eee_enabled_default =3D true; =20 if (dev->chipid =3D=3D ID_REV_CHIP_ID_7801_) phy_interface_set_rgmii(pc->supported_interfaces); else __set_bit(PHY_INTERFACE_MODE_GMII, pc->supported_interfaces); =20 + memcpy(dev->phylink_config.lpi_interfaces, + dev->phylink_config.supported_interfaces, + sizeof(dev->phylink_config.lpi_interfaces)); + phylink =3D phylink_create(pc, dev->net->dev.fwnode, dev->interface, &lan78xx_phylink_mac_ops); if (IS_ERR(phylink)) @@ -2827,8 +2864,6 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) goto phylink_uninit; } =20 - phy_support_eee(phydev); - ret =3D lan78xx_configure_leds_from_dt(dev, phydev); if (ret < 0) goto phylink_uninit; @@ -3333,7 +3368,7 @@ static int lan78xx_reset(struct lan78xx_net *dev) if (ret < 0) return ret; =20 - buf &=3D ~(MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_); + buf &=3D ~(MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_ | MAC_CR_EEE_EN_); =20 /* LAN7801 only has RGMII mode */ if (dev->chipid =3D=3D ID_REV_CHIP_ID_7801_) --=20 2.39.5 From nobody Thu Oct 9 08:54:04 2025 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6C7227FD62 for ; Wed, 18 Jun 2025 12:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750249572; cv=none; b=qQCItbGOz1DwUaPLC6RPtcuz+p+yJIpE3cOVEjyT+JqXJ/vhQdC/tFVIXsb94qakZ0t7QTKZHoOhzSYFttg0aaUMPEn9Ns8KM/QAGxvYkiMtwGhHrQeqRj/vJHqX6LLfYqsqcy6VDrKZLU1Evl0GfN+/e0O5GKBSAapLNqWAlhA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750249572; c=relaxed/simple; bh=WaLWBuyhdxIx9ePl0Vx05HloDG9+eCl0n5cAp+EG+64=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d55NaIy7LIW4wJboyOny7TA1yTG9vGg6jXMcERslhLL86CdKjtpQBRHJeLnSjuLtUmjuVyYwZV+xOazC3vRb4dl29WW/xP1gtQlCqiyTdoeiX7dzlgA0EVaSyuf0qZg3270TMaQ53zcKU8dirfncxI5MuoBS4vJM0uueeuiBDmE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uRrrg-00007m-UX; Wed, 18 Jun 2025 14:26:04 +0200 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uRrrf-0048Ux-2F; Wed, 18 Jun 2025 14:26:03 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1uRrrf-00DFDd-1q; Wed, 18 Jun 2025 14:26:03 +0200 From: Oleksij Rempel To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Woojung Huh , Andrew Lunn , Russell King , Thangaraj Samynathan , Rengarajan Sundararajan Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Phil Elwell , Maxime Chevallier , Simon Horman Subject: [PATCH net-next v8 6/6] net: usb: lan78xx: remove unused struct members Date: Wed, 18 Jun 2025 14:26:02 +0200 Message-Id: <20250618122602.3156678-7-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618122602.3156678-1-o.rempel@pengutronix.de> References: <20250618122602.3156678-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Remove unused members from struct lan78xx_net, including: driver_priv suspend_count mdix_ctrl These fields are no longer used in the driver and can be safely removed as part of a cleanup. Signed-off-by: Oleksij Rempel Reviewed-by: Russell King (Oracle) --- changes v6: - drop only those fields not already removed in previous patches - align patch structure with review feedback from Russell King --- drivers/net/usb/lan78xx.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 3bff1e72a89f..f00284c9ad34 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -414,7 +414,6 @@ struct lan78xx_net { struct net_device *net; struct usb_device *udev; struct usb_interface *intf; - void *driver_priv; =20 unsigned int tx_pend_data_len; size_t n_tx_urbs; @@ -449,15 +448,12 @@ struct lan78xx_net { unsigned long flags; =20 wait_queue_head_t *wait; - unsigned char suspend_count; =20 unsigned int maxpacket; struct timer_list stat_monitor; =20 unsigned long data[5]; =20 - u8 mdix_ctrl; - u32 chipid; u32 chiprev; struct mii_bus *mdiobus; --=20 2.39.5