Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1730831 > unrolled thread

[PATCH] backlight: s6e63m0: make const arrays static, reduces object code size

Started byColin King <colin.king@canonical.com>
First post2017-09-12 13:50 +0200
Last post2017-09-12 15:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] backlight: s6e63m0: make const arrays static, reduces object code size Colin King <colin.king@canonical.com> - 2017-09-12 13:50 +0200
    Re: [PATCH] backlight: s6e63m0: make const arrays static, reduces  object code size Daniel Thompson <daniel.thompson@linaro.org> - 2017-09-12 15:20 +0200

#1730831 — [PATCH] backlight: s6e63m0: make const arrays static, reduces object code size

FromColin King <colin.king@canonical.com>
Date2017-09-12 13:50 +0200
Subject[PATCH] backlight: s6e63m0: make const arrays static, reduces object code size
Message-ID<uoRRw-IN-5@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

Don't populate const arrays on the stack, instead make them
static.  Makes the object code smaller by nearly 400 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
  15164	   6336	      0	  21500	   53fc	drivers/video/backlight/s6e63m0.o

After:
   text	   data	    bss	    dec	    hex	filename
  14669	   6432	      0	  21101	   526d	drivers/video/backlight/s6e63m0.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/video/backlight/s6e63m0.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/backlight/s6e63m0.c b/drivers/video/backlight/s6e63m0.c
index 3c4a22a3063a..965c660b2f6b 100644
--- a/drivers/video/backlight/s6e63m0.c
+++ b/drivers/video/backlight/s6e63m0.c
@@ -446,7 +446,7 @@ static int s6e63m0_gamma_ctl(struct s6e63m0 *lcd, int gamma)
 static int s6e63m0_ldi_init(struct s6e63m0 *lcd)
 {
 	int ret, i;
-	const unsigned short *init_seq[] = {
+	static const unsigned short *init_seq[] = {
 		seq_panel_condition_set,
 		seq_display_condition_set,
 		seq_gamma_setting,
@@ -467,7 +467,7 @@ static int s6e63m0_ldi_init(struct s6e63m0 *lcd)
 static int s6e63m0_ldi_enable(struct s6e63m0 *lcd)
 {
 	int ret = 0, i;
-	const unsigned short *enable_seq[] = {
+	static const unsigned short *enable_seq[] = {
 		seq_stand_by_off,
 		seq_display_on,
 	};
-- 
2.14.1

[toc] | [next] | [standalone]


#1730852 — Re: [PATCH] backlight: s6e63m0: make const arrays static, reduces object code size

FromDaniel Thompson <daniel.thompson@linaro.org>
Date2017-09-12 15:20 +0200
SubjectRe: [PATCH] backlight: s6e63m0: make const arrays static, reduces object code size
Message-ID<uoTgB-1KR-5@gated-at.bofh.it>
In reply to#1730831
On 12/09/17 12:45, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't populate const arrays on the stack, instead make them
> static.  Makes the object code smaller by nearly 400 bytes:
> 
> Before:
>     text	   data	    bss	    dec	    hex	filename
>    15164	   6336	      0	  21500	   53fc	drivers/video/backlight/s6e63m0.o
> 
> After:
>     text	   data	    bss	    dec	    hex	filename
>    14669	   6432	      0	  21101	   526d	drivers/video/backlight/s6e63m0.o

For future records, can you record the compiler version, architecture 
and optimization level (-O2 or -Os) to the patch header?


> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   drivers/video/backlight/s6e63m0.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/video/backlight/s6e63m0.c b/drivers/video/backlight/s6e63m0.c
> index 3c4a22a3063a..965c660b2f6b 100644
> --- a/drivers/video/backlight/s6e63m0.c
> +++ b/drivers/video/backlight/s6e63m0.c
> @@ -446,7 +446,7 @@ static int s6e63m0_gamma_ctl(struct s6e63m0 *lcd, int gamma)
>   static int s6e63m0_ldi_init(struct s6e63m0 *lcd)
>   {
>   	int ret, i;
> -	const unsigned short *init_seq[] = {
> +	static const unsigned short *init_seq[] = {

I'd be inclined to throw in an extra const to help the compile spot any 
negligent maintenance in the future:

static const unsigned short * const init_seq[];


>   		seq_panel_condition_set,
>   		seq_display_condition_set,
>   		seq_gamma_setting,
> @@ -467,7 +467,7 @@ static int s6e63m0_ldi_init(struct s6e63m0 *lcd)
>   static int s6e63m0_ldi_enable(struct s6e63m0 *lcd)
>   {
>   	int ret = 0, i;
> -	const unsigned short *enable_seq[] = {
> +	static const unsigned short *enable_seq[] = {
>   		seq_stand_by_off,
>   		seq_display_on,
>   	};
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web