Skip to contentSkip to conversation

video: fbdev: kyro: make some const read-only arrays static

PATCH Superseded Colin Ian King 2 participants 2 messages Jul 12, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 video: fbdev: kyro: make some const read-only arrays static

Don't populate the const read-only arrays on the stack but instead make them static const. Also makes the object code a little smaller.

---
 drivers/video/fbdev/kyro/STG4000InitDevice.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/video/fbdev/kyro/STG4000InitDevice.c +5 -5
index edfa0a04854d..bf1ee3addbd0 100644
@@ -83,11 +83,11 @@ volatile u32 i,count=0; \
 static u32 InitSDRAMRegisters(volatile STG4000REG __iomem *pSTGReg,
 			      u32 dwSubSysID, u32 dwRevID)
 {
-	u32 adwSDRAMArgCfg0[] = { 0xa0, 0x80, 0xa0, 0xa0, 0xa0 };
-	u32 adwSDRAMCfg1[] = { 0x8732, 0x8732, 0xa732, 0xa732, 0x8732 };
-	u32 adwSDRAMCfg2[] = { 0x87d2, 0x87d2, 0xa7d2, 0x87d2, 0xa7d2 };
-	u32 adwSDRAMRsh[] = { 36, 39, 40 };
-	u32 adwChipSpeed[] = { 110, 120, 125 };
+	static const u32 adwSDRAMArgCfg0[] = { 0xa0, 0x80, 0xa0, 0xa0, 0xa0 };
+	static const u32 adwSDRAMCfg1[] = { 0x8732, 0x8732, 0xa732, 0xa732, 0x8732 };
+	static const u32 adwSDRAMCfg2[] = { 0x87d2, 0x87d2, 0xa7d2, 0x87d2, 0xa7d2 };
+	static const u32 adwSDRAMRsh[] = { 36, 39, 40 };
+	static const u32 adwChipSpeed[] = { 110, 120, 125 };
 	u32 dwMemTypeIdx;
 	u32 dwChipSpeedIdx;
 
Signature · 1 line
2.39.2
maintainer
#1 lore raw
Quoted 2 lines · Colin Ian King

Don't populate the const read-only arrays on the stack but instead make them static const. Also makes the object code a little smaller.

Looks good, but you can optimze even further...

Quoted 10 lines
---
  drivers/video/fbdev/kyro/STG4000InitDevice.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
drivers/video/fbdev/kyro/STG4000InitDevice.c +0 -0
index edfa0a04854d..bf1ee3addbd0 100644

drivers/video/fbdev/kyro/STG4000InitDevice.c volatile u32 i,count=0; \ · line 90

Quoted 8 lines
drivers/video/fbdev/kyro/STG4000InitDevice.c +0 -5
@@ -83,11 +83,11 @@ volatile u32 i,count=0; \
  static u32 InitSDRAMRegisters(volatile STG4000REG __iomem *pSTGReg,
  			      u32 dwSubSysID, u32 dwRevID)
  {
-	u32 adwSDRAMArgCfg0[] = { 0xa0, 0x80, 0xa0, 0xa0, 0xa0 };
-	u32 adwSDRAMCfg1[] = { 0x8732, 0x8732, 0xa732, 0xa732, 0x8732 };
-	u32 adwSDRAMCfg2[] = { 0x87d2, 0x87d2, 0xa7d2, 0x87d2, 0xa7d2 };
-	u32 adwSDRAMRsh[] = { 36, 39, 40 };
-	u32 adwChipSpeed[] = { 110, 120, 125 };> +	static const u32 adwSDRAMArgCfg0[] = { 0xa0, 0x80, 0xa0, 0xa0, 0xa0 };

Make this u8 instead of u32 (saves 5*3 = 15 bytes):
+ static const u8 adwSDRAMArgCfg0[] = { 0xa0, 0x80, 0xa0, 0xa0, 0xa0 };

drivers/video/fbdev/kyro/STG4000InitDevice.c volatile u32 i,count=0; \ · line 87

Quoted 1 line
drivers/video/fbdev/kyro/STG4000InitDevice.c +1 -0
+	static const u32 adwSDRAMCfg1[] = { 0x8732, 0x8732, 0xa732, 0xa732, 0x8732 };

u16

drivers/video/fbdev/kyro/STG4000InitDevice.c volatile u32 i,count=0; \ · line 88

Quoted 1 line
drivers/video/fbdev/kyro/STG4000InitDevice.c +1 -0
+	static const u32 adwSDRAMCfg2[] = { 0x87d2, 0x87d2, 0xa7d2, 0x87d2, 0xa7d2 };

u16

drivers/video/fbdev/kyro/STG4000InitDevice.c volatile u32 i,count=0; \ · line 89

Quoted 1 line
drivers/video/fbdev/kyro/STG4000InitDevice.c +1 -0
+	static const u32 adwSDRAMRsh[] = { 36, 39, 40 };

u8

drivers/video/fbdev/kyro/STG4000InitDevice.c volatile u32 i,count=0; \ · line 90

Quoted 1 line
drivers/video/fbdev/kyro/STG4000InitDevice.c +1 -0
+	static const u32 adwChipSpeed[] = { 110, 120, 125 };

u8...

Can you change that (test compile) and resend?

Helge