https://git.reactos.org/?p=reactos.git;a=commitdiff;h=81860b482a745b86572fb…
commit 81860b482a745b86572fb4804aa28c3481117fac
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Tue Nov 12 20:39:48 2024 +0100
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Tue Nov 12 21:26:42 2024 +0100
[CMBATT] Fix battery Tag
0 (ie BATTERY_TAG_INVALID) is not a valid battery tag.
First battery must have a tag of 1.
---
drivers/bus/acpi/cmbatt/cmbatt.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/bus/acpi/cmbatt/cmbatt.c b/drivers/bus/acpi/cmbatt/cmbatt.c
index 09d9c81d837..3935a9c8150 100644
--- a/drivers/bus/acpi/cmbatt/cmbatt.c
+++ b/drivers/bus/acpi/cmbatt/cmbatt.c
@@ -568,7 +568,6 @@ CmBattQueryTag(IN PCMBATT_DEVICE_EXTENSION DeviceExtension,
{
PDEVICE_OBJECT PdoDevice;
ULONG StaData;
- ULONG NewTag;
NTSTATUS Status;
PAGED_CODE();
if (CmBattDebug & (CMBATT_ACPI_WARNING | CMBATT_GENERIC_INFO))
@@ -587,12 +586,12 @@ CmBattQueryTag(IN PCMBATT_DEVICE_EXTENSION DeviceExtension,
if (StaData & ACPI_STA_BATTERY_PRESENT)
{
/* Do we not have a tag yet? */
- if (!DeviceExtension->Tag)
+ if (DeviceExtension->Tag == BATTERY_TAG_INVALID)
{
/* Set the new tag value, reset tags if we reached the maximum */
- NewTag = DeviceExtension->TagData;
- if (DeviceExtension->TagData++ == 0xFFFFFFFF) NewTag = 1;
- DeviceExtension->Tag = NewTag;
+ if (++DeviceExtension->TagData == BATTERY_TAG_INVALID)
+ DeviceExtension->TagData = 1;
+ DeviceExtension->Tag = DeviceExtension->TagData;
if (CmBattDebug & CMBATT_GENERIC_INFO)
DbgPrint("CmBattQueryTag - New Tag: (%d)\n",
DeviceExtension->Tag);
@@ -608,7 +607,7 @@ CmBattQueryTag(IN PCMBATT_DEVICE_EXTENSION DeviceExtension,
else
{
/* No battery, so no tag */
- DeviceExtension->Tag = 0;
+ DeviceExtension->Tag = BATTERY_TAG_INVALID;
Status = STATUS_NO_SUCH_DEVICE;
}
}