]> rtime.felk.cvut.cz Git - linux-imx.git/commitdiff
ACPI / Battery: Add the check before refresh sysfs in the battery_notify()
authorLan Tianyu <tianyu.lan@intel.com>
Thu, 30 Jun 2011 03:33:58 +0000 (11:33 +0800)
committerLen Brown <len.brown@intel.com>
Thu, 14 Jul 2011 04:05:45 +0000 (00:05 -0400)
In the commit 25be5821, add the refresh sysfs when system resumes
from suspending. But it didn't check that the battery exists. This
will cause battery sysfs files added when the battery doesn't exist.
This patch add the check before refreshing.

https://bugzilla.kernel.org/show_bug.cgi?id=35642

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/acpi/battery.c

index 2fe7cfd956808222296ac45c68f754588869d34b..4ba339d0ea1920ef9bf4d16dc8d190cc27c3dda6 100644 (file)
@@ -949,8 +949,10 @@ static int battery_notify(struct notifier_block *nb,
        switch (mode) {
        case PM_POST_HIBERNATION:
        case PM_POST_SUSPEND:
-               sysfs_remove_battery(battery);
-               sysfs_add_battery(battery);
+               if (battery->bat.dev) {
+                       sysfs_remove_battery(battery);
+                       sysfs_add_battery(battery);
+               }
                break;
        }