public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Jagath Jog J <jagathjog1996@gmail.com>,
	 Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	 Denis Benato <benato.denis96@gmail.com>
Cc: linux-iio@vger.kernel.org, llvm@lists.linux.dev,
	 patches@lists.linux.dev, Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH] iio: bmi323: Fix array reference in bmi323_core_runtime_suspend()
Date: Mon, 09 Sep 2024 09:38:04 -0700	[thread overview]
Message-ID: <20240909-iio-bmi323-fix-array-ref-v1-1-51c220f22229@kernel.org> (raw)

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>


             reply	other threads:[~2024-09-09 16:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-09 16:38 Nathan Chancellor [this message]
2024-09-09 19:10 ` [PATCH] iio: bmi323: Fix array reference in bmi323_core_runtime_suspend() Denis Benato
2024-09-14 14:10   ` Jonathan Cameron
2024-09-14 14:20   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240909-iio-bmi323-fix-array-ref-v1-1-51c220f22229@kernel.org \
    --to=nathan@kernel.org \
    --cc=benato.denis96@gmail.com \
    --cc=jagathjog1996@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=patches@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox