All of lore.kernel.org
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: Colin King <colin.king@canonical.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	linux-gpio@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] gpio: gpio-stmpe: make various char arrays static const, shrinks object size
Date: Wed, 29 Nov 2017 08:19:35 +0000	[thread overview]
Message-ID: <5A1E6D97.1050109@bfs.de> (raw)
In-Reply-To: <20171128182339.24579-1-colin.king@canonical.com>



Am 28.11.2017 19:23, schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't populate the read-only arrays edge_det_values, rise_values and
> fall_values on the stack but instead make them static and constify them.
> Makes the object code smaller by over 240 bytes:
> 
> Before:
>    text	   data	    bss	    dec	    hex	filename
>    9525	   2520	    192	  12237	   2fcd	drivers/gpio/gpio-stmpe.o
> 
> After:
>    text	   data	    bss	    dec	    hex	filename
>    9025	   2776	    192	  11993	   2ed9	drivers/gpio/gpio-stmpe.o
> 
> (gcc version 7.2.0 x86_64)
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/gpio/gpio-stmpe.c | 24 +++++++++++++++---------
>  1 file changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index e6e5cca624a7..e3d048e65339 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -273,15 +273,21 @@ static void stmpe_dbg_show_one(struct seq_file *s,
>  		u8 fall_reg;
>  		u8 irqen_reg;
>  
> -		char *edge_det_values[] = {"edge-inactive",
> -					   "edge-asserted",
> -					   "not-supported"};
> -		char *rise_values[] = {"no-rising-edge-detection",
> -				       "rising-edge-detection",
> -				       "not-supported"};
> -		char *fall_values[] = {"no-falling-edge-detection",
> -				       "falling-edge-detection",
> -				       "not-supported"};
> +		static const char * const edge_det_values[] = {
> +			"edge-inactive",
> +			"edge-asserted",
> +			"not-supported"
> +		};
> +		static const char * const rise_values[] = {
> +			"no-rising-edge-detection",
> +			"rising-edge-detection",
> +			"not-supported"
> +		};
> +		static const char * const fall_values[] = {
> +			"no-falling-edge-detection",
> +			"falling-edge-detection",
> +			"not-supported"
> +		};
>  		#define NOT_SUPPORTED_IDX 2

@maintainer:
the define here is hard to find, perhaps i should be move to a place
where i can be found more easily. Like the beginning of line.

re,
 wh
>  		u8 edge_det = NOT_SUPPORTED_IDX;
>  		u8 rise = NOT_SUPPORTED_IDX;

WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms@bfs.de>
To: Colin King <colin.king@canonical.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	linux-gpio@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] gpio: gpio-stmpe: make various char arrays static const, shrinks object size
Date: Wed, 29 Nov 2017 09:19:35 +0100	[thread overview]
Message-ID: <5A1E6D97.1050109@bfs.de> (raw)
In-Reply-To: <20171128182339.24579-1-colin.king@canonical.com>



Am 28.11.2017 19:23, schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't populate the read-only arrays edge_det_values, rise_values and
> fall_values on the stack but instead make them static and constify them.
> Makes the object code smaller by over 240 bytes:
> 
> Before:
>    text	   data	    bss	    dec	    hex	filename
>    9525	   2520	    192	  12237	   2fcd	drivers/gpio/gpio-stmpe.o
> 
> After:
>    text	   data	    bss	    dec	    hex	filename
>    9025	   2776	    192	  11993	   2ed9	drivers/gpio/gpio-stmpe.o
> 
> (gcc version 7.2.0 x86_64)
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/gpio/gpio-stmpe.c | 24 +++++++++++++++---------
>  1 file changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index e6e5cca624a7..e3d048e65339 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -273,15 +273,21 @@ static void stmpe_dbg_show_one(struct seq_file *s,
>  		u8 fall_reg;
>  		u8 irqen_reg;
>  
> -		char *edge_det_values[] = {"edge-inactive",
> -					   "edge-asserted",
> -					   "not-supported"};
> -		char *rise_values[] = {"no-rising-edge-detection",
> -				       "rising-edge-detection",
> -				       "not-supported"};
> -		char *fall_values[] = {"no-falling-edge-detection",
> -				       "falling-edge-detection",
> -				       "not-supported"};
> +		static const char * const edge_det_values[] = {
> +			"edge-inactive",
> +			"edge-asserted",
> +			"not-supported"
> +		};
> +		static const char * const rise_values[] = {
> +			"no-rising-edge-detection",
> +			"rising-edge-detection",
> +			"not-supported"
> +		};
> +		static const char * const fall_values[] = {
> +			"no-falling-edge-detection",
> +			"falling-edge-detection",
> +			"not-supported"
> +		};
>  		#define NOT_SUPPORTED_IDX 2

@maintainer:
the define here is hard to find, perhaps i should be move to a place
where i can be found more easily. Like the beginning of line.

re,
 wh
>  		u8 edge_det = NOT_SUPPORTED_IDX;
>  		u8 rise = NOT_SUPPORTED_IDX;

  reply	other threads:[~2017-11-29  8:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-28 18:23 [PATCH] gpio: gpio-stmpe: make various char arrays static const, shrinks object size Colin King
2017-11-29  8:19 ` walter harms [this message]
2017-11-29  8:19   ` walter harms
2017-12-02 12:05 ` Linus Walleij
2017-12-02 12:05   ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5A1E6D97.1050109@bfs.de \
    --to=wharms@bfs.de \
    --cc=colin.king@canonical.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.