diff mbox

rt2x00: make const array glrt_table static

Message ID 20170711114733.15387-1-colin.king@canonical.com (mailing list archive)
State Accepted
Commit 17830147c40a26b7c323fbab525e6dd63bd45d49
Delegated to: Kalle Valo
Headers show

Commit Message

Colin King July 11, 2017, 11:47 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Don't populate array glrt_table on the stack but make it static.
Makes the object code a smaller by over 670 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
 131772	   4733	      0	 136505	  21539	rt2800lib.o

After:
   text	   data	    bss	    dec	    hex	filename
 131043	   4789	      0	 135832	  21298	rt2800lib.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stanislaw Gruszka July 12, 2017, 6:49 a.m. UTC | #1
On Tue, Jul 11, 2017 at 12:47:33PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't populate array glrt_table on the stack but make it static.
> Makes the object code a smaller by over 670 bytes:
> 
> Before:
>    text	   data	    bss	    dec	    hex	filename
>  131772	   4733	      0	 136505	  21539	rt2800lib.o
> 
> After:
>    text	   data	    bss	    dec	    hex	filename
>  131043	   4789	      0	 135832	  21298	rt2800lib.o
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>

I wonder why compiler do not optimize by itself since array is
const, but patch is ok.

Stanislaw
Colin King July 12, 2017, 7:04 a.m. UTC | #2
On 12/07/17 07:49, Stanislaw Gruszka wrote:
> On Tue, Jul 11, 2017 at 12:47:33PM +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Don't populate array glrt_table on the stack but make it static.
>> Makes the object code a smaller by over 670 bytes:
>>
>> Before:
>>    text	   data	    bss	    dec	    hex	filename
>>  131772	   4733	      0	 136505	  21539	rt2800lib.o
>>
>> After:
>>    text	   data	    bss	    dec	    hex	filename
>>  131043	   4789	      0	 135832	  21298	rt2800lib.o
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> 
> Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>
> 
> I wonder why compiler do not optimize by itself since array is
> const, but patch is ok.

Afraid marking it as const does not guarantee that at all. The const
qualifier just announces that the value will not be changed [1]. So one
requires static const to ensure it's not populated on the stack and also
marked as non-modifiable.

[1] Section A4.4, The C programming Language, page 196

Colin

> 
> Stanislaw 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Kalle Valo July 28, 2017, 3:01 p.m. UTC | #3
Colin Ian King <colin.king@canonical.com> wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't populate array glrt_table on the stack but make it static.
> Makes the object code a smaller by over 670 bytes:
> 
> Before:
>    text	   data	    bss	    dec	    hex	filename
>  131772	   4733	      0	 136505	  21539	rt2800lib.o
> 
> After:
>    text	   data	    bss	    dec	    hex	filename
>  131043	   4789	      0	 135832	  21298	rt2800lib.o
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>

Patch applied to wireless-drivers-next.git, thanks.

17830147c40a mwifiex: fix spelling mistake: "Insuffient" -> "Insufficient"
Kalle Valo July 28, 2017, 4:51 p.m. UTC | #4
Kalle Valo <kvalo@codeaurora.org> writes:

> Colin Ian King <colin.king@canonical.com> wrote:
>
>> From: Colin Ian King <colin.king@canonical.com>
>> 
>> Don't populate array glrt_table on the stack but make it static.
>> Makes the object code a smaller by over 670 bytes:
>> 
>> Before:
>>    text	   data	    bss	    dec	    hex	filename
>>  131772	   4733	      0	 136505	  21539	rt2800lib.o
>> 
>> After:
>>    text	   data	    bss	    dec	    hex	filename
>>  131043	   4789	      0	 135832	  21298	rt2800lib.o
>> 
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>
>
> Patch applied to wireless-drivers-next.git, thanks.
>
> 17830147c40a mwifiex: fix spelling mistake: "Insuffient" -> "Insufficient"

Dave had applied this earlier and my script failed to detect that. Hence
the commit above is wrong.

commit bf98bd0be1ba509c5e6d77524ffac192f1edb2dd
Author:     Colin Ian King <colin.king@canonical.com>
AuthorDate: Tue Jul 11 12:47:33 2017 +0100
Commit:     David S. Miller <davem@davemloft.net>
CommitDate: Thu Jul 13 09:23:56 2017 -0700

    rt2x00: make const array glrt_table static
diff mbox

Patch

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 6e2e760d98b1..0b75def39c6c 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -5704,7 +5704,7 @@  static void rt2800_init_freq_calibration(struct rt2x00_dev *rt2x00dev)
 
 static void rt2800_init_bbp_5592_glrt(struct rt2x00_dev *rt2x00dev)
 {
-	const u8 glrt_table[] = {
+	static const u8 glrt_table[] = {
 		0xE0, 0x1F, 0X38, 0x32, 0x08, 0x28, 0x19, 0x0A, 0xFF, 0x00, /* 128 ~ 137 */
 		0x16, 0x10, 0x10, 0x0B, 0x36, 0x2C, 0x26, 0x24, 0x42, 0x36, /* 138 ~ 147 */
 		0x30, 0x2D, 0x4C, 0x46, 0x3D, 0x40, 0x3E, 0x42, 0x3D, 0x40, /* 148 ~ 157 */