mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: bmi323: mark bmi323_ext_reg_savestate as maybe unused
@ 2024-10-12  8:37 Su Hui
  2024-10-12  9:11 ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Su Hui @ 2024-10-12  8:37 UTC (permalink / raw)
  To: jagathjog1996, jic23, lars, nathan, ndesaulniers, morbo, justinstitt
  Cc: Su Hui, benato.denis96, Jonathan.Cameron, linux-iio,
	linux-kernel, llvm, kernel-janitors

When running 'make CC=clang drivers/iio/imu/bmi323/bmi323_core.o', there
is a clang warning as follows:

drivers/iio/imu/bmi323/bmi323_core.c:133:27: error:
variable 'bmi323_ext_reg_savestate' is not needed and will not be emitted
[-Werror,-Wunneeded-internal-declaration]
  133 | static const unsigned int bmi323_ext_reg_savestate[] = {
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Mark bmi323_ext_reg_savestate as __maybe_unused to silent this warning.

Fixes: 16531118ba63 ("iio: bmi323: peripheral in lowest power state on suspend")
Signed-off-by: Su Hui <suhui@nfschina.com>
---
 drivers/iio/imu/bmi323/bmi323_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/imu/bmi323/bmi323_core.c b/drivers/iio/imu/bmi323/bmi323_core.c
index beda8d2de53f..1167984809c5 100644
--- a/drivers/iio/imu/bmi323/bmi323_core.c
+++ b/drivers/iio/imu/bmi323/bmi323_core.c
@@ -130,7 +130,7 @@ static const unsigned int bmi323_reg_savestate[] = {
 	BMI323_FIFO_CONF_REG
 };
 
-static const unsigned int bmi323_ext_reg_savestate[] = {
+static const unsigned int bmi323_ext_reg_savestate[] __maybe_unused = {
 	BMI323_GEN_SET1_REG,
 	BMI323_TAP1_REG,
 	BMI323_TAP2_REG,
-- 
2.30.2


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

* Re: [PATCH] iio: bmi323: mark bmi323_ext_reg_savestate as maybe unused
  2024-10-12  8:37 [PATCH] iio: bmi323: mark bmi323_ext_reg_savestate as maybe unused Su Hui
@ 2024-10-12  9:11 ` Julia Lawall
  2024-10-12 10:08   ` Javier Carrasco
  2024-10-12 10:21   ` Su Hui
  0 siblings, 2 replies; 6+ messages in thread
From: Julia Lawall @ 2024-10-12  9:11 UTC (permalink / raw)
  To: Su Hui
  Cc: jagathjog1996, jic23, lars, nathan, ndesaulniers, morbo,
	justinstitt, benato.denis96, Jonathan.Cameron, linux-iio,
	linux-kernel, llvm, kernel-janitors



On Sat, 12 Oct 2024, Su Hui wrote:

> When running 'make CC=clang drivers/iio/imu/bmi323/bmi323_core.o', there
> is a clang warning as follows:
>
> drivers/iio/imu/bmi323/bmi323_core.c:133:27: error:
> variable 'bmi323_ext_reg_savestate' is not needed and will not be emitted
> [-Werror,-Wunneeded-internal-declaration]
>   133 | static const unsigned int bmi323_ext_reg_savestate[] = {
>       |                           ^~~~~~~~~~~~~~~~~~~~~~~~
> 1 error generated.
>
> Mark bmi323_ext_reg_savestate as __maybe_unused to silent this warning.

Why might it be unused?

julia

>
> Fixes: 16531118ba63 ("iio: bmi323: peripheral in lowest power state on suspend")
> Signed-off-by: Su Hui <suhui@nfschina.com>
> ---
>  drivers/iio/imu/bmi323/bmi323_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/imu/bmi323/bmi323_core.c b/drivers/iio/imu/bmi323/bmi323_core.c
> index beda8d2de53f..1167984809c5 100644
> --- a/drivers/iio/imu/bmi323/bmi323_core.c
> +++ b/drivers/iio/imu/bmi323/bmi323_core.c
> @@ -130,7 +130,7 @@ static const unsigned int bmi323_reg_savestate[] = {
>  	BMI323_FIFO_CONF_REG
>  };
>
> -static const unsigned int bmi323_ext_reg_savestate[] = {
> +static const unsigned int bmi323_ext_reg_savestate[] __maybe_unused = {
>  	BMI323_GEN_SET1_REG,
>  	BMI323_TAP1_REG,
>  	BMI323_TAP2_REG,
> --
> 2.30.2
>
>
>

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

* Re: [PATCH] iio: bmi323: mark bmi323_ext_reg_savestate as maybe unused
  2024-10-12  9:11 ` Julia Lawall
@ 2024-10-12 10:08   ` Javier Carrasco
  2024-10-12 10:26     ` Su Hui
  2024-10-12 10:51     ` Jonathan Cameron
  2024-10-12 10:21   ` Su Hui
  1 sibling, 2 replies; 6+ messages in thread
From: Javier Carrasco @ 2024-10-12 10:08 UTC (permalink / raw)
  To: Julia Lawall, Su Hui
  Cc: jagathjog1996, jic23, lars, nathan, ndesaulniers, morbo,
	justinstitt, benato.denis96, Jonathan.Cameron, linux-iio,
	linux-kernel, llvm, kernel-janitors

On 12/10/2024 11:11, Julia Lawall wrote:
> 
> 
> On Sat, 12 Oct 2024, Su Hui wrote:
> 
>> When running 'make CC=clang drivers/iio/imu/bmi323/bmi323_core.o', there
>> is a clang warning as follows:
>>
>> drivers/iio/imu/bmi323/bmi323_core.c:133:27: error:
>> variable 'bmi323_ext_reg_savestate' is not needed and will not be emitted
>> [-Werror,-Wunneeded-internal-declaration]
>>   133 | static const unsigned int bmi323_ext_reg_savestate[] = {
>>       |                           ^~~~~~~~~~~~~~~~~~~~~~~~
>> 1 error generated.
>>
>> Mark bmi323_ext_reg_savestate as __maybe_unused to silent this warning.
> 
> Why might it be unused?
> 
> julia
> 
>>
>> Fixes: 16531118ba63 ("iio: bmi323: peripheral in lowest power state on suspend")
>> Signed-off-by: Su Hui <suhui@nfschina.com>
>> ---
>>  drivers/iio/imu/bmi323/bmi323_core.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/imu/bmi323/bmi323_core.c b/drivers/iio/imu/bmi323/bmi323_core.c
>> index beda8d2de53f..1167984809c5 100644
>> --- a/drivers/iio/imu/bmi323/bmi323_core.c
>> +++ b/drivers/iio/imu/bmi323/bmi323_core.c
>> @@ -130,7 +130,7 @@ static const unsigned int bmi323_reg_savestate[] = {
>>  	BMI323_FIFO_CONF_REG
>>  };
>>
>> -static const unsigned int bmi323_ext_reg_savestate[] = {
>> +static const unsigned int bmi323_ext_reg_savestate[] __maybe_unused = {
>>  	BMI323_GEN_SET1_REG,
>>  	BMI323_TAP1_REG,
>>  	BMI323_TAP2_REG,
>> --
>> 2.30.2
>>
>>
>>
> 

This issue has already been found and discussed here:

https://lore.kernel.org/linux-iio/AS8PR02MB10217F8B5827B69E6438488679C762@AS8PR02MB10217.eurprd02.prod.outlook.com/

where I got lectured by Nathan Chancellor about such warnings.

The fix was not marking the array as unused, because it should have been
used. The proper fix can be found in iio/fixes-togreg.

Best regards,
Javier Carrasco

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

* Re: [PATCH] iio: bmi323: mark bmi323_ext_reg_savestate as maybe unused
  2024-10-12  9:11 ` Julia Lawall
  2024-10-12 10:08   ` Javier Carrasco
@ 2024-10-12 10:21   ` Su Hui
  1 sibling, 0 replies; 6+ messages in thread
From: Su Hui @ 2024-10-12 10:21 UTC (permalink / raw)
  To: Julia Lawall
  Cc: jagathjog1996, jic23, lars, nathan, ndesaulniers, morbo,
	justinstitt, benato.denis96, Jonathan.Cameron, linux-iio,
	linux-kernel, llvm, kernel-janitors

On 2024/10/12 17:11, Julia Lawall wrote:
> On Sat, 12 Oct 2024, Su Hui wrote:
>
>> When running 'make CC=clang drivers/iio/imu/bmi323/bmi323_core.o', there
>> is a clang warning as follows:
>>
>> drivers/iio/imu/bmi323/bmi323_core.c:133:27: error:
>> variable 'bmi323_ext_reg_savestate' is not needed and will not be emitted
>> [-Werror,-Wunneeded-internal-declaration]
>>    133 | static const unsigned int bmi323_ext_reg_savestate[] = {
>>        |                           ^~~~~~~~~~~~~~~~~~~~~~~~
>> 1 error generated.
>>
>> Mark bmi323_ext_reg_savestate as __maybe_unused to silent this warning.
> Why might it be unused?

We only use the size of 'bmi323_ext_reg_savestate[]' not it's value, as 
shown below :

$ git grep  bmi323_ext_reg_savest drivers/iio/imu/
drivers/iio/imu/bmi323/bmi323_core.c:static const unsigned int 
bmi323_ext_reg_savestate[] = {
drivers/iio/imu/bmi323/bmi323_core.c:   unsigned int 
ext_reg_settings[ARRAY_SIZE(bmi323_ext_reg_savestate)];
drivers/iio/imu/bmi323/bmi323_core.c:   for (unsigned int i = 0; i < 
ARRAY_SIZE(bmi323_ext_reg_savestate); i++) {
drivers/iio/imu/bmi323/bmi323_core.c:   for (unsigned int i = 0; i < 
ARRAY_SIZE(bmi323_ext_reg_savestate); i++) {

And I find some solutions use __maybe_unused to silent this warning. 
Like this one:
3034983db355 ("drm/amdgpu: Mark mmhub_v1_8_mmea_err_status_reg as 
__maybe_unused")

Mark this variable to __maybe_unused is  to eliminate clang's warning.
Perhaps it is also possible to mark it as _used:).

Su Hui




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

* Re: [PATCH] iio: bmi323: mark bmi323_ext_reg_savestate as maybe unused
  2024-10-12 10:08   ` Javier Carrasco
@ 2024-10-12 10:26     ` Su Hui
  2024-10-12 10:51     ` Jonathan Cameron
  1 sibling, 0 replies; 6+ messages in thread
From: Su Hui @ 2024-10-12 10:26 UTC (permalink / raw)
  To: Javier Carrasco, Julia Lawall
  Cc: jagathjog1996, jic23, lars, nathan, ndesaulniers, morbo,
	justinstitt, benato.denis96, Jonathan.Cameron, linux-iio,
	linux-kernel, llvm, kernel-janitors

> This issue has already been found and discussed here:
>
> https://lore.kernel.org/linux-iio/AS8PR02MB10217F8B5827B69E6438488679C762@AS8PR02MB10217.eurprd02.prod.outlook.com/
>
> where I got lectured by Nathan Chancellor about such warnings.
>
> The fix was not marking the array as unused, because it should have been
> used. The proper fix can be found in iio/fixes-togreg.

Oh , I just saw this email. Thanks!

Su Hui


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

* Re: [PATCH] iio: bmi323: mark bmi323_ext_reg_savestate as maybe unused
  2024-10-12 10:08   ` Javier Carrasco
  2024-10-12 10:26     ` Su Hui
@ 2024-10-12 10:51     ` Jonathan Cameron
  1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2024-10-12 10:51 UTC (permalink / raw)
  To: Javier Carrasco
  Cc: Julia Lawall, Su Hui, jagathjog1996, lars, nathan, ndesaulniers,
	morbo, justinstitt, benato.denis96, Jonathan.Cameron, linux-iio,
	linux-kernel, llvm, kernel-janitors

On Sat, 12 Oct 2024 12:08:39 +0200
Javier Carrasco <javier.carrasco.cruz@gmail.com> wrote:

> On 12/10/2024 11:11, Julia Lawall wrote:
> > 
> > 
> > On Sat, 12 Oct 2024, Su Hui wrote:
> >   
> >> When running 'make CC=clang drivers/iio/imu/bmi323/bmi323_core.o', there
> >> is a clang warning as follows:
> >>
> >> drivers/iio/imu/bmi323/bmi323_core.c:133:27: error:
> >> variable 'bmi323_ext_reg_savestate' is not needed and will not be emitted
> >> [-Werror,-Wunneeded-internal-declaration]
> >>   133 | static const unsigned int bmi323_ext_reg_savestate[] = {
> >>       |                           ^~~~~~~~~~~~~~~~~~~~~~~~
> >> 1 error generated.
> >>
> >> Mark bmi323_ext_reg_savestate as __maybe_unused to silent this warning.  
> > 
> > Why might it be unused?
> > 
> > julia
> >   
> >>
> >> Fixes: 16531118ba63 ("iio: bmi323: peripheral in lowest power state on suspend")
> >> Signed-off-by: Su Hui <suhui@nfschina.com>
> >> ---
> >>  drivers/iio/imu/bmi323/bmi323_core.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/iio/imu/bmi323/bmi323_core.c b/drivers/iio/imu/bmi323/bmi323_core.c
> >> index beda8d2de53f..1167984809c5 100644
> >> --- a/drivers/iio/imu/bmi323/bmi323_core.c
> >> +++ b/drivers/iio/imu/bmi323/bmi323_core.c
> >> @@ -130,7 +130,7 @@ static const unsigned int bmi323_reg_savestate[] = {
> >>  	BMI323_FIFO_CONF_REG
> >>  };
> >>
> >> -static const unsigned int bmi323_ext_reg_savestate[] = {
> >> +static const unsigned int bmi323_ext_reg_savestate[] __maybe_unused = {
> >>  	BMI323_GEN_SET1_REG,
> >>  	BMI323_TAP1_REG,
> >>  	BMI323_TAP2_REG,
> >> --
> >> 2.30.2
> >>
> >>
> >>  
> >   
> 
> This issue has already been found and discussed here:
> 
> https://lore.kernel.org/linux-iio/AS8PR02MB10217F8B5827B69E6438488679C762@AS8PR02MB10217.eurprd02.prod.outlook.com/
> 
> where I got lectured by Nathan Chancellor about such warnings.
> 
> The fix was not marking the array as unused, because it should have been
> used. The proper fix can be found in iio/fixes-togreg.
> 
> Best regards,
> Javier Carrasco

Busy week so I haven't gotten a pull request out yet. Should send one with this
fix later this weekend.

Jonathan


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

end of thread, other threads:[~2024-10-12 10:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-12  8:37 [PATCH] iio: bmi323: mark bmi323_ext_reg_savestate as maybe unused Su Hui
2024-10-12  9:11 ` Julia Lawall
2024-10-12 10:08   ` Javier Carrasco
2024-10-12 10:26     ` Su Hui
2024-10-12 10:51     ` Jonathan Cameron
2024-10-12 10:21   ` Su Hui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®