ACPI: check battery status on resume for un/plug events during sleep
Add ->resume method to the ACPI battery handler to check if the battery state has changed during sleep. If yes, update the ACPI internal data structures for benefit of /proc/acpi/battery/. Signed-off-by: Jiri Kosina <jikos@jikos.cz> Cc: Stefan Seyfried <seife@suse.de> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
@@ -64,6 +64,7 @@ extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
|
|||||||
|
|
||||||
static int acpi_battery_add(struct acpi_device *device);
|
static int acpi_battery_add(struct acpi_device *device);
|
||||||
static int acpi_battery_remove(struct acpi_device *device, int type);
|
static int acpi_battery_remove(struct acpi_device *device, int type);
|
||||||
|
static int acpi_battery_resume(struct acpi_device *device, int status);
|
||||||
|
|
||||||
static struct acpi_driver acpi_battery_driver = {
|
static struct acpi_driver acpi_battery_driver = {
|
||||||
.name = ACPI_BATTERY_DRIVER_NAME,
|
.name = ACPI_BATTERY_DRIVER_NAME,
|
||||||
@@ -71,6 +72,7 @@ static struct acpi_driver acpi_battery_driver = {
|
|||||||
.ids = ACPI_BATTERY_HID,
|
.ids = ACPI_BATTERY_HID,
|
||||||
.ops = {
|
.ops = {
|
||||||
.add = acpi_battery_add,
|
.add = acpi_battery_add,
|
||||||
|
.resume = acpi_battery_resume,
|
||||||
.remove = acpi_battery_remove,
|
.remove = acpi_battery_remove,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -753,6 +755,18 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* this is needed to learn about changes made in suspended state */
|
||||||
|
static int acpi_battery_resume(struct acpi_device *device, int state)
|
||||||
|
{
|
||||||
|
struct acpi_battery *battery;
|
||||||
|
|
||||||
|
if (!device)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
battery = device->driver_data;
|
||||||
|
return acpi_battery_check(battery);
|
||||||
|
}
|
||||||
|
|
||||||
static int __init acpi_battery_init(void)
|
static int __init acpi_battery_init(void)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
Reference in New Issue
Block a user