diff mbox series

[1/4] rtw88: Fix Sparse warning for rtw8822b

Message ID 20220520184528.4078-2-Larry.Finger@lwfinger.net (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series rtw88: Fix some Sparse warnings | expand

Commit Message

Larry Finger May 20, 2022, 6:45 p.m. UTC
Sparse lists the following for rtw88:

  CHECK   drivers/net/wireless/realtek/rtw88/rtw8822b.c
drivers/net/wireless/realtek/rtw88/rtw8822b.c:2500:22: warning: symbol 'rtw8822b_hw_spec' was not declared. Should it be static?

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
 drivers/net/wireless/realtek/rtw88/rtw8822b.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kalle Valo May 21, 2022, 5:52 a.m. UTC | #1
Larry Finger <Larry.Finger@lwfinger.net> writes:

> Sparse lists the following for rtw88:
>
>   CHECK   drivers/net/wireless/realtek/rtw88/rtw8822b.c
> drivers/net/wireless/realtek/rtw88/rtw8822b.c:2500:22: warning: symbol 'rtw8822b_hw_spec' was not declared. Should it be static?
>
> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>

It's good to try to make title's unique, so maybe something like this:

rtw88: make rtw8822b_hw_spec static

> ---
>  drivers/net/wireless/realtek/rtw88/rtw8822b.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
> index dccd722b8e62..60c4e75df035 100644
> --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
> @@ -2497,7 +2497,7 @@ static struct rtw_hw_reg_offset rtw8822b_edcca_th[] = {
>  	[EDCCA_TH_H2L_IDX] = {{.addr = 0x8a4, .mask = MASKBYTE1}, .offset = 0},
>  };
>  
> -struct rtw_chip_info rtw8822b_hw_spec = {
> +static struct rtw_chip_info rtw8822b_hw_spec = {

This should be static const to make sure it's not modified.

Similar comments for other patches in this patchset.
Ping-Ke Shih May 23, 2022, 12:45 a.m. UTC | #2
> -----Original Message-----
> From: Larry Finger <Larry.Finger@lwfinger.net>
> Sent: Saturday, May 21, 2022 2:45 AM
> To: Kalle Valo <kvalo@kernel.org>
> Cc: Johannes Berg <johannes@sipsolutions.net>; linux-wireless@vger.kernel.org; Larry Finger
> <Larry.Finger@lwfinger.net>; Pkshih <pkshih@realtek.com>
> Subject: [PATCH 1/4] rtw88: Fix Sparse warning for rtw8822b
> 
> Sparse lists the following for rtw88:
> 
>   CHECK   drivers/net/wireless/realtek/rtw88/rtw8822b.c
> drivers/net/wireless/realtek/rtw88/rtw8822b.c:2500:22: warning: symbol 'rtw8822b_hw_spec' was not
> declared. Should it be static?
> 
> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> ---
>  drivers/net/wireless/realtek/rtw88/rtw8822b.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c
> b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
> index dccd722b8e62..60c4e75df035 100644
> --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
> @@ -2497,7 +2497,7 @@ static struct rtw_hw_reg_offset rtw8822b_edcca_th[] = {
>  	[EDCCA_TH_H2L_IDX] = {{.addr = 0x8a4, .mask = MASKBYTE1}, .offset = 0},
>  };
> 
> -struct rtw_chip_info rtw8822b_hw_spec = {
> +static struct rtw_chip_info rtw8822b_hw_spec = {

As Kalle's recommendation, this should be 'const'

>  	.ops = &rtw8822b_ops,
>  	.id = RTW_CHIP_TYPE_8822B,
>  	.fw_name = "rtw88/rtw8822b_fw.bin",

I do grep with 'rtw8822b_hw_spec': 

rtw8822b.c:struct rtw_chip_info rtw8822b_hw_spec = {
rtw8822b.c:EXPORT_SYMBOL(rtw8822b_hw_spec);
rtw8822be.c:            .driver_data = (kernel_ulong_t)&rtw8822b_hw_spec
rtw8822be.h:extern struct rtw_chip_info rtw8822b_hw_spec;

Making rtw8822b_hw_spec static can avoid sparse warning, but I worry that it can't
be loaded, because it is an "external" symbol and used by rtw8822be.ko.
Spuriously, it works. 

However, I think we should correct them by moving extern prototype to rtw8822b.h and
include rtw8822b.h by rtw8822be.c.


Ping-Ke
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
index dccd722b8e62..60c4e75df035 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
@@ -2497,7 +2497,7 @@  static struct rtw_hw_reg_offset rtw8822b_edcca_th[] = {
 	[EDCCA_TH_H2L_IDX] = {{.addr = 0x8a4, .mask = MASKBYTE1}, .offset = 0},
 };
 
-struct rtw_chip_info rtw8822b_hw_spec = {
+static struct rtw_chip_info rtw8822b_hw_spec = {
 	.ops = &rtw8822b_ops,
 	.id = RTW_CHIP_TYPE_8822B,
 	.fw_name = "rtw88/rtw8822b_fw.bin",