* [PATCH] power: supply: bq256xx: drop always-true inner condition
@ 2026-07-02 19:45 Anas Khan
2026-07-20 23:12 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Anas Khan @ 2026-07-02 19:45 UTC (permalink / raw)
To: Sebastian Reichel; +Cc: linux-pm, linux-kernel, Anas Khan
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] power: supply: bq256xx: drop always-true inner condition
2026-07-02 19:45 [PATCH] power: supply: bq256xx: drop always-true inner condition Anas Khan
@ 2026-07-20 23:12 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2026-07-20 23:12 UTC (permalink / raw)
To: Sebastian Reichel, Anas Khan; +Cc: linux-pm, linux-kernel
On Fri, 03 Jul 2026 01:15:47 +0530, Anas Khan wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] power: supply: bq256xx: drop always-true inner condition
commit: c41f57bb3b65fe0b2f5f556752dc03ac66b8c5db
Best regards,
--
Sebastian Reichel <sebastian.reichel@collabora.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-20 23:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-02 19:45 [PATCH] power: supply: bq256xx: drop always-true inner condition Anas Khan
2026-07-20 23:12 ` Sebastian Reichel
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®