From: Anas Khan <anxkhn28@gmail.com>
To: Sebastian Reichel <sre@kernel.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Anas Khan <anxkhn28@gmail.com>
Subject: [PATCH] power: supply: bq256xx: drop always-true inner condition
Date: Fri, 3 Jul 2026 01:15:47 +0530 [thread overview]
Message-ID: <20260702194547.65209-1-anxkhn28@gmail.com> (raw)
In bq256xx_array_parse() the inner "if (val < array[i])" repeats the
second half of the enclosing "if (val > array[i - 1] && val < array[i])",
so it is always true and the "else return i" arm is dead code. The
function performs a round-down table lookup, so returning i - 1 for a
value that falls strictly between two entries is the intended result.
Collapse the redundant branch into a single "return i - 1;"; no
functional change.
Signed-off-by: Anas Khan <anxkhn28@gmail.com>
---
drivers/power/supply/bq256xx_charger.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c
index 5a6634fde837..e5042582da16 100644
--- a/drivers/power/supply/bq256xx_charger.c
+++ b/drivers/power/supply/bq256xx_charger.c
@@ -347,12 +347,8 @@ static int bq256xx_array_parse(int array_size, int val, const int array[])
if (val == array[i])
return i;
- if (val > array[i - 1] && val < array[i]) {
- if (val < array[i])
- return i - 1;
- else
- return i;
- }
+ if (val > array[i - 1] && val < array[i])
+ return i - 1;
}
return -EINVAL;
}
--
2.54.0
next reply other threads:[~2026-07-02 19:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 19:45 Anas Khan [this message]
2026-07-20 23:12 ` Sebastian Reichel
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=20260702194547.65209-1-anxkhn28@gmail.com \
--to=anxkhn28@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.org \
/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
all inboxes | Powered by JetHome®