Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF91B18E20 for ; Fri, 24 Oct 2025 12:49:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761310159; cv=none; b=SjStF8Rk/Q3ArWXyndQUIXvWbpuHYL19r2Pz1J6ZuZwFnW78/KPbiTzUo4ziNTXORqDKPvlkqP/Wluew1hz1dxeU87/3HFAx3BmabwAvfl5Zp0UyLyyp9cUdvPZC1x1UQEG6Ljw1yKnR3TIbDHNoZZxLth1fI53ClNxQIdRpn5E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761310159; c=relaxed/simple; bh=ogT/hKTSN2JpCwXUIcwsIVfV4R4E20+YkU0fVTF+1wg=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=MAE30z6enj7YM79DfQFdCFYf7bn0IWHSzH9VXbl3HGQbGXf3QLHZQO+INXXJSwHJ382TLUfMRDaqBtSzmjAaLJLoQN+n148YMa50wT2P1fUrl6JA8hGbgBLRX46hzlM2GEeaadG+XPHHk86oMVQ9LrKEsahkMyTZOxQwWeaNx5I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=I2ygWatt; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="I2ygWatt" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1DBVmkORiObKi/mtbHrI6pyrFSaGIBlKIWc0uf+aGHI=; b=I2ygWatt8YcqRGUlS+/BI4KZbj ccP9fCaqRn44FKDb3Za9yM62VoOU/b1u9JebulZZXMztRD/YWrIgzkYNnsi8Gt/GQjIce8EAhXwvD Vp/CsxEM5tmVwQ4kNnTyX9bq26D+OF614EOEAgk545kr2QIWrWphWf3HzpML0I7n++oMtjTPP0xS+ 6LEMOFK9Q4Xcck92TmKok8B7IIhiBwOfBqXIH5EMWMO1hfJDXbVKpyn6uMF3R7uVI/x5b7fPvbrgC CYc6sQUSiRNDLC9PR1KJiK+5m6dnPvz/9ErlfCWVLlu/Dj/p9uJxYrSY35szxIuTFeZWNt3MS8Fkb H+jpYxMg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:51294 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vCHEF-000000007Zz-0Ck9; Fri, 24 Oct 2025 13:49:11 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1vCHEE-0000000BPTm-1CTA; Fri, 24 Oct 2025 13:49:10 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Richard Cochran Subject: [PATCH net-next v2 2/8] net: stmmac: simplify stmmac_get_version() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Fri, 24 Oct 2025 13:49:10 +0100 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 Tested-by: Maxime Chevallier Signed-off-by: Russell King (Oracle) -- v2: fix "verison" -> "version" typo (and subsequent patches) --- drivers/net/ethernet/stmicro/stmmac/hwif.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c index 44e34b6ab90a..6b001d3f57c6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -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) -- 2.47.3