linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: make array ch_to_mux static, makes object code smaller
@ 2017-10-19 13:46 Colin King
  2017-10-21 16:58 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2017-10-19 13:46 UTC (permalink / raw)
  To: Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Don't populate const array ch_to_mux on the stack, instead
make it static. Makes the object code smaller by over 200 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
  12663	   1648	    128	  14439	   3867	drivers/iio/adc/ti-adc12138.o

After
   text	   data	    bss	    dec	    hex	filename
  12353	   1744	    128	  14225	   3791	drivers/iio/adc/ti-adc12138.o

(gcc version 7.2.0 x86_64)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/iio/adc/ti-adc12138.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti-adc12138.c b/drivers/iio/adc/ti-adc12138.c
index bf890244789a..703d68ae96b7 100644
--- a/drivers/iio/adc/ti-adc12138.c
+++ b/drivers/iio/adc/ti-adc12138.c
@@ -164,7 +164,7 @@ static int __adc12138_start_conv(struct adc12138 *adc,
 				 void *data, int len)
 
 {
-	const u8 ch_to_mux[] = { 0, 4, 1, 5, 2, 6, 3, 7 };
+	static const u8 ch_to_mux[] = { 0, 4, 1, 5, 2, 6, 3, 7 };
 	u8 mode = (ch_to_mux[channel->channel] << 4) |
 		  (channel->differential ? 0 : 0x80);
 
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: adc: make array ch_to_mux static, makes object code smaller
  2017-10-19 13:46 [PATCH] iio: adc: make array ch_to_mux static, makes object code smaller Colin King
@ 2017-10-21 16:58 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2017-10-21 16:58 UTC (permalink / raw)
  To: Colin King
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	kernel-janitors, linux-kernel

On Thu, 19 Oct 2017 15:46:22 +0200
Colin King <colin.king@canonical.com> wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't populate const array ch_to_mux on the stack, instead
> make it static. Makes the object code smaller by over 200 bytes:
> 
> Before:
>    text	   data	    bss	    dec	    hex	filename
>   12663	   1648	    128	  14439	   3867	drivers/iio/adc/ti-adc12138.o
> 
> After
>    text	   data	    bss	    dec	    hex	filename
>   12353	   1744	    128	  14225	   3791	drivers/iio/adc/ti-adc12138.o
> 
> (gcc version 7.2.0 x86_64)
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Thanks.  I added the driver name to the title though as people tend
to scan lists of commits to see if there is anything they care about
and this only effects on driver rather than all adcs.

Applied to the togreg branch of iio.git and pusehd out as testing for the
autobuilders to play with it.

thanks,

Jonathan
> ---
>  drivers/iio/adc/ti-adc12138.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ti-adc12138.c b/drivers/iio/adc/ti-adc12138.c
> index bf890244789a..703d68ae96b7 100644
> --- a/drivers/iio/adc/ti-adc12138.c
> +++ b/drivers/iio/adc/ti-adc12138.c
> @@ -164,7 +164,7 @@ static int __adc12138_start_conv(struct adc12138 *adc,
>  				 void *data, int len)
>  
>  {
> -	const u8 ch_to_mux[] = { 0, 4, 1, 5, 2, 6, 3, 7 };
> +	static const u8 ch_to_mux[] = { 0, 4, 1, 5, 2, 6, 3, 7 };
>  	u8 mode = (ch_to_mux[channel->channel] << 4) |
>  		  (channel->differential ? 0 : 0x80);
>  


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-21 16:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-19 13:46 [PATCH] iio: adc: make array ch_to_mux static, makes object code smaller Colin King
2017-10-21 16:58 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).