linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] leds: aat1290: make array max_mm_current_percent static const
@ 2017-08-24 13:00 Colin King
  2017-08-24 13:00 ` [PATCH 2/4] leds: lp5521: make several arrays " Colin King
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Colin King @ 2017-08-24 13:00 UTC (permalink / raw)
  To: Richard Purdie, Jacek Anaszewski, Pavel Machek, linux-leds; +Cc: linux-kernel

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

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

Before:
   text	   data	    bss	    dec	    hex	filename
   7225	   1936	     64	   9225	   2409	./drivers/leds/leds-aat1290.o

After:
   text	   data	    bss	    dec	    hex	filename
   6847	   2032	     64	   8943	   22ef	./drivers/leds/leds-aat1290.o`

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

diff --git a/drivers/leds/leds-aat1290.c b/drivers/leds/leds-aat1290.c
index a21e19297745..35fcb0ca9092 100644
--- a/drivers/leds/leds-aat1290.c
+++ b/drivers/leds/leds-aat1290.c
@@ -314,8 +314,10 @@ static void aat1290_led_validate_mm_current(struct aat1290_led *led,
 static int init_mm_current_scale(struct aat1290_led *led,
 			struct aat1290_led_config_data *cfg)
 {
-	int max_mm_current_percent[] = { 20, 22, 25, 28, 32, 36, 40, 45, 50, 56,
-						63, 71, 79, 89, 100 };
+	static const int max_mm_current_percent[] = {
+		20, 22, 25, 28, 32, 36, 40, 45, 50, 56,
+		63, 71, 79, 89, 100
+	};
 	int i, max_mm_current =
 			AAT1290_MAX_MM_CURRENT(cfg->max_flash_current);
 
-- 
2.14.1

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

* [PATCH 2/4] leds: lp5521: make several arrays static const
  2017-08-24 13:00 [PATCH 1/4] leds: aat1290: make array max_mm_current_percent static const Colin King
@ 2017-08-24 13:00 ` Colin King
  2017-08-24 13:00 ` [PATCH 3/4] leds: lp5562: " Colin King
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Colin King @ 2017-08-24 13:00 UTC (permalink / raw)
  To: Richard Purdie, Jacek Anaszewski, Pavel Machek, linux-leds; +Cc: linux-kernel

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

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

Before:
   text	   data	    bss	    dec	    hex	filename
   8999	   4176	     64	  13239	   33b7	drivers/leds/leds-lp5521.o

After:
   text	   data	    bss	    dec	    hex	filename
   8554	   4496	     64	  13114	   333a	drivers/leds/leds-lp5521.o

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

diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index f53c8cda1bde..55c0517fbe03 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -134,13 +134,13 @@ static void lp5521_set_led_current(struct lp55xx_led *led, u8 led_current)
 static void lp5521_load_engine(struct lp55xx_chip *chip)
 {
 	enum lp55xx_engine_index idx = chip->engine_idx;
-	u8 mask[] = {
+	static const u8 mask[] = {
 		[LP55XX_ENGINE_1] = LP5521_MODE_R_M,
 		[LP55XX_ENGINE_2] = LP5521_MODE_G_M,
 		[LP55XX_ENGINE_3] = LP5521_MODE_B_M,
 	};
 
-	u8 val[] = {
+	static const u8 val[] = {
 		[LP55XX_ENGINE_1] = LP5521_LOAD_R,
 		[LP55XX_ENGINE_2] = LP5521_LOAD_G,
 		[LP55XX_ENGINE_3] = LP5521_LOAD_B,
@@ -160,7 +160,7 @@ static void lp5521_stop_all_engines(struct lp55xx_chip *chip)
 static void lp5521_stop_engine(struct lp55xx_chip *chip)
 {
 	enum lp55xx_engine_index idx = chip->engine_idx;
-	u8 mask[] = {
+	static const u8 mask[] = {
 		[LP55XX_ENGINE_1] = LP5521_MODE_R_M,
 		[LP55XX_ENGINE_2] = LP5521_MODE_G_M,
 		[LP55XX_ENGINE_3] = LP5521_MODE_B_M,
@@ -226,7 +226,7 @@ static int lp5521_update_program_memory(struct lp55xx_chip *chip,
 {
 	enum lp55xx_engine_index idx = chip->engine_idx;
 	u8 pattern[LP5521_PROGRAM_LENGTH] = {0};
-	u8 addr[] = {
+	static const u8 addr[] = {
 		[LP55XX_ENGINE_1] = LP5521_REG_R_PROG_MEM,
 		[LP55XX_ENGINE_2] = LP5521_REG_G_PROG_MEM,
 		[LP55XX_ENGINE_3] = LP5521_REG_B_PROG_MEM,
-- 
2.14.1

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

* [PATCH 3/4] leds: lp5562: make several arrays static const
  2017-08-24 13:00 [PATCH 1/4] leds: aat1290: make array max_mm_current_percent static const Colin King
  2017-08-24 13:00 ` [PATCH 2/4] leds: lp5521: make several arrays " Colin King
@ 2017-08-24 13:00 ` Colin King
  2017-08-24 13:00 ` [PATCH 4/4] leds: lp8501: " Colin King
  2017-08-24 20:38 ` [PATCH 1/4] leds: aat1290: make array max_mm_current_percent " Jacek Anaszewski
  3 siblings, 0 replies; 5+ messages in thread
From: Colin King @ 2017-08-24 13:00 UTC (permalink / raw)
  To: Richard Purdie, Jacek Anaszewski, Pavel Machek, linux-leds; +Cc: linux-kernel

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

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

Before:
   text	   data	    bss	    dec	    hex	filename
   7725	   2448	     64	  10237	   27fd	drivers/leds/leds-lp5562.o

After:
   text	   data	    bss	    dec	    hex	filename
   7184	   2832	     64	  10080	   2760	drivers/leds/leds-lp5562.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/leds/leds-lp5562.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/leds/leds-lp5562.c b/drivers/leds/leds-lp5562.c
index 90892585bcb5..05ffa34fb6ad 100644
--- a/drivers/leds/leds-lp5562.c
+++ b/drivers/leds/leds-lp5562.c
@@ -116,7 +116,7 @@ static inline void lp5562_wait_enable_done(void)
 
 static void lp5562_set_led_current(struct lp55xx_led *led, u8 led_current)
 {
-	u8 addr[] = {
+	static const u8 addr[] = {
 		LP5562_REG_R_CURRENT,
 		LP5562_REG_G_CURRENT,
 		LP5562_REG_B_CURRENT,
@@ -130,13 +130,13 @@ static void lp5562_set_led_current(struct lp55xx_led *led, u8 led_current)
 static void lp5562_load_engine(struct lp55xx_chip *chip)
 {
 	enum lp55xx_engine_index idx = chip->engine_idx;
-	u8 mask[] = {
+	static const u8 mask[] = {
 		[LP55XX_ENGINE_1] = LP5562_MODE_ENG1_M,
 		[LP55XX_ENGINE_2] = LP5562_MODE_ENG2_M,
 		[LP55XX_ENGINE_3] = LP5562_MODE_ENG3_M,
 	};
 
-	u8 val[] = {
+	static const u8 val[] = {
 		[LP55XX_ENGINE_1] = LP5562_LOAD_ENG1,
 		[LP55XX_ENGINE_2] = LP5562_LOAD_ENG2,
 		[LP55XX_ENGINE_3] = LP5562_LOAD_ENG3,
@@ -211,7 +211,7 @@ static int lp5562_update_firmware(struct lp55xx_chip *chip,
 {
 	enum lp55xx_engine_index idx = chip->engine_idx;
 	u8 pattern[LP5562_PROGRAM_LENGTH] = {0};
-	u8 addr[] = {
+	static const u8 addr[] = {
 		[LP55XX_ENGINE_1] = LP5562_REG_PROG_MEM_ENG1,
 		[LP55XX_ENGINE_2] = LP5562_REG_PROG_MEM_ENG2,
 		[LP55XX_ENGINE_3] = LP5562_REG_PROG_MEM_ENG3,
@@ -314,7 +314,7 @@ static int lp5562_post_init_device(struct lp55xx_chip *chip)
 static int lp5562_led_brightness(struct lp55xx_led *led)
 {
 	struct lp55xx_chip *chip = led->chip;
-	u8 addr[] = {
+	static const u8 addr[] = {
 		LP5562_REG_R_PWM,
 		LP5562_REG_G_PWM,
 		LP5562_REG_B_PWM,
-- 
2.14.1

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

* [PATCH 4/4] leds: lp8501: make several arrays static const
  2017-08-24 13:00 [PATCH 1/4] leds: aat1290: make array max_mm_current_percent static const Colin King
  2017-08-24 13:00 ` [PATCH 2/4] leds: lp5521: make several arrays " Colin King
  2017-08-24 13:00 ` [PATCH 3/4] leds: lp5562: " Colin King
@ 2017-08-24 13:00 ` Colin King
  2017-08-24 20:38 ` [PATCH 1/4] leds: aat1290: make array max_mm_current_percent " Jacek Anaszewski
  3 siblings, 0 replies; 5+ messages in thread
From: Colin King @ 2017-08-24 13:00 UTC (permalink / raw)
  To: Richard Purdie, Jacek Anaszewski, Pavel Machek, linux-leds; +Cc: linux-kernel

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

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

Before:
   text	   data	    bss	    dec	    hex	filename
   5058	   1552	     64	   6674	   1a12	drivers/leds/leds-lp8501.o

After:
   text	   data	    bss	    dec	    hex	filename
   4788	   1776	     64	   6628	   19e4	drivers/leds/leds-lp8501.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/leds/leds-lp8501.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/leds-lp8501.c b/drivers/leds/leds-lp8501.c
index 3f9675bd214a..3adb113cf02e 100644
--- a/drivers/leds/leds-lp8501.c
+++ b/drivers/leds/leds-lp8501.c
@@ -118,19 +118,19 @@ static int lp8501_post_init_device(struct lp55xx_chip *chip)
 static void lp8501_load_engine(struct lp55xx_chip *chip)
 {
 	enum lp55xx_engine_index idx = chip->engine_idx;
-	u8 mask[] = {
+	static const u8 mask[] = {
 		[LP55XX_ENGINE_1] = LP8501_MODE_ENG1_M,
 		[LP55XX_ENGINE_2] = LP8501_MODE_ENG2_M,
 		[LP55XX_ENGINE_3] = LP8501_MODE_ENG3_M,
 	};
 
-	u8 val[] = {
+	static const u8 val[] = {
 		[LP55XX_ENGINE_1] = LP8501_LOAD_ENG1,
 		[LP55XX_ENGINE_2] = LP8501_LOAD_ENG2,
 		[LP55XX_ENGINE_3] = LP8501_LOAD_ENG3,
 	};
 
-	u8 page_sel[] = {
+	static const u8 page_sel[] = {
 		[LP55XX_ENGINE_1] = LP8501_PAGE_ENG1,
 		[LP55XX_ENGINE_2] = LP8501_PAGE_ENG2,
 		[LP55XX_ENGINE_3] = LP8501_PAGE_ENG3,
-- 
2.14.1

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

* Re: [PATCH 1/4] leds: aat1290: make array max_mm_current_percent static const
  2017-08-24 13:00 [PATCH 1/4] leds: aat1290: make array max_mm_current_percent static const Colin King
                   ` (2 preceding siblings ...)
  2017-08-24 13:00 ` [PATCH 4/4] leds: lp8501: " Colin King
@ 2017-08-24 20:38 ` Jacek Anaszewski
  3 siblings, 0 replies; 5+ messages in thread
From: Jacek Anaszewski @ 2017-08-24 20:38 UTC (permalink / raw)
  To: Colin King, Richard Purdie, Pavel Machek, linux-leds; +Cc: linux-kernel

Hi Colin,

Thanks for the path set, applied.

Best regards,
Jacek Anaszewski

On 08/24/2017 03:00 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't populate the array max_mm_current_percent on the stack, instead
> make it static const.  Makes the object code smaller by over 280 bytes:
> 
> Before:
>    text	   data	    bss	    dec	    hex	filename
>    7225	   1936	     64	   9225	   2409	./drivers/leds/leds-aat1290.o
> 
> After:
>    text	   data	    bss	    dec	    hex	filename
>    6847	   2032	     64	   8943	   22ef	./drivers/leds/leds-aat1290.o`
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/leds/leds-aat1290.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/leds/leds-aat1290.c b/drivers/leds/leds-aat1290.c
> index a21e19297745..35fcb0ca9092 100644
> --- a/drivers/leds/leds-aat1290.c
> +++ b/drivers/leds/leds-aat1290.c
> @@ -314,8 +314,10 @@ static void aat1290_led_validate_mm_current(struct aat1290_led *led,
>  static int init_mm_current_scale(struct aat1290_led *led,
>  			struct aat1290_led_config_data *cfg)
>  {
> -	int max_mm_current_percent[] = { 20, 22, 25, 28, 32, 36, 40, 45, 50, 56,
> -						63, 71, 79, 89, 100 };
> +	static const int max_mm_current_percent[] = {
> +		20, 22, 25, 28, 32, 36, 40, 45, 50, 56,
> +		63, 71, 79, 89, 100
> +	};
>  	int i, max_mm_current =
>  			AAT1290_MAX_MM_CURRENT(cfg->max_flash_current);
>  
> 

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

end of thread, other threads:[~2017-08-24 20:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-24 13:00 [PATCH 1/4] leds: aat1290: make array max_mm_current_percent static const Colin King
2017-08-24 13:00 ` [PATCH 2/4] leds: lp5521: make several arrays " Colin King
2017-08-24 13:00 ` [PATCH 3/4] leds: lp5562: " Colin King
2017-08-24 13:00 ` [PATCH 4/4] leds: lp8501: " Colin King
2017-08-24 20:38 ` [PATCH 1/4] leds: aat1290: make array max_mm_current_percent " Jacek Anaszewski

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).