From: Joel <joelcrouch@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Joel <joelcrouch@gmail.com>
Subject: [PATCH v2 2/2] sungem: validate BCM5411 PHY register reads
Date: Fri, 24 Apr 2026 03:33:48 +0000 [thread overview]
Message-ID: <20260424033348.1917-3-joelcrouch@gmail.com> (raw)
In-Reply-To: <20260424033348.1917-1-joelcrouch@gmail.com>
Check for -EIO and 0xffff during initialization to prevent silent failures. Add error logging to gem_init_phy to report failures.
---
drivers/net/ethernet/sun/sungem.c | 8 ++++++--
drivers/net/sungem_phy.c | 7 ++++++-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/sungem.c
index 8e69d917d..525aba527 100644
--- a/drivers/net/ethernet/sun/sungem.c
+++ b/drivers/net/ethernet/sun/sungem.c
@@ -1707,8 +1707,12 @@ static void gem_init_phy(struct gem *gp)
sungem_phy_probe(&gp->phy_mii, gp->mii_phy_addr);
/* Init PHY */
- if (gp->phy_mii.def && gp->phy_mii.def->ops->init)
- gp->phy_mii.def->ops->init(&gp->phy_mii);
+ if (gp->phy_mii.def && gp->phy_mii.def->ops->init) {
+ int err = gp->phy_mii.def->ops->init(&gp->phy_mii);
+
+ if (err)
+ netdev_err(gp->dev, "PHY init failed: %d\n", err);
+ }
} else {
gem_pcs_reset(gp);
gem_pcs_reinit_adv(gp);
diff --git a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c
index 44cbe1938..ec8800c93 100644
--- a/drivers/net/sungem_phy.c
+++ b/drivers/net/sungem_phy.c
@@ -296,7 +296,12 @@ static int bcm5411_init(struct mii_phy *phy)
sungem_phy_write(phy, MII_BMCR, BMCR_RESET);
sungem_phy_write(phy, MII_BMCR, 0x1340);
- data = sungem_phy_read(phy, MII_BCM5400_GB_CONTROL);
+ val = sungem_phy_read(phy, MII_BCM5400_GB_CONTROL);
+
+ if (val < 0 || val == 0xffff)
+ return -EIO;
+
+ data = (u16)val;
data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP;
sungem_phy_write(phy, MII_BCM5400_GB_CONTROL, data);
--
2.43.0
next prev parent reply other threads:[~2026-04-24 3:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 3:33 [PATCH v2 0/2] sungem: PHY initialization fixes and style cleanup Joel
2026-04-24 3:33 ` [PATCH v2 1/2] sungem: fix pointer formatting and indentation Joel
2026-04-24 3:33 ` Joel [this message]
2026-04-24 3:45 ` [PATCH v2 2/2] sungem: validate BCM5411 PHY register reads Andrew Lunn
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=20260424033348.1917-3-joelcrouch@gmail.com \
--to=joelcrouch@gmail.com \
--cc=andrew@lunn.ch \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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