aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2011-08-05 22:16:42 -0400
committerLen Brown <len.brown@intel.com>2011-08-05 22:16:42 -0400
commit5389102e231d5f06da8b2897336293db18af9d76 (patch)
tree39f7a1afe053ef8457f568cf4e1f9e960d1e6916
parentde96355c111679dd6e2c5c73e25e814c72510c58 (diff)
parent69d94ec6d83d84044252d9ba03f6a8970816e350 (diff)
Merge branch 'battery' into release
-rw-r--r--drivers/acpi/battery.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 87c0a8daa99a..7711d94a0409 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -99,6 +99,7 @@ enum {
99 99
100struct acpi_battery { 100struct acpi_battery {
101 struct mutex lock; 101 struct mutex lock;
102 struct mutex sysfs_lock;
102 struct power_supply bat; 103 struct power_supply bat;
103 struct acpi_device *device; 104 struct acpi_device *device;
104 struct notifier_block pm_nb; 105 struct notifier_block pm_nb;
@@ -573,16 +574,16 @@ static int sysfs_add_battery(struct acpi_battery *battery)
573 574
574static void sysfs_remove_battery(struct acpi_battery *battery) 575static void sysfs_remove_battery(struct acpi_battery *battery)
575{ 576{
576 mutex_lock(&battery->lock); 577 mutex_lock(&battery->sysfs_lock);
577 if (!battery->bat.dev) { 578 if (!battery->bat.dev) {
578 mutex_unlock(&battery->lock); 579 mutex_unlock(&battery->sysfs_lock);
579 return; 580 return;
580 } 581 }
581 582
582 device_remove_file(battery->bat.dev, &alarm_attr); 583 device_remove_file(battery->bat.dev, &alarm_attr);
583 power_supply_unregister(&battery->bat); 584 power_supply_unregister(&battery->bat);
584 battery->bat.dev = NULL; 585 battery->bat.dev = NULL;
585 mutex_unlock(&battery->lock); 586 mutex_unlock(&battery->sysfs_lock);
586} 587}
587 588
588/* 589/*
@@ -982,6 +983,7 @@ static int acpi_battery_add(struct acpi_device *device)
982 strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); 983 strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
983 device->driver_data = battery; 984 device->driver_data = battery;
984 mutex_init(&battery->lock); 985 mutex_init(&battery->lock);
986 mutex_init(&battery->sysfs_lock);
985 if (ACPI_SUCCESS(acpi_get_handle(battery->device->handle, 987 if (ACPI_SUCCESS(acpi_get_handle(battery->device->handle,
986 "_BIX", &handle))) 988 "_BIX", &handle)))
987 set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags); 989 set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
@@ -1010,6 +1012,7 @@ static int acpi_battery_add(struct acpi_device *device)
1010fail: 1012fail:
1011 sysfs_remove_battery(battery); 1013 sysfs_remove_battery(battery);
1012 mutex_destroy(&battery->lock); 1014 mutex_destroy(&battery->lock);
1015 mutex_destroy(&battery->sysfs_lock);
1013 kfree(battery); 1016 kfree(battery);
1014 return result; 1017 return result;
1015} 1018}
@@ -1027,6 +1030,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
1027#endif 1030#endif
1028 sysfs_remove_battery(battery); 1031 sysfs_remove_battery(battery);
1029 mutex_destroy(&battery->lock); 1032 mutex_destroy(&battery->lock);
1033 mutex_destroy(&battery->sysfs_lock);
1030 kfree(battery); 1034 kfree(battery);
1031 return 0; 1035 return 0;
1032} 1036}