From: <Thangaraj.S@microchip.com>
To: <andrew+netdev@lunn.ch>, <rmk+kernel@armlinux.org.uk>,
<davem@davemloft.net>, <Rengarajan.S@microchip.com>,
<Woojung.Huh@microchip.com>, <pabeni@redhat.com>,
<o.rempel@pengutronix.de>, <edumazet@google.com>,
<kuba@kernel.org>
Cc: <phil@raspberrypi.org>, <kernel@pengutronix.de>,
<horms@kernel.org>, <linux-kernel@vger.kernel.org>,
<netdev@vger.kernel.org>, <UNGLinuxDriver@microchip.com>,
<maxime.chevallier@bootlin.com>
Subject: Re: [PATCH net-next v8 3/7] net: usb: lan78xx: refactor PHY init to separate detection and MAC configuration
Date: Tue, 6 May 2025 05:31:30 +0000 [thread overview]
Message-ID: <c1b45ed298748aafbe3557d637707820bc37e2d2.camel@microchip.com> (raw)
In-Reply-To: <20250505084341.824165-4-o.rempel@pengutronix.de>
Hi Oleksj.
Thanks for the patch.
On Mon, 2025-05-05 at 10:43 +0200, Oleksij Rempel wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> Split out PHY detection into lan78xx_get_phy() and MAC-side setup
> into
> lan78xx_mac_prepare_for_phy(), making the main lan78xx_phy_init()
> cleaner
> and easier to follow.
>
> This improves separation of concerns and prepares the code for a
> future
> transition to phylink. Fixed PHY registration and interface selection
> are now handled in lan78xx_get_phy(), while MAC-side delay
> configuration
> is done in lan78xx_mac_prepare_for_phy().
>
> The fixed PHY fallback is preserved for setups like EVB-KSZ9897-1,
> where LAN7801 connects directly to a KSZ switch without a standard
> PHY
> or device tree support.
>
> No functional changes intended.
>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
> changes v6:
> - this patch is added in v6
> ---
> drivers/net/usb/lan78xx.c | 174 ++++++++++++++++++++++++++++------
> ----
> 1 file changed, 128 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index 9c0658227bde..7f1ecc415d53 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -2508,53 +2508,145 @@ static void lan78xx_remove_irq_domain(struct
> lan78xx_net *dev)
> dev->domain_data.irqdomain = NULL;
> }
>
>
> static int lan78xx_phy_init(struct lan78xx_net *dev)
> @@ -2564,31 +2656,13 @@ static int lan78xx_phy_init(struct
> lan78xx_net *dev)
> u32 mii_adv;
> struct phy_device *phydev;
>
> - switch (dev->chipid) {
> - case ID_REV_CHIP_ID_7801_:
> - phydev = lan7801_phy_init(dev);
> - if (IS_ERR(phydev)) {
> - netdev_err(dev->net, "lan7801: failed to init
> PHY: %pe\n",
> - phydev);
> - return PTR_ERR(phydev);
> - }
> - break;
> -
> - case ID_REV_CHIP_ID_7800_:
> - case ID_REV_CHIP_ID_7850_:
> - phydev = phy_find_first(dev->mdiobus);
> - if (!phydev) {
> - netdev_err(dev->net, "no PHY found\n");
> - return -ENODEV;
> - }
> - phydev->is_internal = true;
> - dev->interface = PHY_INTERFACE_MODE_GMII;
> - break;
> + phydev = lan78xx_get_phy(dev);
> + if (IS_ERR(phydev))
> + return PTR_ERR(phydev);
>
> - default:
> - netdev_err(dev->net, "Unknown CHIP ID found\n");
> - return -ENODEV;
> - }
> + ret = lan78xx_mac_prepare_for_phy(dev);
> + if (ret < 0)
> + goto free_phy;
>
> /* if phyirq is not set, use polling mode in phylib */
> if (dev->domain_data.phyirq > 0)
> @@ -2662,6 +2736,14 @@ static int lan78xx_phy_init(struct lan78xx_net
> *dev)
> dev->fc_autoneg = phydev->autoneg;
>
> return 0;
> +
> +free_phy:
> + if (phy_is_pseudo_fixed_link(phydev)) {
> + fixed_phy_unregister(phydev);
> + phy_device_free(phydev);
> + }
> +
> + return ret;
> }
Could see as per implementation, this case might hit on normal phy
other than fixed-phy too. Should we not add any cleanup for phydev
here?
Thanks,
Thangaraj Samynathan
>
> static int lan78xx_set_rx_max_frame_length(struct lan78xx_net *dev,
> int size)
> --
> 2.39.5
>
next prev parent reply other threads:[~2025-05-06 5:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-05 8:43 [PATCH net-next v8 0/7] lan78xx: preparation for PHYLINK conversion Oleksij Rempel
2025-05-05 8:43 ` [PATCH net-next v8 1/7] net: usb: lan78xx: Improve error handling in PHY initialization Oleksij Rempel
2025-05-07 3:56 ` Thangaraj.S
2025-05-05 8:43 ` [PATCH net-next v8 2/7] net: usb: lan78xx: remove explicit check for missing PHY driver Oleksij Rempel
2025-05-07 3:57 ` Thangaraj.S
2025-05-05 8:43 ` [PATCH net-next v8 3/7] net: usb: lan78xx: refactor PHY init to separate detection and MAC configuration Oleksij Rempel
2025-05-06 5:31 ` Thangaraj.S [this message]
2025-05-06 10:13 ` Oleksij Rempel
2025-05-07 3:58 ` Thangaraj.S
2025-05-05 8:43 ` [PATCH net-next v8 4/7] net: usb: lan78xx: move LED DT configuration to helper Oleksij Rempel
2025-05-07 3:59 ` Thangaraj.S
2025-05-05 8:43 ` [PATCH net-next v8 5/7] net: usb: lan78xx: Extract PHY interrupt acknowledgment " Oleksij Rempel
2025-05-07 3:59 ` Thangaraj.S
2025-05-05 8:43 ` [PATCH net-next v8 6/7] net: usb: lan78xx: Refactor USB link power configuration into helper Oleksij Rempel
2025-05-05 8:43 ` [PATCH net-next v8 7/7] net: usb: lan78xx: Extract flow control configuration to helper Oleksij Rempel
2025-05-07 12:00 ` [PATCH net-next v8 0/7] lan78xx: preparation for PHYLINK conversion patchwork-bot+netdevbpf
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=c1b45ed298748aafbe3557d637707820bc37e2d2.camel@microchip.com \
--to=thangaraj.s@microchip.com \
--cc=Rengarajan.S@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=Woojung.Huh@microchip.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=phil@raspberrypi.org \
--cc=rmk+kernel@armlinux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®