From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
Richard Cochran <richardcochran@gmail.com>
Subject: [PATCH net-next v2 5/8] net: stmmac: use FIELD_GET() for version register
Date: Fri, 24 Oct 2025 13:49:25 +0100 [thread overview]
Message-ID: <E1vCHET-0000000BPU4-2f0F@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <aPt1l6ocBCg4YlyS@shell.armlinux.org.uk>
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>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/common.h | 3 +++
drivers/net/ethernet/stmicro/stmmac/hwif.c | 8 ++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 31254ba525d5..a89fe25f1837 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -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
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c
index c156edb54ae6..78362cf656f2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.c
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c
@@ -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)
--
2.47.3
next prev parent reply other threads:[~2025-10-24 12:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-24 12:48 [PATCH net-next 0/8] net: stmmac: hwif.c cleanups Russell King (Oracle)
2025-10-24 12:49 ` [PATCH net-next v2 1/8] net: stmmac: move version handling into own function Russell King (Oracle)
2025-10-24 12:49 ` [PATCH net-next v2 2/8] net: stmmac: simplify stmmac_get_version() Russell King (Oracle)
2025-10-24 12:49 ` [PATCH net-next v2 3/8] net: stmmac: consolidate version reading and validation Russell King (Oracle)
2025-10-24 12:49 ` [PATCH net-next v2 4/8] net: stmmac: move stmmac_get_*id() into stmmac_get_version() Russell King (Oracle)
2025-10-24 12:49 ` Russell King (Oracle) [this message]
2025-10-24 12:49 ` [PATCH net-next v2 6/8] net: stmmac: provide function to lookup hwif Russell King (Oracle)
2025-10-24 12:49 ` [PATCH net-next v2 7/8] net: stmmac: use != rather than ^ for comparing dev_id Russell King (Oracle)
2025-10-24 12:49 ` [PATCH net-next v2 8/8] net: stmmac: reorganise stmmac_hwif_init() Russell King (Oracle)
2025-10-24 20:22 ` [PATCH net-next 0/8] net: stmmac: hwif.c cleanups Mohd Ayaan Anwar
2025-10-28 23:42 ` Jakub Kicinski
2025-10-28 23:54 ` Russell King (Oracle)
2025-10-28 23:57 ` Russell King (Oracle)
2025-10-29 0:10 ` Jakub Kicinski
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=E1vCHET-0000000BPU4-2f0F@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.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;
as well as URLs for NNTP newsgroup(s).