]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: stmmac: use FIELD_GET() for version register
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Wed, 29 Oct 2025 00:03:31 +0000 (00:03 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 30 Oct 2025 00:18:22 +0000 (17:18 -0700)
Provide field definitions in common.h, and use these with FIELD_GET()
to extract the fields from the version register.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Tested-by: Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1vDtf1-0000000CCCF-0uUV@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/common.h
drivers/net/ethernet/stmicro/stmmac/hwif.c

index 553a8897b005b121f2cf595ac9143d4fb1e319cb..27083af5456832afba3154fa677f80c2607de089 100644 (file)
@@ -26,6 +26,9 @@
 #include "hwif.h"
 #include "mmc.h"
 
+#define DWMAC_SNPSVER  GENMASK_U32(7, 0)
+#define DWMAC_USERVER  GENMASK_U32(15, 8)
+
 /* Synopsys Core versions */
 #define        DWMAC_CORE_3_40         0x34
 #define        DWMAC_CORE_3_50         0x35
index a4df51a7aef1146e1c61b314ed801ff2a118ffb6..26cc1bc758bfb43612254d203cc17fc7b9072925 100644 (file)
@@ -43,12 +43,12 @@ static void stmmac_get_version(struct stmmac_priv *priv,
        }
 
        dev_info(priv->device, "User ID: 0x%x, Synopsys ID: 0x%x\n",
-                (unsigned int)(version & GENMASK(15, 8)) >> 8,
-                (unsigned int)(version & GENMASK(7, 0)));
+                FIELD_GET(DWMAC_USERVER, version),
+                FIELD_GET(DWMAC_SNPSVER, version));
 
-       ver->snpsver = version & GENMASK(7, 0);
+       ver->snpsver = FIELD_GET(DWMAC_SNPSVER, version);
        if (core_type == DWMAC_CORE_XGMAC)
-               ver->dev_id = (version & GENMASK(15, 8)) >> 8;
+               ver->dev_id = FIELD_GET(DWMAC_USERVER, version);
 }
 
 static void stmmac_dwmac_mode_quirk(struct stmmac_priv *priv)