From: Dan Carpenter <dan.carpenter@linaro.org>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: kernel-janitors@vger.kernel.org
Subject: [bug report] net: usb: lan78xx: refactor PHY init to separate detection and MAC configuration
Date: Fri, 9 May 2025 12:03:26 +0300 [thread overview]
Message-ID: <aB3E3qDVOHu6zBI-@stanley.mountain> (raw)
Hello Oleksij Rempel,
Commit d39f339d2603 ("net: usb: lan78xx: refactor PHY init to
separate detection and MAC configuration") from May 5, 2025
(linux-next), leads to the following Smatch static checker warning:
drivers/net/usb/lan78xx.c:2842 lan78xx_phy_init()
warn: missing unwind goto?
drivers/net/usb/lan78xx.c
2805 static int lan78xx_phy_init(struct lan78xx_net *dev)
2806 {
2807 __ETHTOOL_DECLARE_LINK_MODE_MASK(fc) = { 0, };
2808 int ret;
2809 u32 mii_adv;
2810 struct phy_device *phydev;
2811
2812 phydev = lan78xx_get_phy(dev);
2813 if (IS_ERR(phydev))
2814 return PTR_ERR(phydev);
2815
2816 ret = lan78xx_mac_prepare_for_phy(dev);
2817 if (ret < 0)
2818 goto free_phy;
2819
2820 /* if phyirq is not set, use polling mode in phylib */
2821 if (dev->domain_data.phyirq > 0)
2822 phydev->irq = dev->domain_data.phyirq;
2823 else
2824 phydev->irq = PHY_POLL;
2825 netdev_dbg(dev->net, "phydev->irq = %d\n", phydev->irq);
2826
2827 /* set to AUTOMDIX */
2828 phydev->mdix = ETH_TP_MDI_AUTO;
2829
2830 ret = phy_connect_direct(dev->net, phydev,
2831 lan78xx_link_status_change,
2832 dev->interface);
2833 if (ret) {
2834 netdev_err(dev->net, "can't attach PHY to %s\n",
2835 dev->mdiobus->id);
2836 if (dev->chipid == ID_REV_CHIP_ID_7801_) {
2837 if (phy_is_pseudo_fixed_link(phydev)) {
2838 fixed_phy_unregister(phydev);
2839 phy_device_free(phydev);
2840 }
2841 }
Why does this error path only cleanup for ID_REV_CHIP_ID_7801_ where the
others do it unconditionally?
--> 2842 return -EIO;
2843 }
2844
2845 /* MAC doesn't support 1000T Half */
2846 phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
2847
2848 /* support both flow controls */
2849 dev->fc_request_control = (FLOW_CTRL_RX | FLOW_CTRL_TX);
2850 linkmode_clear_bit(ETHTOOL_LINK_MODE_Pause_BIT,
2851 phydev->advertising);
2852 linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
2853 phydev->advertising);
2854 mii_adv = (u32)mii_advertise_flowctrl(dev->fc_request_control);
2855 mii_adv_to_linkmode_adv_t(fc, mii_adv);
2856 linkmode_or(phydev->advertising, fc, phydev->advertising);
2857
2858 phy_support_eee(phydev);
2859
2860 ret = lan78xx_configure_leds_from_dt(dev, phydev);
2861 if (ret)
2862 goto free_phy;
2863
2864 genphy_config_aneg(phydev);
2865
2866 dev->fc_autoneg = phydev->autoneg;
2867
2868 return 0;
2869
2870 free_phy:
2871 if (phy_is_pseudo_fixed_link(phydev)) {
2872 fixed_phy_unregister(phydev);
2873 phy_device_free(phydev);
2874 }
2875
2876 return ret;
2877 }
regards,
dan carpenter
next reply other threads:[~2025-05-09 9:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-09 9:03 Dan Carpenter [this message]
2025-05-09 12:43 ` [bug report] net: usb: lan78xx: refactor PHY init to separate detection and MAC configuration Oleksij Rempel
2025-05-09 12:54 ` Dan Carpenter
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=aB3E3qDVOHu6zBI-@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
/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.