From 35608e295ddaa304077ef6457364c0e6daa7e711 Mon Sep 17 00:00:00 2001 From: Oleksii Shcherbyna Date: Wed, 30 Apr 2025 12:00:14 +0300 Subject: [PATCH] drivers: fuel_gauge: Fix incorrect variable in bq27xx chem_id switch The bq27xx driver incorrectly uses the 'val' variable in a switch() statement that should operate on 'chem_id'. This leads to incorrect behavior for fuel gauges such as the BQ27427, where the chemical ID determines how properties are interpreted. This commit replaces 'switch(val)' with 'switch(chem_id)' to ensure proper handling of fuel gauge behavior across supported devices. Signed-off-by: Oleksii Shcherbyna --- drivers/sensor/ti/bq274xx/bq274xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/sensor/ti/bq274xx/bq274xx.c b/drivers/sensor/ti/bq274xx/bq274xx.c index b4e5684c321..d4b3e302a93 100644 --- a/drivers/sensor/ti/bq274xx/bq274xx.c +++ b/drivers/sensor/ti/bq274xx/bq274xx.c @@ -363,7 +363,7 @@ static int bq274xx_ensure_chemistry(const struct device *dev) uint16_t cmd; - switch (val) { + switch (chem_id) { case BQ27427_CHEM_ID_A: cmd = BQ27427_CTRL_CHEM_A; break;