提交 5b31d895 编写于 作者: L Len Brown

Revert "ACPI: Battery: Synchronize battery operations."

This reverts commit 3bd92ba1.

It is no longer necessary, and it opens up a race.
Acked-by: NVladimir Lebedev <vladimir.p.lebedev@gmail.com>
Acked-by: NAlexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 28e8351a
...@@ -113,7 +113,7 @@ struct acpi_battery_info { ...@@ -113,7 +113,7 @@ struct acpi_battery_info {
acpi_string oem_info; acpi_string oem_info;
}; };
enum acpi_battery_files { enum acpi_battery_files{
ACPI_BATTERY_INFO = 0, ACPI_BATTERY_INFO = 0,
ACPI_BATTERY_STATE, ACPI_BATTERY_STATE,
ACPI_BATTERY_ALARM, ACPI_BATTERY_ALARM,
...@@ -129,14 +129,13 @@ struct acpi_battery_flags { ...@@ -129,14 +129,13 @@ struct acpi_battery_flags {
}; };
struct acpi_battery { struct acpi_battery {
struct mutex mutex;
struct acpi_device *device; struct acpi_device *device;
struct acpi_battery_flags flags; struct acpi_battery_flags flags;
struct acpi_buffer bif_data; struct acpi_buffer bif_data;
struct acpi_buffer bst_data; struct acpi_buffer bst_data;
struct mutex lock;
unsigned long alarm; unsigned long alarm;
unsigned long update_time[ACPI_BATTERY_NUMFILES]; unsigned long update_time[ACPI_BATTERY_NUMFILES];
}; };
inline int acpi_battery_present(struct acpi_battery *battery) inline int acpi_battery_present(struct acpi_battery *battery)
...@@ -236,10 +235,10 @@ static int acpi_battery_get_info(struct acpi_battery *battery) ...@@ -236,10 +235,10 @@ static int acpi_battery_get_info(struct acpi_battery *battery)
return 0; return 0;
/* Evaluate _BIF */ /* Evaluate _BIF */
mutex_lock(&battery->lock);
status = acpi_evaluate_object(acpi_battery_handle(battery), "_BIF", status =
NULL, &buffer); acpi_evaluate_object(acpi_battery_handle(battery), "_BIF", NULL,
mutex_unlock(&battery->lock); &buffer);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF")); ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
return -ENODEV; return -ENODEV;
...@@ -286,10 +285,10 @@ static int acpi_battery_get_state(struct acpi_battery *battery) ...@@ -286,10 +285,10 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
return 0; return 0;
/* Evaluate _BST */ /* Evaluate _BST */
mutex_lock(&battery->lock);
status = acpi_evaluate_object(acpi_battery_handle(battery), "_BST", status =
NULL, &buffer); acpi_evaluate_object(acpi_battery_handle(battery), "_BST", NULL,
mutex_unlock(&battery->lock); &buffer);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST")); ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
return -ENODEV; return -ENODEV;
...@@ -337,10 +336,9 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery, ...@@ -337,10 +336,9 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery,
arg0.integer.value = alarm; arg0.integer.value = alarm;
mutex_lock(&battery->lock); status =
status = acpi_evaluate_object(acpi_battery_handle(battery), "_BTP", acpi_evaluate_object(acpi_battery_handle(battery), "_BTP",
&arg_list, NULL); &arg_list, NULL);
mutex_unlock(&battery->lock);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
return -ENODEV; return -ENODEV;
...@@ -660,6 +658,8 @@ acpi_battery_write_alarm(struct file *file, ...@@ -660,6 +658,8 @@ acpi_battery_write_alarm(struct file *file,
if (!battery || (count > sizeof(alarm_string) - 1)) if (!battery || (count > sizeof(alarm_string) - 1))
return -EINVAL; return -EINVAL;
mutex_lock(&battery->mutex);
result = acpi_battery_update(battery, 1, &update_result); result = acpi_battery_update(battery, 1, &update_result);
if (result) { if (result) {
result = -ENODEV; result = -ENODEV;
...@@ -688,7 +688,9 @@ acpi_battery_write_alarm(struct file *file, ...@@ -688,7 +688,9 @@ acpi_battery_write_alarm(struct file *file,
acpi_battery_check_result(battery, result); acpi_battery_check_result(battery, result);
if (!result) if (!result)
return count; result = count;
mutex_unlock(&battery->mutex);
return result; return result;
} }
...@@ -712,6 +714,8 @@ static int acpi_battery_read(int fid, struct seq_file *seq) ...@@ -712,6 +714,8 @@ static int acpi_battery_read(int fid, struct seq_file *seq)
int update_result = ACPI_BATTERY_NONE_UPDATE; int update_result = ACPI_BATTERY_NONE_UPDATE;
int update = 0; int update = 0;
mutex_lock(&battery->mutex);
update = (get_seconds() - battery->update_time[fid] >= update_time); update = (get_seconds() - battery->update_time[fid] >= update_time);
update = (update | battery->flags.update[fid]); update = (update | battery->flags.update[fid]);
...@@ -729,6 +733,7 @@ static int acpi_battery_read(int fid, struct seq_file *seq) ...@@ -729,6 +733,7 @@ static int acpi_battery_read(int fid, struct seq_file *seq)
result = acpi_read_funcs[fid].print(seq, result); result = acpi_read_funcs[fid].print(seq, result);
acpi_battery_check_result(battery, result); acpi_battery_check_result(battery, result);
battery->flags.update[fid] = result; battery->flags.update[fid] = result;
mutex_unlock(&battery->mutex);
return result; return result;
} }
...@@ -892,7 +897,10 @@ static int acpi_battery_add(struct acpi_device *device) ...@@ -892,7 +897,10 @@ static int acpi_battery_add(struct acpi_device *device)
if (!battery) if (!battery)
return -ENOMEM; return -ENOMEM;
mutex_init(&battery->lock); mutex_init(&battery->mutex);
mutex_lock(&battery->mutex);
battery->device = device; battery->device = device;
strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
...@@ -928,6 +936,7 @@ static int acpi_battery_add(struct acpi_device *device) ...@@ -928,6 +936,7 @@ static int acpi_battery_add(struct acpi_device *device)
kfree(battery); kfree(battery);
} }
mutex_unlock(&battery->mutex);
return result; return result;
} }
...@@ -942,6 +951,8 @@ static int acpi_battery_remove(struct acpi_device *device, int type) ...@@ -942,6 +951,8 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
battery = acpi_driver_data(device); battery = acpi_driver_data(device);
mutex_lock(&battery->mutex);
status = acpi_remove_notify_handler(device->handle, status = acpi_remove_notify_handler(device->handle,
ACPI_ALL_NOTIFY, ACPI_ALL_NOTIFY,
acpi_battery_notify); acpi_battery_notify);
...@@ -952,7 +963,9 @@ static int acpi_battery_remove(struct acpi_device *device, int type) ...@@ -952,7 +963,9 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
kfree(battery->bst_data.pointer); kfree(battery->bst_data.pointer);
mutex_destroy(&battery->lock); mutex_unlock(&battery->mutex);
mutex_destroy(&battery->mutex);
kfree(battery); kfree(battery);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册