net: stmmac: simplify stmmac_get_version()

We can simplify stmmac_get_version() by pre-initialising the version
members to zero, detecting the MAC100 core and returning, otherwise
determining the version register offset separately from calling
stmmac_get_id() and stmmac_get_dev_id(). Do this.

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/E1vDtel-0000000CCBx-3Lpf@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Russell King (Oracle) 2025-10-29 00:03:15 +00:00 committed by Jakub Kicinski
parent fc18b6e98c
commit f49838f77c

View File

@ -49,18 +49,22 @@ static void stmmac_get_version(struct stmmac_priv *priv,
struct stmmac_version *ver)
{
enum dwmac_core_type core_type = priv->plat->core_type;
unsigned int version_offset;
ver->snpsver = 0;
ver->dev_id = 0;
if (core_type == DWMAC_CORE_GMAC) {
ver->snpsver = stmmac_get_id(priv, GMAC_VERSION);
} else if (dwmac_is_xmac(core_type)) {
ver->snpsver = stmmac_get_id(priv, GMAC4_VERSION);
if (core_type == DWMAC_CORE_XGMAC)
ver->dev_id = stmmac_get_dev_id(priv, GMAC4_VERSION);
} else {
ver->snpsver = 0;
}
if (core_type == DWMAC_CORE_MAC100)
return;
if (core_type == DWMAC_CORE_GMAC)
version_offset = GMAC_VERSION;
else
version_offset = GMAC4_VERSION;
ver->snpsver = stmmac_get_id(priv, version_offset);
if (core_type == DWMAC_CORE_XGMAC)
ver->dev_id = stmmac_get_dev_id(priv, version_offset);
}
static void stmmac_dwmac_mode_quirk(struct stmmac_priv *priv)