axp2101: fix the enable test in axp2101_supply_get_voltage()

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit a13368d0d65ea61d1c4ef4f7a9006a04d6f8e761
Author: Michael McAllister <[email protected]>
Date:   Sun Aug 9 23:21:02 2026 +0100

    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

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;
     }
 
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.