linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: prodikeys: make array keys static const, makes object smaller
@ 2019-09-05 16:54 Colin King
  2019-10-01 14:21 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-09-05 16:54 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, linux-input
  Cc: kernel-janitors, linux-kernel

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;
 
 	if (pm->ifnum != 1)  /* only set up ONCE for interace 1 */
-- 
2.20.1


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

* Re: [PATCH] HID: prodikeys: make array keys static const, makes object smaller
  2019-09-05 16:54 [PATCH] HID: prodikeys: make array keys static const, makes object smaller Colin King
@ 2019-10-01 14:21 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2019-10-01 14:21 UTC (permalink / raw)
  To: Colin King; +Cc: Benjamin Tissoires, linux-input, kernel-janitors, linux-kernel

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.

-- 
Jiri Kosina
SUSE Labs


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

end of thread, other threads:[~2019-10-01 14:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05 16:54 [PATCH] HID: prodikeys: make array keys static const, makes object smaller Colin King
2019-10-01 14:21 ` Jiri Kosina

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