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 3FA953093AE for ; Thu, 23 Oct 2025 09:37:36 +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=1761212258; cv=none; b=mboCxTWQQzg9ShCgvH+NBDQtiNC3F5mb07CVrfBbISUQKPHLyTa+82zv6CMxyrFy13uwtug8XuxwzDvQWbJTHLM5v53BXufz2zNlloD35NE7zTVlU4ArOYbZ/5LdIGSkDRtWiFZA9wK6jG/0zTN2GCytvE8XlL+eWSaAdoeKGBQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761212258; c=relaxed/simple; bh=mSvANulbTb2iz7GmLuYuROqChjMJITyDfu6eGj7HUQk=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=TsCoatmXEKXqwqdQFuw3cf8lJ6W3bX1IYaamAiuDT86yQUYfCrbRB3CeSoAGvYKuZqGAn4g/CgeOMVe7SQZqIJKJOaunwLhrCL6CpekGyvyT2OTOUY8JnUDNsTUmM9Ov9+xbuEauSYO0LtVmAyVf5V7l0XCAf4NC6sUShwuzlbA= 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=CdN6Ceka; 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="CdN6Ceka" 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=4IR15YmOi30IOFo+C5GF3Vg22Y2q6B0Iun6RgdkPXEg=; b=CdN6Ceka+/zjQIEZ8kYbkAcKqA REh4YekMIC8ImXyLWn0Es2/GWoS6q2jsC49Y0B06JerTuFKvhxrJjlED/URWgtNUPqMVjXBmKXOUM QJyuCJelnd3IKKXy3ubjQnwhPgGkQwCCwj1nvOKu7LPX08iTAwVXuuItWPsG4yhTXLOaH0wqwNoTb 0ciV4iAHofBCXhoH591b8E0pyxxT0wDfOZq7q8fXVoZhc9mTsC0m2xYruUdrETBbn4XwhcUq6eKnY i+hO/8Iljq98bLJQA4fCxxcElvxlGELI3sn2LQb8urgAadM0kNIMSyphn4pxypsD/TsgYIbeRGQSO 7czPVxMA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:37978 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 1vBrlC-0000000064v-0l63; Thu, 23 Oct 2025 10:37:30 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1vBrlB-0000000BMPs-1eS9; Thu, 23 Oct 2025 10:37:29 +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 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: Thu, 23 Oct 2025 10:37:29 +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. Signed-off-by: Russell King (Oracle) --- 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..7ee304e3599a 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, verison_offset); } static void stmmac_dwmac_mode_quirk(struct stmmac_priv *priv) -- 2.47.3