Skip to contentSkip to conversation

drm/mgag200: make a const array static, makes object smaller

PATCH In review Colin King 2 participants 2 messages Feb 4, 2021 – Feb 5, 2021

Subsystems (4)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH v2 1/1 drm/mgag200: make a const array static, makes object smaller

From: Colin Ian King <[email protected]>

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

Before:
text data bss dec hex filename
34736 4552 0 39288 9978 drivers/gpu/drm/mgag200/mgag200_mode.o

After:
text data bss dec hex filename
34625 4616 0 39241 9949 drivers/gpu/drm/mgag200/mgag200_mode.o

(gcc version 10.2.0)

---

V2: move static declaration to the top of the declarations

---
 drivers/gpu/drm/mgag200/mgag200_mode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/mgag200/mgag200_mode.c +1 -1
index 1dfc42170059..c3dfde8cad25 100644
@@ -706,13 +706,13 @@ static int mga_g200eh_set_plls(struct mga_device *mdev, long clock)
 
 static int mga_g200er_set_plls(struct mga_device *mdev, long clock)
 {
+	static const unsigned int m_div_val[] = { 1, 2, 4, 8 };
 	unsigned int vcomax, vcomin, pllreffreq;
 	unsigned int delta, tmpdelta;
 	int testr, testn, testm, testo;
 	unsigned int p, m, n;
 	unsigned int computed, vco;
 	int tmp;
-	const unsigned int m_div_val[] = { 1, 2, 4, 8 };
 
 	m = n = p = 0;
 	vcomax = 1488000;
Signature · 1 line
2.29.2
#1 lore raw

Merged.

Am 04.02.21 um 20:11 schrieb Colin King:

Quoted 45 lines

From: Colin Ian King <[email protected]>

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

Before:
text data bss dec hex filename
34736 4552 0 39288 9978 drivers/gpu/drm/mgag200/mgag200_mode.o

After:
text data bss dec hex filename
34625 4616 0 39241 9949 drivers/gpu/drm/mgag200/mgag200_mode.o

(gcc version 10.2.0)

---

V2: move static declaration to the top of the declarations

---
  drivers/gpu/drm/mgag200/mgag200_mode.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/mgag200/mgag200_mode.c +1 -1
index 1dfc42170059..c3dfde8cad25 100644
@@ -706,13 +706,13 @@ static int mga_g200eh_set_plls(struct mga_device *mdev, long clock)
 
  static int mga_g200er_set_plls(struct mga_device *mdev, long clock)
  {
+	static const unsigned int m_div_val[] = { 1, 2, 4, 8 };
  	unsigned int vcomax, vcomin, pllreffreq;
  	unsigned int delta, tmpdelta;
  	int testr, testn, testm, testo;
  	unsigned int p, m, n;
  	unsigned int computed, vco;
  	int tmp;
-	const unsigned int m_div_val[] = { 1, 2, 4, 8 };
 
  	m = n = p = 0;
  	vcomax = 1488000;
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer