[CMBATT] Fix battery Tag
authorHervé Poussineau <hpoussin@reactos.org>
Tue, 12 Nov 2024 19:39:48 +0000 (20:39 +0100)
committerHervé Poussineau <hpoussin@reactos.org>
Tue, 12 Nov 2024 20:26:42 +0000 (21:26 +0100)
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

index 09d9c81..3935a9c 100644 (file)
@@ -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;
         }
     }