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 072203254B4 for ; Wed, 19 Nov 2025 10:23:21 +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=1763547803; cv=none; b=PC1M3bYXASI+wS+ZWcUFCbrjxN7P/yBSULQv9j97TlnErXSaPW5Mbw9NqJz04n7h7hCn879RVs0oxtF32QQLknb3YkcI6KgLkvDV6kc5N7SAU3kyf5UPwl9caaleTljpTMwLXPzQxGlQ4C+6vT8wzQ5GBTPiwAQLkudMYBy10SQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763547803; c=relaxed/simple; bh=GTDcHdSSbmTqIYT5xwca12E6pUYdeo//5lQJmWhnR8U=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=q+yAY0MZwLC+Jo6AVMOQp5sXJug0ePpDeqQMZE1kQlAX1ysP10+DlMHeo2Tz29WZiL8SZkvveGRwezrbnOyOfYTwCmYYT28ChRllaEp401Xs4r8w6wmYk0VHkIVLS85p3TPER/NCjszGS83YF/I0a92n/uAzoN+yavFd9ZxdDdI= 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=Kbo/jik9; 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="Kbo/jik9" 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=0nTWHIx4Dctv5EXusL1J/hHr97kNJ1bSy5pO5kUUQNg=; b=Kbo/jik9svCmqoRmpP0yr7EOGi e7mn2hLsU/nfP59SJ6YVT2GlwEr7QtVKCH1mke1HI8yUQt+fUeUWpkNyvSOVhiAf7cDPO2cnP1zlC FO7tXuQ1vKMdcVEbHGn3f6MkV8ehvP/2ROpHmk84ly3GprTovc8fpQFJ4ci1FiXFGqMTg0Kc3B+Sq tCKqj7zT55Q3m7gxf6RvL9kJ4qYrQx43ezZYrC4AWezez1CdU+uot2sJKotPSs7dkl5AFGFUBqqrP E8L0WfWEWaKPMww/gDmyJu+CaupqR2S0PA6mftc0oU9s6PfD3PSZOEDFxqfWXq46E7VN6AEPGIyF2 PeMwlKuA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:52102 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 1vLfLH-000000004Uf-2TZr; Wed, 19 Nov 2025 10:23:15 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1vLfLG-0000000FMai-3fKz; Wed, 19 Nov 2025 10:23:14 +0000 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 Subject: [PATCH net-next 1/6] net: stmmac: dwc-qos-eth: simplify switch() in dwc_eth_dwmac_config_dt() 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: Wed, 19 Nov 2025 10:23:14 +0000 Simplify the switch() statement in dwc_eth_dwmac_config_dt(). Although this is not speed-critical, simplifying it can make it more readable. This also drastically improves the code emitted by the compiler. On aarch64, with the original code, the compiler loads registers with every possible value, and then has a tree of test-and-branch statements to work out which register to store. With the simplified code, the compiler can load a register with '4' and shift it appropriately. This shrinks the text size on aarch64 from 4289 bytes to 4153 bytes, a reduction of 3%. Reviewed-by: Maxime Chevallier Signed-off-by: Russell King (Oracle) -- v2: remove "the the" in commit description --- .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c index c7cd6497d42d..e6d5893c5905 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -84,29 +84,9 @@ static int dwc_eth_dwmac_config_dt(struct platform_device *pdev, device_property_read_u32(dev, "snps,burst-map", &burst_map); /* converts burst-map bitmask to burst array */ - for (bit_index = 0; bit_index < 7; bit_index++) { - if (burst_map & (1 << bit_index)) { - switch (bit_index) { - case 0: - plat_dat->axi->axi_blen[a_index] = 4; break; - case 1: - plat_dat->axi->axi_blen[a_index] = 8; break; - case 2: - plat_dat->axi->axi_blen[a_index] = 16; break; - case 3: - plat_dat->axi->axi_blen[a_index] = 32; break; - case 4: - plat_dat->axi->axi_blen[a_index] = 64; break; - case 5: - plat_dat->axi->axi_blen[a_index] = 128; break; - case 6: - plat_dat->axi->axi_blen[a_index] = 256; break; - default: - break; - } - a_index++; - } - } + for (bit_index = 0; bit_index < 7; bit_index++) + if (burst_map & (1 << bit_index)) + plat_dat->axi->axi_blen[a_index++] = 4 << bit_index; /* dwc-qos needs GMAC4, AAL, TSO and PMT */ plat_dat->core_type = DWMAC_CORE_GMAC4; -- 2.47.3