From: "Jakub Vaněk" <linuxtardis@gmail.com>
To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Cc: "Andrew Lunn" <andrew@lunn.ch>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Russell King" <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
Frank <Frank.Sae@motor-comm.com>,
"Sai Krishna" <saikrishnag@marvell.com>,
"Daniel Golle" <daniel@makrotopia.org>,
"Jakub Vaněk" <linuxtardis@gmail.com>
Subject: [PATCH net-next v2 3/5] net: phy: Support PHY fixups on Clause 45 PHYs
Date: Sun, 1 Mar 2026 00:22:39 +0100 [thread overview]
Message-ID: <20260228232241.1274236-4-linuxtardis@gmail.com> (raw)
In-Reply-To: <20260228232241.1274236-1-linuxtardis@gmail.com>
For Clause 45 PHYs, phydev->phy_id is zero and therefore cannot be used
to match PHY fixups. Clause 45 PHYs instead have per-MMD identifiers
stored in phydev->c45_ids. Extend phy_needs_fixup() to match against
these IDs by reusing the relevant matching logic from
genphy_match_phy_device().
Signed-off-by: Jakub Vaněk <linuxtardis@gmail.com>
---
drivers/net/phy/phy_device.c | 56 ++++++++++++++++++++++++------------
1 file changed, 37 insertions(+), 19 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 02fc0133428d..db187d370eaa 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -472,13 +472,48 @@ int phy_register_fixup_for_id(const char *bus_id,
}
EXPORT_SYMBOL(phy_register_fixup_for_id);
+/**
+ * genphy_check_device_id - match a PHY device against a given ID
+ * @phydev: target phy_device struct
+ * @phy_id: expected PHY ID
+ * @phy_id_mask: the PHY ID mask, set bits are significant in matching
+ *
+ * Description: Checks whether the given PHY device matches the specified
+ * ID. For Clause 45 PHYs, iterates over the available device identifiers
+ * and compares them against the expected PHY ID, applying the provided mask.
+ * For Clause 22 PHYs, a direct ID comparison is performed.
+ *
+ * Return: true if the PHY device matches the masked ID, false otherwise.
+ */
+static bool genphy_check_device_id(struct phy_device *phydev,
+ u32 phy_id, u32 phy_id_mask)
+{
+ if (phydev->is_c45) {
+ const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids);
+ int i;
+
+ for (i = 1; i < num_ids; i++) {
+ if (phydev->c45_ids.device_ids[i] == 0xffffffff)
+ continue;
+
+ if (phy_id_compare(phydev->c45_ids.device_ids[i],
+ phy_id, phy_id_mask))
+ return true;
+ }
+
+ return false;
+ }
+
+ return phy_id_compare(phydev->phy_id, phy_id, phy_id_mask);
+}
+
static bool phy_needs_fixup(struct phy_device *phydev, struct phy_fixup *fixup)
{
if (!strcmp(fixup->bus_id, phydev_name(phydev)))
return true;
if (fixup->phy_uid_mask &&
- phy_id_compare(phydev->phy_id, fixup->phy_uid, fixup->phy_uid_mask))
+ genphy_check_device_id(phydev, fixup->phy_uid, fixup->phy_uid_mask))
return true;
return false;
@@ -522,24 +557,7 @@ static int phy_scan_fixups(struct phy_device *phydev)
int genphy_match_phy_device(struct phy_device *phydev,
const struct phy_driver *phydrv)
{
- if (phydev->is_c45) {
- const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids);
- int i;
-
- for (i = 1; i < num_ids; i++) {
- if (phydev->c45_ids.device_ids[i] == 0xffffffff)
- continue;
-
- if (phy_id_compare(phydev->c45_ids.device_ids[i],
- phydrv->phy_id, phydrv->phy_id_mask))
- return 1;
- }
-
- return 0;
- }
-
- return phy_id_compare(phydev->phy_id, phydrv->phy_id,
- phydrv->phy_id_mask);
+ return genphy_check_device_id(phydev, phydrv->phy_id, phydrv->phy_id_mask);
}
EXPORT_SYMBOL_GPL(genphy_match_phy_device);
--
2.43.0
next prev parent reply other threads:[~2026-02-28 23:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-28 23:22 [PATCH net-next v2 0/5] net: phy: Disable MDIO broadcast address on YT8821 Jakub Vaněk
2026-02-28 23:22 ` [PATCH net-next v2 1/5] net: mdiobus: Scan buses in reverse order (31 -> 0) Jakub Vaněk
2026-03-01 15:11 ` Andrew Lunn
2026-03-01 17:03 ` Russell King (Oracle)
2026-03-01 17:24 ` Jakub Vaněk
2026-02-28 23:22 ` [PATCH net-next v2 2/5] of: mdio: Scan PHY address 0 last Jakub Vaněk
2026-02-28 23:22 ` Jakub Vaněk [this message]
2026-02-28 23:22 ` [PATCH net-next v2 4/5] net: phy: Add infrastructure for PHY address 0 fixups Jakub Vaněk
2026-02-28 23:22 ` [PATCH net-next v2 5/5] net: phy: motorcomm: yt8821: Disable MDIO broadcast Jakub Vaněk
2026-03-01 2:43 ` kernel test robot
2026-03-01 16:06 ` [PATCH net-next v2 0/5] net: phy: Disable MDIO broadcast address on YT8821 Andrew Lunn
2026-03-01 17:07 ` Russell King (Oracle)
2026-03-01 17:15 ` Jakub Vaněk
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=20260228232241.1274236-4-linuxtardis@gmail.com \
--to=linuxtardis@gmail.com \
--cc=Frank.Sae@motor-comm.com \
--cc=andrew@lunn.ch \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saikrishnag@marvell.com \
/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