Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: stmmac: dwc-qos-eth: simplify switch() in dwc_eth_dwmac_config_dt()

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 <maxime.chevallier@bootlin.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1vLfLG-0000000FMai-3fKz@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Russell King (Oracle) and committed by
Jakub Kicinski
f7ac9a0b f15bcd07

+3 -23
+3 -23
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
··· 84 84 device_property_read_u32(dev, "snps,burst-map", &burst_map); 85 85 86 86 /* converts burst-map bitmask to burst array */ 87 - for (bit_index = 0; bit_index < 7; bit_index++) { 88 - if (burst_map & (1 << bit_index)) { 89 - switch (bit_index) { 90 - case 0: 91 - plat_dat->axi->axi_blen[a_index] = 4; break; 92 - case 1: 93 - plat_dat->axi->axi_blen[a_index] = 8; break; 94 - case 2: 95 - plat_dat->axi->axi_blen[a_index] = 16; break; 96 - case 3: 97 - plat_dat->axi->axi_blen[a_index] = 32; break; 98 - case 4: 99 - plat_dat->axi->axi_blen[a_index] = 64; break; 100 - case 5: 101 - plat_dat->axi->axi_blen[a_index] = 128; break; 102 - case 6: 103 - plat_dat->axi->axi_blen[a_index] = 256; break; 104 - default: 105 - break; 106 - } 107 - a_index++; 108 - } 109 - } 87 + for (bit_index = 0; bit_index < 7; bit_index++) 88 + if (burst_map & (1 << bit_index)) 89 + plat_dat->axi->axi_blen[a_index++] = 4 << bit_index; 110 90 111 91 /* dwc-qos needs GMAC4, AAL, TSO and PMT */ 112 92 plat_dat->core_type = DWMAC_CORE_GMAC4;