X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=drivers%2Facpi%2Fscan.c;h=20c23c04920777259fc426acc7a9154d612a8cd0;hb=38d9aefb5ce8f26358b0d5cd933cfa9e267105b1;hp=c54d7b6c406680b5b82d0df4e0aa9b1a0ac8688d;hpb=33dbe6114047496a5b6fee0941c52dad41250043;p=mv-sheeva.git diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index c54d7b6c406..20c23c04920 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -11,6 +11,8 @@ #include +#include "internal.h" + #define _COMPONENT ACPI_BUS_COMPONENT ACPI_MODULE_NAME("scan"); #define STRUCT_TO_INT(s) (*((int*)&s)) @@ -357,6 +359,61 @@ static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env) return 0; } +static void acpi_device_notify(acpi_handle handle, u32 event, void *data) +{ + struct acpi_device *device = data; + + device->driver->ops.notify(device, event); +} + +static acpi_status acpi_device_notify_fixed(void *data) +{ + struct acpi_device *device = data; + + acpi_device_notify(device->handle, ACPI_FIXED_HARDWARE_EVENT, device); + return AE_OK; +} + +static int acpi_device_install_notify_handler(struct acpi_device *device) +{ + acpi_status status; + char *hid; + + hid = acpi_device_hid(device); + if (!strcmp(hid, ACPI_BUTTON_HID_POWERF)) + status = + acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, + acpi_device_notify_fixed, + device); + else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) + status = + acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, + acpi_device_notify_fixed, + device); + else + status = acpi_install_notify_handler(device->handle, + ACPI_DEVICE_NOTIFY, + acpi_device_notify, + device); + + if (ACPI_FAILURE(status)) + return -EINVAL; + return 0; +} + +static void acpi_device_remove_notify_handler(struct acpi_device *device) +{ + if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) + acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, + acpi_device_notify_fixed); + else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) + acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, + acpi_device_notify_fixed); + else + acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, + acpi_device_notify); +} + static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *); static int acpi_start_single_object(struct acpi_device *); static int acpi_device_probe(struct device * dev) @@ -369,6 +426,20 @@ static int acpi_device_probe(struct device * dev) if (!ret) { if (acpi_dev->bus_ops.acpi_op_start) acpi_start_single_object(acpi_dev); + + if (acpi_drv->ops.notify) { + ret = acpi_device_install_notify_handler(acpi_dev); + if (ret) { + if (acpi_drv->ops.stop) + acpi_drv->ops.stop(acpi_dev, + acpi_dev->removal_type); + if (acpi_drv->ops.remove) + acpi_drv->ops.remove(acpi_dev, + acpi_dev->removal_type); + return ret; + } + } + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n", acpi_drv->name, acpi_dev->pnp.bus_id)); @@ -383,6 +454,8 @@ static int acpi_device_remove(struct device * dev) struct acpi_driver *acpi_drv = acpi_dev->driver; if (acpi_drv) { + if (acpi_drv->ops.notify) + acpi_device_remove_notify_handler(acpi_dev); if (acpi_drv->ops.stop) acpi_drv->ops.stop(acpi_dev, acpi_dev->removal_type); if (acpi_drv->ops.remove) @@ -395,22 +468,10 @@ static int acpi_device_remove(struct device * dev) return 0; } -static void acpi_device_shutdown(struct device *dev) -{ - struct acpi_device *acpi_dev = to_acpi_device(dev); - struct acpi_driver *acpi_drv = acpi_dev->driver; - - if (acpi_drv && acpi_drv->ops.shutdown) - acpi_drv->ops.shutdown(acpi_dev); - - return ; -} - struct bus_type acpi_bus_type = { .name = "acpi", .suspend = acpi_device_suspend, .resume = acpi_device_resume, - .shutdown = acpi_device_shutdown, .match = acpi_bus_match, .probe = acpi_device_probe, .remove = acpi_device_remove, @@ -1524,16 +1585,11 @@ static int acpi_bus_scan_fixed(struct acpi_device *root) return result; } - -static int __init acpi_scan_init(void) +int __init acpi_scan_init(void) { int result; struct acpi_bus_ops ops; - - if (acpi_disabled) - return 0; - memset(&ops, 0, sizeof(ops)); ops.acpi_op_add = 1; ops.acpi_op_start = 1; @@ -1566,5 +1622,3 @@ static int __init acpi_scan_init(void) Done: return result; } - -subsys_initcall(acpi_scan_init);