99
99
100
100
struct acpi_battery {
101
101
struct mutex lock ;
102
+ struct mutex sysfs_lock ;
102
103
struct power_supply bat ;
103
104
struct acpi_device * device ;
104
105
struct notifier_block pm_nb ;
@@ -573,16 +574,16 @@ static int sysfs_add_battery(struct acpi_battery *battery)
573
574
574
575
static void sysfs_remove_battery (struct acpi_battery * battery )
575
576
{
576
- mutex_lock (& battery -> lock );
577
+ mutex_lock (& battery -> sysfs_lock );
577
578
if (!battery -> bat .dev ) {
578
- mutex_unlock (& battery -> lock );
579
+ mutex_unlock (& battery -> sysfs_lock );
579
580
return ;
580
581
}
581
582
582
583
device_remove_file (battery -> bat .dev , & alarm_attr );
583
584
power_supply_unregister (& battery -> bat );
584
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
983
strcpy (acpi_device_class (device ), ACPI_BATTERY_CLASS );
983
984
device -> driver_data = battery ;
984
985
mutex_init (& battery -> lock );
986
+ mutex_init (& battery -> sysfs_lock );
985
987
if (ACPI_SUCCESS (acpi_get_handle (battery -> device -> handle ,
986
988
"_BIX" , & handle )))
987
989
set_bit (ACPI_BATTERY_XINFO_PRESENT , & battery -> flags );
@@ -1010,6 +1012,7 @@ static int acpi_battery_add(struct acpi_device *device)
1010
1012
fail :
1011
1013
sysfs_remove_battery (battery );
1012
1014
mutex_destroy (& battery -> lock );
1015
+ mutex_destroy (& battery -> sysfs_lock );
1013
1016
kfree (battery );
1014
1017
return result ;
1015
1018
}
@@ -1027,6 +1030,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
1027
1030
#endif
1028
1031
sysfs_remove_battery (battery );
1029
1032
mutex_destroy (& battery -> lock );
1033
+ mutex_destroy (& battery -> sysfs_lock );
1030
1034
kfree (battery );
1031
1035
return 0 ;
1032
1036
}
0 commit comments