From 7c4cc60a6c41dbe6b9991eb54e4a01d4594a9795 Mon Sep 17 00:00:00 2001 From: Sean Rhodes Date: Mon, 18 Mar 2024 13:35:40 +0000 Subject: ec/starlabs/merlin/battery: Check values are valid before using them Change-Id: I559aca98044b7f0e6b08c475b5383c014bb4cd3f Signed-off-by: Sean Rhodes Reviewed-on: https://review.coreboot.org/c/coreboot/+/81407 Reviewed-by: Matt DeVillier Tested-by: build bot (Jenkins) --- src/ec/starlabs/merlin/acpi/battery.asl | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/ec/starlabs/merlin/acpi') diff --git a/src/ec/starlabs/merlin/acpi/battery.asl b/src/ec/starlabs/merlin/acpi/battery.asl index 197be64f50..262969a338 100644 --- a/src/ec/starlabs/merlin/acpi/battery.asl +++ b/src/ec/starlabs/merlin/acpi/battery.asl @@ -38,13 +38,17 @@ Device (BAT0) { If (B1DC) { SBIF [1] = B1DC - SBIF [2] = B1FC + If (B1FC != 0xffff) { + SBIF [2] = B1FC + } SBIF [4] = B1DV SBIF [5] = B1DC / 5 // 20% SBIF [6] = B1DC / 20 // 5% SBIF [7] = B1DC / 500 // 0.2% SBIF [8] = B1DC / 500 // 0.2% - SBIF [10] = B1SN + If (B1SN != 0xffff) { + SBIF [10] = B1SN + } } Return (SBIF) } @@ -82,14 +86,20 @@ Device (BAT0) { If (B1DC) { XBIF [2] = B1DC - XBIF [3] = B1FC + If (B1FC != 0xffff) { + XBIF [3] = B1FC + } XBIF [5] = B1DV XBIF [6] = B1DC / 5 // 20% XBIF [7] = B1DC / 20 // 5% - XBIF [8] = B1CC + If (B1CC != 0xffff) { + XBIF [8] = B1CC + } XBIF [14] = B1DC / 500 // 0.2% XBIF [15] = B1DC / 500 // 0.2% - XBIF [17] = B1SN + If (B1SN != 0xffff) { + XBIF [17] = B1SN + } } Return (XBIF) } @@ -105,7 +115,9 @@ Device (BAT0) { PKG1[0] = (B1ST & 0x07) PKG1[1] = B1PR - PKG1[2] = B1RC + If (B1RC != 0xffff) { + PKG1[2] = B1RC + } PKG1[3] = B1PV Return (PKG1) } -- cgit v1.2.3