public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: bmi323: Fix array reference in bmi323_core_runtime_suspend()
@ 2024-09-09 16:38 Nathan Chancellor
  2024-09-09 19:10 ` Denis Benato
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2024-09-09 16:38 UTC (permalink / raw)
  To: Jagath Jog J, Jonathan Cameron, Lars-Peter Clausen, Denis Benato
  Cc: linux-iio, llvm, patches, Nathan Chancellor

Clang warns (or errors with CONFIG_WERROR):

  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[] = {
        |                           ^~~~~~~~~~~~~~~~~~~~~~~~

bmi323_ext_reg_savestate is only used within sizeof() through
ARRAY_SIZE(), so it is not unused, but it will not be emitted in the
final binary because sizeof() is evaluated only at compile time.
bmi323_ext_reg_savestate should have been used in the second parameter
in the call to bmi323_read_ext_reg() in the second for loop in
bmi323_core_runtime_suspend().

Fixes: 16531118ba63 ("iio: bmi323: peripheral in lowest power state on suspend")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 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 671401ce80dcf947b7b64ea3af112d2a42ca5501..64dbce23ce17bcdd11c0d4c454dbeb9de17ef56c 100644
--- a/drivers/iio/imu/bmi323/bmi323_core.c
+++ b/drivers/iio/imu/bmi323/bmi323_core.c
@@ -2199,7 +2199,7 @@ static int bmi323_core_runtime_suspend(struct device *dev)
 	}
 
 	for (unsigned int i = 0; i < ARRAY_SIZE(bmi323_ext_reg_savestate); i++) {
-		ret = bmi323_read_ext_reg(data, bmi323_reg_savestate[i],
+		ret = bmi323_read_ext_reg(data, bmi323_ext_reg_savestate[i],
 					  &savestate->reg_settings[i]);
 		if (ret) {
 			dev_err(data->dev,

---
base-commit: 5ba0cb92584ba5e107c97001e09013c1da0772a8
change-id: 20240909-iio-bmi323-fix-array-ref-a0672a8213f0

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


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

* Re: [PATCH] iio: bmi323: Fix array reference in bmi323_core_runtime_suspend()
  2024-09-09 16:38 [PATCH] iio: bmi323: Fix array reference in bmi323_core_runtime_suspend() Nathan Chancellor
@ 2024-09-09 19:10 ` Denis Benato
  2024-09-14 14:10   ` Jonathan Cameron
  2024-09-14 14:20   ` Jonathan Cameron
  0 siblings, 2 replies; 4+ messages in thread
From: Denis Benato @ 2024-09-09 19:10 UTC (permalink / raw)
  To: Nathan Chancellor, Jagath Jog J, Jonathan Cameron,
	Lars-Peter Clausen
  Cc: linux-iio, llvm, patches

On 09/09/24 18:38, Nathan Chancellor wrote:
> Clang warns (or errors with CONFIG_WERROR):
> 
>   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[] = {
>         |                           ^~~~~~~~~~~~~~~~~~~~~~~~
> 
> bmi323_ext_reg_savestate is only used within sizeof() through
> ARRAY_SIZE(), so it is not unused, but it will not be emitted in the
> final binary because sizeof() is evaluated only at compile time.
> bmi323_ext_reg_savestate should have been used in the second parameter
> in the call to bmi323_read_ext_reg() in the second for loop in
> bmi323_core_runtime_suspend().
> 
> Fixes: 16531118ba63 ("iio: bmi323: peripheral in lowest power state on suspend")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  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 671401ce80dcf947b7b64ea3af112d2a42ca5501..64dbce23ce17bcdd11c0d4c454dbeb9de17ef56c 100644
> --- a/drivers/iio/imu/bmi323/bmi323_core.c
> +++ b/drivers/iio/imu/bmi323/bmi323_core.c
> @@ -2199,7 +2199,7 @@ static int bmi323_core_runtime_suspend(struct device *dev)
>  	}
>  
>  	for (unsigned int i = 0; i < ARRAY_SIZE(bmi323_ext_reg_savestate); i++) {
> -		ret = bmi323_read_ext_reg(data, bmi323_reg_savestate[i],
> +		ret = bmi323_read_ext_reg(data, bmi323_ext_reg_savestate[i],
>  					  &savestate->reg_settings[i]);
>  		if (ret) {
>  			dev_err(data->dev,
> 
> ---
> base-commit: 5ba0cb92584ba5e107c97001e09013c1da0772a8
> change-id: 20240909-iio-bmi323-fix-array-ref-a0672a8213f0
> 
> Best regards,
Hello Nathan,

Thank you kindly for spotting and fixing it.

Regrettably while integrating suggestions I received I also changed the patch semantic and due to my hardware not having the irq pin connected to the cpu this went unnoticed.

Best regards,
Denis Benato

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

* Re: [PATCH] iio: bmi323: Fix array reference in bmi323_core_runtime_suspend()
  2024-09-09 19:10 ` Denis Benato
@ 2024-09-14 14:10   ` Jonathan Cameron
  2024-09-14 14:20   ` Jonathan Cameron
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2024-09-14 14:10 UTC (permalink / raw)
  To: Denis Benato
  Cc: Nathan Chancellor, Jagath Jog J, Lars-Peter Clausen, linux-iio,
	llvm, patches

On Mon, 9 Sep 2024 21:10:35 +0200
Denis Benato <benato.denis96@gmail.com> wrote:

> On 09/09/24 18:38, Nathan Chancellor wrote:
> > Clang warns (or errors with CONFIG_WERROR):
> > 
> >   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[] = {
> >         |                           ^~~~~~~~~~~~~~~~~~~~~~~~
> > 
> > bmi323_ext_reg_savestate is only used within sizeof() through
> > ARRAY_SIZE(), so it is not unused, but it will not be emitted in the
> > final binary because sizeof() is evaluated only at compile time.
> > bmi323_ext_reg_savestate should have been used in the second parameter
> > in the call to bmi323_read_ext_reg() in the second for loop in
> > bmi323_core_runtime_suspend().
> > 
> > Fixes: 16531118ba63 ("iio: bmi323: peripheral in lowest power state on suspend")
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> >  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 671401ce80dcf947b7b64ea3af112d2a42ca5501..64dbce23ce17bcdd11c0d4c454dbeb9de17ef56c 100644
> > --- a/drivers/iio/imu/bmi323/bmi323_core.c
> > +++ b/drivers/iio/imu/bmi323/bmi323_core.c
> > @@ -2199,7 +2199,7 @@ static int bmi323_core_runtime_suspend(struct device *dev)
> >  	}
> >  
> >  	for (unsigned int i = 0; i < ARRAY_SIZE(bmi323_ext_reg_savestate); i++) {
> > -		ret = bmi323_read_ext_reg(data, bmi323_reg_savestate[i],
> > +		ret = bmi323_read_ext_reg(data, bmi323_ext_reg_savestate[i],
> >  					  &savestate->reg_settings[i]);
> >  		if (ret) {
> >  			dev_err(data->dev,
> > 
> > ---
> > base-commit: 5ba0cb92584ba5e107c97001e09013c1da0772a8
> > change-id: 20240909-iio-bmi323-fix-array-ref-a0672a8213f0
> > 
> > Best regards,  
> Hello Nathan,
> 
> Thank you kindly for spotting and fixing it.
> 
> Regrettably while integrating suggestions I received I also changed the patch semantic and due to my hardware not having the irq pin connected to the cpu this went unnoticed.
> 
Slight delay on these due to the likely opening of the merge window
meaning I probably won't get another pull request in.  That's fine
as these are fixes and can go in during rc1, but until rc1 is released
I won't have the driver in my fixes tree upstream.

Anyhow upshot is that I'll sit on this and the CONFIG_PM one until
after RC1.

Thanks,

Jonathan

> Best regards,
> Denis Benato


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

* Re: [PATCH] iio: bmi323: Fix array reference in bmi323_core_runtime_suspend()
  2024-09-09 19:10 ` Denis Benato
  2024-09-14 14:10   ` Jonathan Cameron
@ 2024-09-14 14:20   ` Jonathan Cameron
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2024-09-14 14:20 UTC (permalink / raw)
  To: Denis Benato
  Cc: Nathan Chancellor, Jagath Jog J, Lars-Peter Clausen, linux-iio,
	llvm, patches

On Mon, 9 Sep 2024 21:10:35 +0200
Denis Benato <benato.denis96@gmail.com> wrote:

> On 09/09/24 18:38, Nathan Chancellor wrote:
> > Clang warns (or errors with CONFIG_WERROR):
> > 
> >   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[] = {
> >         |                           ^~~~~~~~~~~~~~~~~~~~~~~~
> > 
> > bmi323_ext_reg_savestate is only used within sizeof() through
> > ARRAY_SIZE(), so it is not unused, but it will not be emitted in the
> > final binary because sizeof() is evaluated only at compile time.
> > bmi323_ext_reg_savestate should have been used in the second parameter
> > in the call to bmi323_read_ext_reg() in the second for loop in
> > bmi323_core_runtime_suspend().
> > 
> > Fixes: 16531118ba63 ("iio: bmi323: peripheral in lowest power state on suspend")
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> >  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 671401ce80dcf947b7b64ea3af112d2a42ca5501..64dbce23ce17bcdd11c0d4c454dbeb9de17ef56c 100644
> > --- a/drivers/iio/imu/bmi323/bmi323_core.c
> > +++ b/drivers/iio/imu/bmi323/bmi323_core.c
> > @@ -2199,7 +2199,7 @@ static int bmi323_core_runtime_suspend(struct device *dev)
> >  	}
> >  
> >  	for (unsigned int i = 0; i < ARRAY_SIZE(bmi323_ext_reg_savestate); i++) {
> > -		ret = bmi323_read_ext_reg(data, bmi323_reg_savestate[i],
> > +		ret = bmi323_read_ext_reg(data, bmi323_ext_reg_savestate[i],
> >  					  &savestate->reg_settings[i]);
This is saving it in the wrong place.
Noticed as Dan sent out another patch for this that was different.

So I'll pick up his instead.  Note that similar bug exists in resume.

Jonathan

> >  		if (ret) {
> >  			dev_err(data->dev,
> > 
> > ---
> > base-commit: 5ba0cb92584ba5e107c97001e09013c1da0772a8
> > change-id: 20240909-iio-bmi323-fix-array-ref-a0672a8213f0
> > 
> > Best regards,  
> Hello Nathan,
> 
> Thank you kindly for spotting and fixing it.
> 
> Regrettably while integrating suggestions I received I also changed the patch semantic and due to my hardware not having the irq pin connected to the cpu this went unnoticed.
> 
> Best regards,
> Denis Benato


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

end of thread, other threads:[~2024-09-14 14:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-09 16:38 [PATCH] iio: bmi323: Fix array reference in bmi323_core_runtime_suspend() Nathan Chancellor
2024-09-09 19:10 ` Denis Benato
2024-09-14 14:10   ` Jonathan Cameron
2024-09-14 14:20   ` Jonathan Cameron

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