ACPI: bus: Simplify installation and removal of notify callback
Because the only drivers that cared about button fixed events take care of those events by themselves now, eliminate the code related to them from acpi_device_install_notify_handler() and acpi_device_remove_notify_handler(). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
ff1d7aea83
commit
365eac5ef2
|
@ -530,65 +530,30 @@ static void acpi_notify_device(acpi_handle handle, u32 event, void *data)
|
||||||
acpi_drv->ops.notify(device, event);
|
acpi_drv->ops.notify(device, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void acpi_notify_device_fixed(void *data)
|
|
||||||
{
|
|
||||||
struct acpi_device *device = data;
|
|
||||||
|
|
||||||
/* Fixed hardware devices have no handles */
|
|
||||||
acpi_notify_device(NULL, ACPI_FIXED_HARDWARE_EVENT, device);
|
|
||||||
}
|
|
||||||
|
|
||||||
static u32 acpi_device_fixed_event(void *data)
|
|
||||||
{
|
|
||||||
acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_notify_device_fixed, data);
|
|
||||||
return ACPI_INTERRUPT_HANDLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int acpi_device_install_notify_handler(struct acpi_device *device,
|
static int acpi_device_install_notify_handler(struct acpi_device *device,
|
||||||
struct acpi_driver *acpi_drv)
|
struct acpi_driver *acpi_drv)
|
||||||
{
|
{
|
||||||
|
u32 type = acpi_drv->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS ?
|
||||||
|
ACPI_ALL_NOTIFY : ACPI_DEVICE_NOTIFY;
|
||||||
acpi_status status;
|
acpi_status status;
|
||||||
|
|
||||||
if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) {
|
status = acpi_install_notify_handler(device->handle, type,
|
||||||
status =
|
acpi_notify_device, device);
|
||||||
acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
|
|
||||||
acpi_device_fixed_event,
|
|
||||||
device);
|
|
||||||
} else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) {
|
|
||||||
status =
|
|
||||||
acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
|
|
||||||
acpi_device_fixed_event,
|
|
||||||
device);
|
|
||||||
} else {
|
|
||||||
u32 type = acpi_drv->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS ?
|
|
||||||
ACPI_ALL_NOTIFY : ACPI_DEVICE_NOTIFY;
|
|
||||||
|
|
||||||
status = acpi_install_notify_handler(device->handle, type,
|
|
||||||
acpi_notify_device,
|
|
||||||
device);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ACPI_FAILURE(status))
|
if (ACPI_FAILURE(status))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void acpi_device_remove_notify_handler(struct acpi_device *device,
|
static void acpi_device_remove_notify_handler(struct acpi_device *device,
|
||||||
struct acpi_driver *acpi_drv)
|
struct acpi_driver *acpi_drv)
|
||||||
{
|
{
|
||||||
if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) {
|
u32 type = acpi_drv->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS ?
|
||||||
acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
|
|
||||||
acpi_device_fixed_event);
|
|
||||||
} else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) {
|
|
||||||
acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
|
|
||||||
acpi_device_fixed_event);
|
|
||||||
} else {
|
|
||||||
u32 type = acpi_drv->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS ?
|
|
||||||
ACPI_ALL_NOTIFY : ACPI_DEVICE_NOTIFY;
|
ACPI_ALL_NOTIFY : ACPI_DEVICE_NOTIFY;
|
||||||
|
|
||||||
acpi_remove_notify_handler(device->handle, type,
|
acpi_remove_notify_handler(device->handle, type,
|
||||||
acpi_notify_device);
|
acpi_notify_device);
|
||||||
}
|
|
||||||
acpi_os_wait_events_complete();
|
acpi_os_wait_events_complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue