i2c: designware: make const array supported_speeds static to shink object code size

Message ID 20170921223007.21081-1-colin.king@canonical.com
State Accepted
Headers show
Series
  • i2c: designware: make const array supported_speeds static to shink object code size
Related show

Commit Message

Colin Ian King Sept. 21, 2017, 10:30 p.m.
From: Colin Ian King <colin.king@canonical.com>

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

Before:
   text	   data	    bss	    dec	    hex	filename
   8474	   1440	      0	   9914	   26ba	i2c-designware-platdrv.o

After:
   text	   data	    bss	    dec	    hex	filename
   8324	   1440	      0	   9764	   2624	i2c-designware-platdrv.o

(gcc version 7.2.0 x86_64)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/i2c/busses/i2c-designware-platdrv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jarkko Nikula Sept. 22, 2017, 7:10 a.m. | #1
On 09/22/2017 01:30 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't populate const array supported_speeds on the stack, instead
> make it static.  Makes the object code smaller by 150 bytes:
> 
> Before:
>     text	   data	    bss	    dec	    hex	filename
>     8474	   1440	      0	   9914	   26ba	i2c-designware-platdrv.o
> 
> After:
>     text	   data	    bss	    dec	    hex	filename
>     8324	   1440	      0	   9764	   2624	i2c-designware-platdrv.o
> 
> (gcc version 7.2.0 x86_64)
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   drivers/i2c/busses/i2c-designware-platdrv.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
> index 0e65b97842b4..8a7b29b9afbe 100644
> --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> @@ -257,7 +257,9 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
>   	u32 acpi_speed, ht = 0;
>   	struct resource *mem;
>   	int i, irq, ret;
> -	const int supported_speeds[] = { 0, 100000, 400000, 1000000, 3400000 };
> +	static const int supported_speeds[] = {
> +		0, 100000, 400000, 1000000, 3400000
> +	};
>   
Oh, this is so easy to forget.

Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Wolfram Sang Oct. 17, 2017, 9:50 p.m. | #2
On Thu, Sep 21, 2017 at 11:30:07PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't populate const array supported_speeds on the stack, instead
> make it static.  Makes the object code smaller by 150 bytes:
> 
> Before:
>    text	   data	    bss	    dec	    hex	filename
>    8474	   1440	      0	   9914	   26ba	i2c-designware-platdrv.o
> 
> After:
>    text	   data	    bss	    dec	    hex	filename
>    8324	   1440	      0	   9764	   2624	i2c-designware-platdrv.o
> 
> (gcc version 7.2.0 x86_64)
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied to for-next, thanks!

Patch

diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 0e65b97842b4..8a7b29b9afbe 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -257,7 +257,9 @@  static int dw_i2c_plat_probe(struct platform_device *pdev)
 	u32 acpi_speed, ht = 0;
 	struct resource *mem;
 	int i, irq, ret;
-	const int supported_speeds[] = { 0, 100000, 400000, 1000000, 3400000 };
+	static const int supported_speeds[] = {
+		0, 100000, 400000, 1000000, 3400000
+	};
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)