linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath9k: make array voice_priority static const
@ 2022-02-22 12:17 Colin Ian King
  2022-02-23  1:19 ` Jeff Johnson
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Colin Ian King @ 2022-02-22 12:17 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen, Kalle Valo, David S . Miller,
	Jakub Kicinski, linux-wireless, netdev
  Cc: kernel-janitors, linux-kernel

Don't populate the read-only array voice_priority on the stack but
instead make it static const. Also makes the object code a little
smaller.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 drivers/net/wireless/ath/ath9k/mci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c
index 39d46c203f6b..5e0ae7e6412f 100644
--- a/drivers/net/wireless/ath/ath9k/mci.c
+++ b/drivers/net/wireless/ath/ath9k/mci.c
@@ -43,7 +43,7 @@ static bool ath_mci_add_profile(struct ath_common *common,
 				struct ath_mci_profile_info *info)
 {
 	struct ath_mci_profile_info *entry;
-	u8 voice_priority[] = { 110, 110, 110, 112, 110, 110, 114, 116, 118 };
+	static const u8 voice_priority[] = { 110, 110, 110, 112, 110, 110, 114, 116, 118 };
 
 	if ((mci->num_sco == ATH_MCI_MAX_SCO_PROFILE) &&
 	    (info->type == MCI_GPM_COEX_PROFILE_VOICE))
-- 
2.34.1


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

* Re: [PATCH] ath9k: make array voice_priority static const
  2022-02-22 12:17 [PATCH] ath9k: make array voice_priority static const Colin Ian King
@ 2022-02-23  1:19 ` Jeff Johnson
  2022-02-24 15:08   ` Dan Carpenter
  2022-02-26 21:01 ` Toke Høiland-Jørgensen
  2022-03-09 15:09 ` Kalle Valo
  2 siblings, 1 reply; 5+ messages in thread
From: Jeff Johnson @ 2022-02-23  1:19 UTC (permalink / raw)
  To: Colin Ian King, Toke Høiland-Jørgensen, Kalle Valo,
	David S . Miller, Jakub Kicinski, linux-wireless, netdev
  Cc: kernel-janitors, linux-kernel

On 2/22/2022 4:17 AM, Colin Ian King wrote:
> Don't populate the read-only array voice_priority on the stack but
> instead make it static const. Also makes the object code a little
> smaller.
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>   drivers/net/wireless/ath/ath9k/mci.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c
> index 39d46c203f6b..5e0ae7e6412f 100644
> --- a/drivers/net/wireless/ath/ath9k/mci.c
> +++ b/drivers/net/wireless/ath/ath9k/mci.c
> @@ -43,7 +43,7 @@ static bool ath_mci_add_profile(struct ath_common *common,
>   				struct ath_mci_profile_info *info)
>   {
>   	struct ath_mci_profile_info *entry;
> -	u8 voice_priority[] = { 110, 110, 110, 112, 110, 110, 114, 116, 118 };
> +	static const u8 voice_priority[] = { 110, 110, 110, 112, 110, 110, 114, 116, 118 };
>   
>   	if ((mci->num_sco == ATH_MCI_MAX_SCO_PROFILE) &&
>   	    (info->type == MCI_GPM_COEX_PROFILE_VOICE))

Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>

An additional cleanup that could be performed in that function:

		if (info->voice_type < sizeof(voice_priority))

replace sizeof() with ARRAY_SIZE() so that it works correctly if the 
base type is ever changed from u8

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

* Re: [PATCH] ath9k: make array voice_priority static const
  2022-02-23  1:19 ` Jeff Johnson
@ 2022-02-24 15:08   ` Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2022-02-24 15:08 UTC (permalink / raw)
  To: Jeff Johnson
  Cc: Colin Ian King, Toke Høiland-Jørgensen, Kalle Valo,
	David S . Miller, Jakub Kicinski, linux-wireless, netdev,
	kernel-janitors, linux-kernel

On Tue, Feb 22, 2022 at 05:19:01PM -0800, Jeff Johnson wrote:
> On 2/22/2022 4:17 AM, Colin Ian King wrote:
> > Don't populate the read-only array voice_priority on the stack but
> > instead make it static const. Also makes the object code a little
> > smaller.
> > 
> > Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> > ---
> >   drivers/net/wireless/ath/ath9k/mci.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c
> > index 39d46c203f6b..5e0ae7e6412f 100644
> > --- a/drivers/net/wireless/ath/ath9k/mci.c
> > +++ b/drivers/net/wireless/ath/ath9k/mci.c
> > @@ -43,7 +43,7 @@ static bool ath_mci_add_profile(struct ath_common *common,
> >   				struct ath_mci_profile_info *info)
> >   {
> >   	struct ath_mci_profile_info *entry;
> > -	u8 voice_priority[] = { 110, 110, 110, 112, 110, 110, 114, 116, 118 };
> > +	static const u8 voice_priority[] = { 110, 110, 110, 112, 110, 110, 114, 116, 118 };
> >   	if ((mci->num_sco == ATH_MCI_MAX_SCO_PROFILE) &&
> >   	    (info->type == MCI_GPM_COEX_PROFILE_VOICE))
> 
> Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
> 
> An additional cleanup that could be performed in that function:
> 
> 		if (info->voice_type < sizeof(voice_priority))
> 
> replace sizeof() with ARRAY_SIZE() so that it works correctly if the base
> type is ever changed from u8

You're right that ARRAY_SIZE() is better style but we have a bunch of
static analysis to catch the bug if someone changes the type to int or
whatever.

regards,
dan carpenter


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

* Re: [PATCH] ath9k: make array voice_priority static const
  2022-02-22 12:17 [PATCH] ath9k: make array voice_priority static const Colin Ian King
  2022-02-23  1:19 ` Jeff Johnson
@ 2022-02-26 21:01 ` Toke Høiland-Jørgensen
  2022-03-09 15:09 ` Kalle Valo
  2 siblings, 0 replies; 5+ messages in thread
From: Toke Høiland-Jørgensen @ 2022-02-26 21:01 UTC (permalink / raw)
  To: Colin Ian King, Kalle Valo, David S . Miller, Jakub Kicinski,
	linux-wireless, netdev
  Cc: kernel-janitors, linux-kernel

Colin Ian King <colin.i.king@gmail.com> writes:

> Don't populate the read-only array voice_priority on the stack but
> instead make it static const. Also makes the object code a little
> smaller.
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>

Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>

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

* Re: [PATCH] ath9k: make array voice_priority static const
  2022-02-22 12:17 [PATCH] ath9k: make array voice_priority static const Colin Ian King
  2022-02-23  1:19 ` Jeff Johnson
  2022-02-26 21:01 ` Toke Høiland-Jørgensen
@ 2022-03-09 15:09 ` Kalle Valo
  2 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2022-03-09 15:09 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Toke Høiland-Jørgensen, David S . Miller,
	Jakub Kicinski, linux-wireless, netdev, kernel-janitors,
	linux-kernel

Colin Ian King <colin.i.king@gmail.com> wrote:

> Don't populate the read-only array voice_priority on the stack but
> instead make it static const. Also makes the object code a little
> smaller.
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
> Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>

Patch applied to ath-next branch of ath.git, thanks.

44d445c02388 ath9k: make array voice_priority static const

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20220222121749.87513-1-colin.i.king@gmail.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

end of thread, other threads:[~2022-03-09 15:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 12:17 [PATCH] ath9k: make array voice_priority static const Colin Ian King
2022-02-23  1:19 ` Jeff Johnson
2022-02-24 15:08   ` Dan Carpenter
2022-02-26 21:01 ` Toke Høiland-Jørgensen
2022-03-09 15:09 ` Kalle Valo

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