Re: [net-next PATCH v2 1/2] net: phy: introduce phy_id_compare_vendor() PHY ID helper

From
Andrew Lunn <andrew@lunn.ch>
Date
2025-08-24 16:08:42
Also in
lkml
Reply to
Christian Marangi, 2025-08-23
On Sat, Aug 23, 2025 at 03:44:28PM +0200, Christian Marangi wrote:
Introduce phy_id_compare_vendor() PHY ID helper to compare a PHY ID with
the PHY ID Vendor using the generic PHY ID Vendor mask.

While at it also rework the PHY_ID_MATCH macro and move the mask to
dedicated define so that PHY driver can make use of the mask if needed.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Hi Christian

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
quoted hunk ↗ jump to hunk
+/**
+ * phy_id_compare_vendor - compare @id with @vendor mask
+ * @id: PHY ID
+ * @vendor_mask: PHY Vendor mask
+ *
+ * Return: true if the bits from @id match @vendor using the
+ *	   generic PHY Vendor mask.
+ */
+static inline bool phy_id_compare_vendor(u32 id, u32 vendor_mask)
+{
+	return phy_id_compare(id, vendor_mask, PHY_ID_MATCH_VENDOR_MASK);
+}
+
broadcom.c:	if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 ||
broadcom.c:	    BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) {
broadcom.c:	if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM57780) {
broadcom.c:	if ((BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 ||
broadcom.c:	     BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) &&
broadcom.c:		if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54210E ||
broadcom.c:		    BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810 ||
broadcom.c:		    BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54811)
broadcom.c:	if ((BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 ||
broadcom.c:	     BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) &&

It looks like there is a use case of phy_id_compare_model(), if you
feel like adding it.

	Andrew
Thread (5 messages) 5 messages, 3 authors, last reply 2025-08-27
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help