Commit d9406691 authored by Bjorn Helgaas's avatar Bjorn Helgaas Committed by Len Brown

ACPI: battery: use .notify method instead of installing handler directly

This patch adds a .notify() method.  The presence of .notify() causes
Linux/ACPI to manage event handlers and notify handlers on our behalf,
so we don't have to install and remove them ourselves.

This driver apparently relies on seeing ALL notify events, not just
device-specific ones (because it used ACPI_ALL_NOTIFY).  We use the
ACPI_DRIVER_ALL_NOTIFY_EVENTS driver flag to request all events.
Signed-off-by: default avatarBjorn Helgaas <bjorn.helgaas@hp.com>
CC: Alexey Starikovskiy <alexey.y.starikovskiy@linux.intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 48fe1127
...@@ -796,13 +796,12 @@ static void acpi_battery_remove_fs(struct acpi_device *device) ...@@ -796,13 +796,12 @@ static void acpi_battery_remove_fs(struct acpi_device *device)
Driver Interface Driver Interface
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) static void acpi_battery_notify(struct acpi_device *device, u32 event)
{ {
struct acpi_battery *battery = data; struct acpi_battery *battery = acpi_driver_data(device);
struct acpi_device *device;
if (!battery) if (!battery)
return; return;
device = battery->device;
acpi_battery_update(battery); acpi_battery_update(battery);
acpi_bus_generate_proc_event(device, event, acpi_bus_generate_proc_event(device, event,
acpi_battery_present(battery)); acpi_battery_present(battery));
...@@ -819,7 +818,6 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) ...@@ -819,7 +818,6 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
static int acpi_battery_add(struct acpi_device *device) static int acpi_battery_add(struct acpi_device *device)
{ {
int result = 0; int result = 0;
acpi_status status = 0;
struct acpi_battery *battery = NULL; struct acpi_battery *battery = NULL;
if (!device) if (!device)
return -EINVAL; return -EINVAL;
...@@ -837,14 +835,6 @@ static int acpi_battery_add(struct acpi_device *device) ...@@ -837,14 +835,6 @@ static int acpi_battery_add(struct acpi_device *device)
if (result) if (result)
goto end; goto end;
#endif #endif
status = acpi_install_notify_handler(device->handle,
ACPI_ALL_NOTIFY,
acpi_battery_notify, battery);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "Installing notify handler"));
result = -ENODEV;
goto end;
}
printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n", printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device), ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
device->status.battery_present ? "present" : "absent"); device->status.battery_present ? "present" : "absent");
...@@ -860,15 +850,11 @@ static int acpi_battery_add(struct acpi_device *device) ...@@ -860,15 +850,11 @@ 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)
{ {
acpi_status status = 0;
struct acpi_battery *battery = NULL; struct acpi_battery *battery = NULL;
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return -EINVAL; return -EINVAL;
battery = acpi_driver_data(device); battery = acpi_driver_data(device);
status = acpi_remove_notify_handler(device->handle,
ACPI_ALL_NOTIFY,
acpi_battery_notify);
#ifdef CONFIG_ACPI_PROCFS_POWER #ifdef CONFIG_ACPI_PROCFS_POWER
acpi_battery_remove_fs(device); acpi_battery_remove_fs(device);
#endif #endif
...@@ -896,10 +882,12 @@ static struct acpi_driver acpi_battery_driver = { ...@@ -896,10 +882,12 @@ static struct acpi_driver acpi_battery_driver = {
.name = "battery", .name = "battery",
.class = ACPI_BATTERY_CLASS, .class = ACPI_BATTERY_CLASS,
.ids = battery_device_ids, .ids = battery_device_ids,
.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
.ops = { .ops = {
.add = acpi_battery_add, .add = acpi_battery_add,
.resume = acpi_battery_resume, .resume = acpi_battery_resume,
.remove = acpi_battery_remove, .remove = acpi_battery_remove,
.notify = acpi_battery_notify,
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment