Skip to contentSkip to conversation

mfd: stw481x: make three arrays static const, reduces object code size

PATCH In review Colin King 2 participants 2 messages Sep 5, 2017 – Sep 7, 2017

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 mfd: stw481x: make three arrays static const, reduces object code size

From: Colin Ian King <[email protected]>

Don't populate the arrays vcore_val, vpll_val and vaux_val on the stack, instead make them static const. Makes the object code smaller by over 370 bytes:

Before:
text data bss dec hex filename
6971 3248 64 10283 282b drivers/mfd/stw481x.o

After:
text data bss dec hex filename
6338 3504 64 9906 26b2 drivers/mfd/stw481x.o

---
 drivers/mfd/stw481x.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/mfd/stw481x.c +6 -4
index ab949eaca6ad..3cc80956260e 100644
@@ -72,10 +72,12 @@ static int stw481x_get_pctl_reg(struct stw481x *stw481x, u8 reg)
 static int stw481x_startup(struct stw481x *stw481x)
 {
 	/* Voltages multiplied by 100 */
-	u8 vcore_val[] = { 100, 105, 110, 115, 120, 122, 124, 126, 128,
-			   130, 132, 134, 136, 138, 140, 145 };
-	u8 vpll_val[] = { 105, 120, 130, 180 };
-	u8 vaux_val[] = { 15, 18, 25, 28 };
+	static const u8 vcore_val[] = {
+		100, 105, 110, 115, 120, 122, 124, 126, 128,
+		130, 132, 134, 136, 138, 140, 145
+	};
+	static const u8 vpll_val[] = { 105, 120, 130, 180 };
+	static const u8 vaux_val[] = { 15, 18, 25, 28 };
 	u8 vcore;
 	u8 vcore_slp;
 	u8 vpll;
Signature · 1 line
2.14.1
#1 lore raw
Quoted 10 lines · Colin King

From: Colin Ian King <[email protected]>

Don't populate the arrays vcore_val, vpll_val and vaux_val on the stack, instead make them static const. Makes the object code smaller by over 370 bytes:

Before:
text data bss dec hex filename
6971 3248 64 10283 282b drivers/mfd/stw481x.o

Quoted 8 lines

After:
text data bss dec hex filename
6338 3504 64 9906 26b2 drivers/mfd/stw481x.o

---
 drivers/mfd/stw481x.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Applied for v4.15, thanks.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html