Skip to contentSkip to conversation

net: dsa: bcm_sf2: make const array static, makes object smaller

PATCH Applied Colin King 3 participants 3 messages Oct 20, 2020 – Oct 21, 2020

Subsystems (5)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 net: dsa: bcm_sf2: make const array static, makes object smaller

From: Colin Ian King <[email protected]>

Don't populate the const array rate_table on the stack but instead it static. Makes the object code smaller by 46 bytes.

Before:

   text	   data	    bss	    dec	    hex	filename
  29812	   3824	    192	  33828	   8424	drivers/net/dsa/bcm_sf2.o

After:

   text	   data	    bss	    dec	    hex	filename
  29670	   3920	    192	  33782	   83f6	drivers/net/dsa/bcm_sf2.o

(gcc version 10.2.0)

---
 drivers/net/dsa/bcm_sf2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/bcm_sf2.c +1 -1
index 0b5b2b33b3b6..1e9a0adda2d6 100644
@@ -54,7 +54,7 @@ static void bcm_sf2_recalc_clock(struct dsa_switch *ds)
 	unsigned long new_rate;
 	unsigned int ports_active;
 	/* Frequenty in Mhz */
-	const unsigned long rate_table[] = {
+	static const unsigned long rate_table[] = {
 		59220000,
 		60820000,
 		62500000,
Signature · 1 line
2.27.0
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Colin King

From: Colin Ian King <[email protected]>

Don't populate the const array rate_table on the stack but instead it static. Makes the object code smaller by 46 bytes.

Before:

   text	   data	    bss	    dec	    hex	filename
  29812	   3824	    192	  33828	   8424	drivers/net/dsa/bcm_sf2.o
Quoted 7 lines

After:

   text	   data	    bss	    dec	    hex	filename
  29670	   3920	    192	  33782	   83f6	drivers/net/dsa/bcm_sf2.o

(gcc version 10.2.0)

Signature · 1 line
Florian
maintainer Applied
#2 lore raw
Quoted 14 lines · On Tue, 20 Oct 2020 09:51:39 -0700 Florian Fainelli wrote:
Quoted 13 lines · Colin King

From: Colin Ian King <[email protected]>

Don't populate the const array rate_table on the stack but instead it static. Makes the object code smaller by 46 bytes.

Before:

   text	   data	    bss	    dec	    hex	filename
  29812	   3824	    192	  33828	   8424	drivers/net/dsa/bcm_sf2.o

After:

   text	   data	    bss	    dec	    hex	filename
  29670	   3920	    192	  33782	   83f6	drivers/net/dsa/bcm_sf2.o
Quoted 5 lines
Quoted 3 lines

(gcc version 10.2.0)

Applied, thanks!