/** * acpi_device_wakeup - Enable/disable wakeup functionality for device. * @adev: ACPI device to enable/disable wakeup functionality for. * @target_state: State the system is transitioning into. * @enable: Whether to enable or disable the wakeup functionality. * * Enable/disable the GPE associated with @adev so that it can generate * wakeup signals for the device in response to external (remote) events and * enable/disable device wakeup power. * * Callers must ensure that @adev is a valid ACPI device node before executing * this function. */ static int acpi_device_wakeup(struct acpi_device *adev, u32 target_state, bool enable) { struct acpi_device_wakeup *wakeup = &adev->wakeup; if (enable) { acpi_status res; int error; error = acpi_enable_wakeup_device_power(adev, target_state); if (error) return error; if (adev->wakeup.flags.enabled) return 0; res = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number); if (ACPI_SUCCESS(res)) { adev->wakeup.flags.enabled = 1; } else { acpi_disable_wakeup_device_power(adev); return -EIO; } } else { if (adev->wakeup.flags.enabled) { acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number); adev->wakeup.flags.enabled = 0; } acpi_disable_wakeup_device_power(adev); } return 0; }
static int xo15_sci_remove(struct acpi_device *device, int type) { acpi_disable_gpe(NULL, xo15_sci_gpe); acpi_remove_gpe_handler(NULL, xo15_sci_gpe, xo15_sci_gpe_handler); cancel_work_sync(&sci_work); sysfs_remove_file(&device->dev.kobj, &lid_wake_on_close_attr.attr); return 0; }
static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) { int status; u32 glk; if (!ec || (!t) || (t->wlen && !t->wdata) || (t->rlen && !t->rdata)) return -EINVAL; if (t->rdata) memset(t->rdata, 0, t->rlen); mutex_lock(&ec->lock); if (test_bit(EC_FLAGS_BLOCKED, &ec->flags)) { status = -EINVAL; goto unlock; } if (ec->global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) { status = -ENODEV; goto unlock; } } if (ec_wait_ibf0(ec)) { pr_err(PREFIX "input buffer is not empty, " "aborting transaction\n"); status = -ETIME; goto end; } pr_debug(PREFIX "transaction start\n"); /* disable GPE during transaction if storm is detected */ if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { /* It has to be disabled, so that it doesn't trigger. */ acpi_disable_gpe(NULL, ec->gpe); } status = acpi_ec_transaction_unlocked(ec, t); /* check if we received SCI during transaction */ ec_check_sci_sync(ec, acpi_ec_read_status(ec)); if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { msleep(1); /* It is safe to enable the GPE outside of the transaction. */ acpi_enable_gpe(NULL, ec->gpe); } else if (t->irq_count > ACPI_EC_STORM_THRESHOLD) { pr_info(PREFIX "GPE storm detected, " "transactions will use polling mode\n"); set_bit(EC_FLAGS_GPE_STORM, &ec->flags); } pr_debug(PREFIX "transaction end\n"); end: if (ec->global_lock) acpi_release_global_lock(glk); unlock: mutex_unlock(&ec->lock); return status; }
/** * __acpi_device_run_wake - Enable/disable runtime remote wakeup for device. * @adev: ACPI device to enable/disable the remote wakeup for. * @enable: Whether to enable or disable the wakeup functionality. * * Enable/disable the GPE associated with @adev so that it can generate * wakeup signals for the device in response to external (remote) events and * enable/disable device wakeup power. * * Callers must ensure that @adev is a valid ACPI device node before executing * this function. */ int __acpi_device_run_wake(struct acpi_device *adev, bool enable) { struct acpi_device_wakeup *wakeup = &adev->wakeup; if (enable) { acpi_status res; int error; error = acpi_enable_wakeup_device_power(adev, ACPI_STATE_S0); if (error) return error; res = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number); if (ACPI_FAILURE(res)) { acpi_disable_wakeup_device_power(adev); return -EIO; } } else { acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number); acpi_disable_wakeup_device_power(adev); } return 0; }
/** * acpi_device_wakeup - Enable/disable wakeup functionality for device. * @adev: ACPI device to enable/disable wakeup functionality for. * @target_state: State the system is transitioning into. * @enable: Whether to enable or disable the wakeup functionality. * * Enable/disable the GPE associated with @adev so that it can generate * wakeup signals for the device in response to external (remote) events and * enable/disable device wakeup power. * * Callers must ensure that @adev is a valid ACPI device node before executing * this function. */ static int acpi_device_wakeup(struct acpi_device *adev, u32 target_state, bool enable) { struct acpi_device_wakeup *wakeup = &adev->wakeup; if (enable) { acpi_status res; int error; error = acpi_enable_wakeup_device_power(adev, target_state); if (error) return error; res = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number); if (ACPI_FAILURE(res)) { acpi_disable_wakeup_device_power(adev); return -EIO; } } else { acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number); acpi_disable_wakeup_device_power(adev); } return 0; }