acpi_string oem_info;
};
-enum acpi_battery_files{
+enum acpi_battery_files {
ACPI_BATTERY_INFO = 0,
ACPI_BATTERY_STATE,
ACPI_BATTERY_ALARM,
};
struct acpi_battery {
- struct mutex mutex;
struct acpi_device *device;
struct acpi_battery_flags flags;
struct acpi_buffer bif_data;
struct acpi_buffer bst_data;
+ struct mutex lock;
unsigned long alarm;
unsigned long update_time[ACPI_BATTERY_NUMFILES];
+
};
inline int acpi_battery_present(struct acpi_battery *battery)
return 0;
/* Evaluate _BIF */
-
- status =
- acpi_evaluate_object(acpi_battery_handle(battery), "_BIF", NULL,
- &buffer);
+ mutex_lock(&battery->lock);
+ status = acpi_evaluate_object(acpi_battery_handle(battery), "_BIF",
+ NULL, &buffer);
+ mutex_unlock(&battery->lock);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
return -ENODEV;
return 0;
/* Evaluate _BST */
-
- status =
- acpi_evaluate_object(acpi_battery_handle(battery), "_BST", NULL,
- &buffer);
+ mutex_lock(&battery->lock);
+ status = acpi_evaluate_object(acpi_battery_handle(battery), "_BST",
+ NULL, &buffer);
+ mutex_unlock(&battery->lock);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
return -ENODEV;
arg0.integer.value = alarm;
- status =
- acpi_evaluate_object(acpi_battery_handle(battery), "_BTP",
+ mutex_lock(&battery->lock);
+ status = acpi_evaluate_object(acpi_battery_handle(battery), "_BTP",
&arg_list, NULL);
+ mutex_unlock(&battery->lock);
if (ACPI_FAILURE(status))
return -ENODEV;
if (!battery || (count > sizeof(alarm_string) - 1))
return -EINVAL;
- mutex_lock(&battery->mutex);
-
result = acpi_battery_update(battery, 1, &update_result);
if (result) {
result = -ENODEV;
acpi_battery_check_result(battery, result);
if (!result)
- result = count;
-
- mutex_unlock(&battery->mutex);
+ return count;
return result;
}
int update_result = ACPI_BATTERY_NONE_UPDATE;
int update = 0;
- mutex_lock(&battery->mutex);
-
update = (get_seconds() - battery->update_time[fid] >= update_time);
update = (update | battery->flags.update[fid]);
result = acpi_read_funcs[fid].print(seq, result);
acpi_battery_check_result(battery, result);
battery->flags.update[fid] = result;
- mutex_unlock(&battery->mutex);
return result;
}
if (!battery)
return -ENOMEM;
- mutex_init(&battery->mutex);
-
- mutex_lock(&battery->mutex);
-
+ mutex_init(&battery->lock);
battery->device = device;
strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
kfree(battery);
}
- mutex_unlock(&battery->mutex);
return result;
}
battery = acpi_driver_data(device);
- mutex_lock(&battery->mutex);
-
status = acpi_remove_notify_handler(device->handle,
ACPI_ALL_NOTIFY,
acpi_battery_notify);
kfree(battery->bst_data.pointer);
- mutex_unlock(&battery->mutex);
-
- mutex_destroy(&battery->mutex);
+ mutex_destroy(&battery->lock);
kfree(battery);