Newly inserted battery might differ from one just removed, so
authorAlexey Starikovskiy <astarikovskiy@suse.de>
Mon, 22 Dec 2008 23:44:54 +0000 (02:44 +0300)
committerLen Brown <len.brown@intel.com>
Tue, 23 Dec 2008 00:32:55 +0000 (19:32 -0500)
update of battery info fields is required.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Acked-by: Andy Neitzke <neitzke@ias.edu>
Signed-off-by: Alexey Starikovskiy <astarikovskiy <at> suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/acpi/battery.c

index 1423b0c0cd2eecc6e3c7b2f5c78746cee5fac4eb..65132f9204596eb9908b8e0424531ec682a8b731 100644 (file)
@@ -471,7 +471,7 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
 
 static int acpi_battery_update(struct acpi_battery *battery)
 {
-       int result;
+       int result, old_present = acpi_battery_present(battery);
        result = acpi_battery_get_status(battery);
        if (result)
                return result;
@@ -482,7 +482,8 @@ static int acpi_battery_update(struct acpi_battery *battery)
                return 0;
        }
 #endif
-       if (!battery->update_time) {
+       if (!battery->update_time ||
+           old_present != acpi_battery_present(battery)) {
                result = acpi_battery_get_info(battery);
                if (result)
                        return result;