diff options
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/battery.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index ffce2f06dd8d..8953b7087091 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -99,6 +99,7 @@ enum { | |||
99 | 99 | ||
100 | struct acpi_battery { | 100 | struct 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 | ||
574 | static void sysfs_remove_battery(struct acpi_battery *battery) | 575 | static 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) | |||
1010 | fail: | 1012 | fail: |
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 | } |