acpi_status acpi_ev_init_global_lock_handler (void) { acpi_status status; ACPI_FUNCTION_TRACE ("ev_init_global_lock_handler"); acpi_gbl_global_lock_present = TRUE; status = acpi_install_fixed_event_handler (ACPI_EVENT_GLOBAL, acpi_ev_global_lock_handler, NULL); /* * If the global lock does not exist on this platform, the attempt * to enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick) * Map to AE_OK, but mark global lock as not present. * Any attempt to actually use the global lock will be flagged * with an error. */ if (status == AE_NO_HARDWARE_RESPONSE) { acpi_gbl_global_lock_present = FALSE; status = AE_OK; } return_ACPI_STATUS (status); }
acpi_status acpi_ev_init_global_lock_handler(void) { acpi_status status; ACPI_FUNCTION_TRACE(ev_init_global_lock_handler); /* Attempt installation of the global lock handler */ status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL, acpi_ev_global_lock_handler, NULL); /* * If the global lock does not exist on this platform, the attempt to * enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick). * Map to AE_OK, but mark global lock as not present. Any attempt to * actually use the global lock will be flagged with an error. */ if (status == AE_NO_HARDWARE_RESPONSE) { ACPI_ERROR((AE_INFO, "No response from Global Lock hardware, disabling lock")); acpi_gbl_global_lock_present = FALSE; return_ACPI_STATUS(AE_OK); } acpi_gbl_global_lock_present = TRUE; return_ACPI_STATUS(status); }
acpi_status acpi_ev_init_global_lock_handler(void) { acpi_status status; ACPI_FUNCTION_TRACE(ev_init_global_lock_handler); if (acpi_gbl_reduced_hardware) { return_ACPI_STATUS(AE_OK); } status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL, acpi_ev_global_lock_handler, NULL); acpi_gbl_global_lock_present = FALSE; if (status == AE_NO_HARDWARE_RESPONSE) { ACPI_ERROR((AE_INFO, "No response from Global Lock hardware, disabling lock")); return_ACPI_STATUS(AE_OK); } status = acpi_os_create_lock(&acpi_gbl_global_lock_pending_lock); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } acpi_gbl_global_lock_pending = FALSE; acpi_gbl_global_lock_present = TRUE; return_ACPI_STATUS(status); }
acpi_status acpi_ev_init_global_lock_handler(void) { acpi_status status; ACPI_FUNCTION_TRACE(ev_init_global_lock_handler); status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, (struct acpi_table_header **)&facs); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } acpi_gbl_global_lock_present = TRUE; status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL, acpi_ev_global_lock_handler, NULL); /* * If the global lock does not exist on this platform, the attempt * to enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick) * Map to AE_OK, but mark global lock as not present. * Any attempt to actually use the global lock will be flagged * with an error. */ if (status == AE_NO_HARDWARE_RESPONSE) { ACPI_ERROR((AE_INFO, "No response from Global Lock hardware, disabling lock")); acpi_gbl_global_lock_present = FALSE; status = AE_OK; } return_ACPI_STATUS(status); }
static inline void rtc_wake_setup(struct device *dev) { acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, dev); /* * After the RTC handler is installed, the Fixed_RTC event should * be disabled. Only when the RTC alarm is set will it be enabled. */ acpi_clear_event(ACPI_EVENT_RTC); acpi_disable_event(ACPI_EVENT_RTC, 0); }
static int acpi_device_install_notify_handler(struct acpi_device *device) { acpi_status status; if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) status = 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 status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_device_notify, device); if (ACPI_FAILURE(status)) return -EINVAL; return 0; }
static inline void rtc_wake_setup(void) { acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL); acpi_clear_event(ACPI_EVENT_RTC); acpi_disable_event(ACPI_EVENT_RTC, 0); }
acpi_status bn_add_device( BM_HANDLE device_handle, void **context) { acpi_status status = AE_OK; BM_DEVICE *device = NULL; BN_CONTEXT *button = NULL; FUNCTION_TRACE("bn_add_device"); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Adding button device [%02x].\n", device_handle)); if (!context || *context) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid context.\n")); return_ACPI_STATUS(AE_BAD_PARAMETER); } /* * Get information on this device. */ status = bm_get_device_info( device_handle, &device ); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* * Allocate a new BN_CONTEXT structure. */ button = acpi_os_callocate(sizeof(BN_CONTEXT)); if (!button) { return_ACPI_STATUS(AE_NO_MEMORY); } button->device_handle = device->handle; button->acpi_handle = device->acpi_handle; /* * Power Button? * ------------- * Either fixed-feature or generic (namespace) types. */ if (strncmp(device->id.hid, BN_HID_POWER_BUTTON, sizeof(BM_DEVICE_HID)) == 0) { if (device->id.type == BM_TYPE_FIXED_BUTTON) { button->type = BN_TYPE_POWER_BUTTON_FIXED; /* Register for fixed-feature events. */ status = acpi_install_fixed_event_handler( ACPI_EVENT_POWER_BUTTON, bn_notify_fixed, (void*)button); } else { button->type = BN_TYPE_POWER_BUTTON; } } /* * Sleep Button? * ------------- * Either fixed-feature or generic (namespace) types. */ else if (strncmp( device->id.hid, BN_HID_SLEEP_BUTTON, sizeof(BM_DEVICE_HID)) == 0) { if (device->id.type == BM_TYPE_FIXED_BUTTON) { button->type = BN_TYPE_SLEEP_BUTTON_FIXED; /* Register for fixed-feature events. */ status = acpi_install_fixed_event_handler( ACPI_EVENT_SLEEP_BUTTON, bn_notify_fixed, (void*)button); } else { button->type = BN_TYPE_SLEEP_BUTTON; } } /* * LID Switch? * ----------- */ else if (strncmp( device->id.hid, BN_HID_LID_SWITCH, sizeof(BM_DEVICE_HID)) == 0) { button->type = BN_TYPE_LID_SWITCH; } status = bn_osl_add_device(button); if (ACPI_FAILURE(status)) { goto end; } *context = button; bn_print(button); end: if (ACPI_FAILURE(status)) { acpi_os_free(button); } return_ACPI_STATUS(status); }
static int acpi_button_add ( struct acpi_device *device) { int result = 0; acpi_status status = AE_OK; struct acpi_button *button = NULL; static struct acpi_device *power_button; static struct acpi_device *sleep_button; static struct acpi_device *lid_button; ACPI_FUNCTION_TRACE("acpi_button_add"); if (!device) return_VALUE(-EINVAL); button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL); if (!button) return_VALUE(-ENOMEM); memset(button, 0, sizeof(struct acpi_button)); button->device = device; button->handle = device->handle; acpi_driver_data(device) = button; /* * Determine the button type (via hid), as fixed-feature buttons * need to be handled a bit differently than generic-space. */ if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) { button->type = ACPI_BUTTON_TYPE_POWER; sprintf(acpi_device_name(device), "%s", ACPI_BUTTON_DEVICE_NAME_POWER); sprintf(acpi_device_class(device), "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) { button->type = ACPI_BUTTON_TYPE_POWERF; sprintf(acpi_device_name(device), "%s", ACPI_BUTTON_DEVICE_NAME_POWERF); sprintf(acpi_device_class(device), "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) { button->type = ACPI_BUTTON_TYPE_SLEEP; sprintf(acpi_device_name(device), "%s", ACPI_BUTTON_DEVICE_NAME_SLEEP); sprintf(acpi_device_class(device), "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) { button->type = ACPI_BUTTON_TYPE_SLEEPF; sprintf(acpi_device_name(device), "%s", ACPI_BUTTON_DEVICE_NAME_SLEEPF); sprintf(acpi_device_class(device), "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) { button->type = ACPI_BUTTON_TYPE_LID; sprintf(acpi_device_name(device), "%s", ACPI_BUTTON_DEVICE_NAME_LID); sprintf(acpi_device_class(device), "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); } else { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n", acpi_device_hid(device))); result = -ENODEV; goto end; } /* * Ensure only one button of each type is used. */ switch (button->type) { case ACPI_BUTTON_TYPE_POWER: case ACPI_BUTTON_TYPE_POWERF: if (!power_button) power_button = device; else { kfree(button); return_VALUE(-ENODEV); } break; case ACPI_BUTTON_TYPE_SLEEP: case ACPI_BUTTON_TYPE_SLEEPF: if (!sleep_button) sleep_button = device; else { kfree(button); return_VALUE(-ENODEV); } break; case ACPI_BUTTON_TYPE_LID: if (!lid_button) lid_button = device; else { kfree(button); return_VALUE(-ENODEV); } break; } result = acpi_button_add_fs(device); if (result) goto end; switch (button->type) { case ACPI_BUTTON_TYPE_POWERF: status = acpi_install_fixed_event_handler ( ACPI_EVENT_POWER_BUTTON, acpi_button_notify_fixed, button); break; case ACPI_BUTTON_TYPE_SLEEPF: status = acpi_install_fixed_event_handler ( ACPI_EVENT_SLEEP_BUTTON, acpi_button_notify_fixed, button); break; default: status = acpi_install_notify_handler ( button->handle, ACPI_DEVICE_NOTIFY, acpi_button_notify, button); break; } if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error installing notify handler\n")); result = -ENODEV; goto end; } printk(KERN_INFO PREFIX "%s [%s]\n", acpi_device_name(device), acpi_device_bid(device)); end: if (result) { acpi_button_remove_fs(device); kfree(button); } return_VALUE(result); }