diff mbox series

HID: prodikeys: make array keys static const, makes object smaller

Message ID 20190905165406.24641-1-colin.king@canonical.com (mailing list archive)
State Mainlined
Commit fe2199cfd1516e90e03c033c52c9a28da09d9986
Delegated to: Jiri Kosina
Headers show
Series HID: prodikeys: make array keys static const, makes object smaller | expand

Commit Message

Colin King Sept. 5, 2019, 4:54 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Don't populate the array keys on the stack but instead make it
static const. Makes the object code smaller by 166 bytes.

Before:
   text	   data	    bss	    dec	    hex	filename
  18931	   5872	    480	  25283	   62c3	drivers/hid/hid-prodikeys.o

After:
   text	   data	    bss	    dec	    hex	filename
  18669	   5968	    480	  25117	   621d	drivers/hid/hid-prodikeys.o

(gcc version 9.2.1, amd64)

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

Comments

Jiri Kosina Oct. 1, 2019, 2:21 p.m. UTC | #1
On Thu, 5 Sep 2019, Colin King wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't populate the array keys on the stack but instead make it
> static const. Makes the object code smaller by 166 bytes.
> 
> Before:
>    text	   data	    bss	    dec	    hex	filename
>   18931	   5872	    480	  25283	   62c3	drivers/hid/hid-prodikeys.o
> 
> After:
>    text	   data	    bss	    dec	    hex	filename
>   18669	   5968	    480	  25117	   621d	drivers/hid/hid-prodikeys.o
> 
> (gcc version 9.2.1, amd64)
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/hid/hid-prodikeys.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c
> index 21544ebff855..fb6841ebe4d9 100644
> --- a/drivers/hid/hid-prodikeys.c
> +++ b/drivers/hid/hid-prodikeys.c
> @@ -516,7 +516,7 @@ static void pcmidi_setup_extra_keys(
>  		MY PICTURES =>	KEY_WORDPROCESSOR
>  		MY MUSIC=>	KEY_SPREADSHEET
>  	*/
> -	unsigned int keys[] = {
> +	static const unsigned int keys[] = {
>  		KEY_FN,
>  		KEY_MESSENGER, KEY_CALENDAR,
>  		KEY_ADDRESSBOOK, KEY_DOCUMENTS,
> @@ -532,7 +532,7 @@ static void pcmidi_setup_extra_keys(
>  		0
>  	};
>  
> -	unsigned int *pkeys = &keys[0];
> +	const unsigned int *pkeys = &keys[0];
>  	unsigned short i;

Applied, thanks for the fix.
diff mbox series

Patch

diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c
index 21544ebff855..fb6841ebe4d9 100644
--- a/drivers/hid/hid-prodikeys.c
+++ b/drivers/hid/hid-prodikeys.c
@@ -516,7 +516,7 @@  static void pcmidi_setup_extra_keys(
 		MY PICTURES =>	KEY_WORDPROCESSOR
 		MY MUSIC=>	KEY_SPREADSHEET
 	*/
-	unsigned int keys[] = {
+	static const unsigned int keys[] = {
 		KEY_FN,
 		KEY_MESSENGER, KEY_CALENDAR,
 		KEY_ADDRESSBOOK, KEY_DOCUMENTS,
@@ -532,7 +532,7 @@  static void pcmidi_setup_extra_keys(
 		0
 	};
 
-	unsigned int *pkeys = &keys[0];
+	const unsigned int *pkeys = &keys[0];
 	unsigned short i;
 
 	if (pm->ifnum != 1)  /* only set up ONCE for interace 1 */