From a13368d0d65ea61d1c4ef4f7a9006a04d6f8e761 Mon Sep 17 00:00:00 2001 From: Michael McAllister Date: Sun, 9 Aug 2026 23:21:02 +0100 Subject: [PATCH] axp2101: fix the enable test in axp2101_supply_get_voltage() The enable check read if(r & (1 << info->en_bit) == 0) `==` binds tighter than `&`, so this evaluates as `r & ((1 << bit) == 0)`, i.e. `r & 0`, which is always false. The check never fired, and a supply that was switched off reported the voltage it would have had if enabled. Callers cannot tell "off" from "on at this voltage", so anything reading a rail back to confirm it came up gets a false confirmation. Found by inspection while bringing up another Ingenic target. Not run on X1000 hardware as I do not have one of these devices. Change-Id: I19fc89ff33cce047160d826ce2344cc34b26e224 Co-Authored-By: Claude Opus 4.8 --- firmware/drivers/axp-2101.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/drivers/axp-2101.c b/firmware/drivers/axp-2101.c index 7cac31eb9c..a0797d72f1 100644 --- a/firmware/drivers/axp-2101.c +++ b/firmware/drivers/axp-2101.c @@ -355,7 +355,7 @@ int axp2101_supply_get_voltage(int supply) int r = i2c_reg_read1(AXP_PMU_BUS, AXP_PMU_ADDR, info->en_reg); if(r < 0) return AXP2101_SUPPLY_DISABLED; - if(r & (1 << info->en_bit) == 0) + if((r & (1 << info->en_bit)) == 0) return AXP2101_SUPPLY_DISABLED; }