Skip to contentSkip to conversation

rsi: make array fsm_state static const, makes object smaller

PATCH In review Colin King 3 participants 3 messages Aug 19, 2021 – Aug 29, 2021

Subsystems (4)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 rsi: make array fsm_state static const, makes object smaller

From: Colin Ian King <[email protected]>

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

Before:
text data bss dec hex filename
9213 3904 0 13117 333d .../wireless/rsi/rsi_91x_debugfs.o

After:
text data bss dec hex filename
8995 3968 0 12963 32a3 .../wireless/rsi/rsi_91x_debugfs.o

(gcc version 10.3.0)

---
 drivers/net/wireless/rsi/rsi_91x_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/rsi/rsi_91x_debugfs.c +1 -1
index 24a417ea2ae7..f404ca4c38e8 100644
@@ -117,7 +117,7 @@ static int rsi_stats_read(struct seq_file *seq, void *data)
 {
 	struct rsi_common *common = seq->private;
 
-	unsigned char fsm_state[][32] = {
+	static const unsigned char fsm_state[][32] = {
 		"FSM_FW_NOT_LOADED",
 		"FSM_CARD_NOT_READY",
 		"FSM_COMMON_DEV_PARAMS_SENT",
Signature · 1 line
2.32.0
#1 lore raw
Quoted 4 lines · Colin King

From: Colin Ian King <[email protected]>

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

[]

drivers/net/wireless/rsi/rsi_91x_debugfs.c

Quoted 1 line
drivers/net/wireless/rsi/rsi_91x_debugfs.c +0 -0

[]

drivers/net/wireless/rsi/rsi_91x_debugfs.c static int rsi_stats_read(struct seq_file *seq, void *data) · line 120

Quoted 6 lines
drivers/net/wireless/rsi/rsi_91x_debugfs.c +1 -1
@@ -117,7 +117,7 @@ static int rsi_stats_read(struct seq_file *seq, void *data)
  {
  	struct rsi_common *common = seq->private;
 
-	unsigned char fsm_state[][32] = {
+	static const unsigned char fsm_state[][32] = {

why not the even smaller with a defconfig

	static const char * const fsm_state[] = {
Quoted 3 lines
drivers/net/wireless/rsi/rsi_91x_debugfs.c +0 -0
  		"FSM_FW_NOT_LOADED",
  		"FSM_CARD_NOT_READY",
  		"FSM_COMMON_DEV_PARAMS_SENT",
#2 lore raw
In reply to Colin King
Quoted 9 lines · Colin King

From: Colin Ian King <[email protected]>

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

Before:
text data bss dec hex filename
9213 3904 0 13117 333d .../wireless/rsi/rsi_91x_debugfs.o

Quoted 7 lines

After:
text data bss dec hex filename
8995 3968 0 12963 32a3 .../wireless/rsi/rsi_91x_debugfs.o

(gcc version 10.3.0)

Patch applied to wireless-drivers-next.git, thanks.

f4c813641897 rsi: make array fsm_state static const, makes object smaller

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches