/** \brief uninstall notify handler for acpi device * \param device acpi device * \param handler_type type of handler * \param handler pointer of notify handler * \return status */ unsigned int ATI_API_CALL KCL_ACPI_RemoveHandler(KCL_ACPI_DevHandle device, unsigned int handler_type, KCL_ACPI_CallbackHandle handler, KCL_NOTIFIER_BLOCKER *nb) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) return acpi_remove_notify_handler(device, handler_type, (acpi_notify_handler)handler); #else KCL_ACPI_DevHandle dummy_handle; int ret = 0; //unregister notifier chain for video switching events if ((KCL_ACPI_GetDevHandle(device, "_DOD", &dummy_handle) == KCL_ACPI_OK) || (KCL_ACPI_GetDevHandle(device, "_DOS", &dummy_handle) == KCL_ACPI_OK)) { ret = unregister_acpi_notifier((struct notifier_block*)(*nb)); kfree(*nb); *nb = NULL; } //unregister notifier chain for ac adapter events if (KCL_ACPI_GetDevHandle(device, "_PSR", &dummy_handle) == KCL_ACPI_OK) { ret = unregister_acpi_notifier((struct notifier_block*)(*nb)); kfree(*nb); *nb = NULL; } return ret; #endif }
static int acpi_processor_remove(struct acpi_device *device, int type) { acpi_status status = AE_OK; struct acpi_processor *pr = NULL; if (!device || !acpi_driver_data(device)) return -EINVAL; pr = acpi_driver_data(device); if (pr->id >= NR_CPUS) { kfree(pr); return 0; } if (type == ACPI_BUS_REMOVAL_EJECT) { if (acpi_processor_handle_eject(pr)) return -EINVAL; } acpi_processor_power_exit(pr, device); status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, acpi_processor_notify); acpi_processor_remove_fs(device); processors[pr->id] = NULL; kfree(pr); return 0; }
/** \brief uninstall notify handler for acpi device * \param device acpi device * \param handler_type type of handler * \param handler pointer of notify handler * \return status */ unsigned int ATI_API_CALL KCL_ACPI_RemoveHandler(KCL_ACPI_DevHandle device, unsigned int handler_type, KCL_ACPI_CallbackHandle handler) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) return acpi_remove_notify_handler(device, handler_type, (acpi_notify_handler)handler); #else KCL_ACPI_DevHandle dummy_handle; //unregister notifier chain for video switching events if ((KCL_ACPI_GetDevHandle(device, "_DOD", &dummy_handle) == KCL_ACPI_OK) || (KCL_ACPI_GetDevHandle(device, "_DOS", &dummy_handle) == KCL_ACPI_OK)) { return unregister_acpi_notifier(&firegl_acpi_video_notifier); } //unregister notifier chain for ac adapter events if (KCL_ACPI_GetDevHandle(device, "_PSR", &dummy_handle) == KCL_ACPI_OK) { return unregister_acpi_notifier(&firegl_acpi_ac_notifier); } return 0; #endif }
static int acpi_processor_stop(struct device *dev) { struct acpi_device *device; struct acpi_processor *pr; if (acpi_bus_get_device(ACPI_HANDLE(dev), &device)) return 0; acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_processor_notify); pr = acpi_driver_data(device); if (!pr) return 0; acpi_processor_power_exit(pr); if (pr->cdev) { sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); sysfs_remove_link(&pr->cdev->device.kobj, "device"); thermal_cooling_device_unregister(pr->cdev); pr->cdev = NULL; } return 0; }
static int acpi_battery_remove ( struct acpi_device *device, int type) { acpi_status status = 0; struct acpi_battery *battery = NULL; ACPI_FUNCTION_TRACE("acpi_battery_remove"); if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); battery = (struct acpi_battery *) acpi_driver_data(device); status = acpi_remove_notify_handler(battery->handle, ACPI_DEVICE_NOTIFY, acpi_battery_notify); if (ACPI_FAILURE(status)) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error removing notify handler\n")); acpi_battery_remove_fs(device); kfree(battery); return_VALUE(0); }
/** * acpi_remove_pm_notifier - Unregister PM notifier from given ACPI device. * @adev: ACPI device to remove the notifier from. */ acpi_status acpi_remove_pm_notifier(struct acpi_device *adev) { acpi_status status = AE_BAD_PARAMETER; mutex_lock(&acpi_pm_notifier_lock); if (!adev->wakeup.flags.notifier_present) goto out; status = acpi_remove_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY, acpi_pm_notify_handler); if (ACPI_FAILURE(status)) goto out; if (adev->wakeup.context.work.func) { cancel_work_sync(&adev->wakeup.context.work); adev->wakeup.context.work.func = NULL; } adev->wakeup.context.dev = NULL; wakeup_source_unregister(adev->wakeup.ws); adev->wakeup.flags.notifier_present = false; out: mutex_unlock(&acpi_pm_notifier_lock); return status; }
static acpi_status processor_walk_namespace_cb(acpi_handle handle, u32 lvl, void *context, void **rv) { acpi_status status; int *action = context; acpi_object_type type = 0; status = acpi_get_type(handle, &type); if (ACPI_FAILURE(status)) return (AE_OK); if (type != ACPI_TYPE_PROCESSOR) return (AE_OK); switch (*action) { case INSTALL_NOTIFY_HANDLER: acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, acpi_processor_hotplug_notify, NULL); break; case UNINSTALL_NOTIFY_HANDLER: acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, acpi_processor_hotplug_notify); break; default: break; } return (AE_OK); }
static acpi_status processor_walk_namespace_cb(acpi_handle handle, u32 lvl, void *context, void **rv) { acpi_status status; int *action = context; status = is_processor_device(handle); if (ACPI_FAILURE(status)) return AE_OK; /* not a processor; continue to walk */ switch (*action) { case INSTALL_NOTIFY_HANDLER: acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, acpi_processor_hotplug_notify, NULL); break; case UNINSTALL_NOTIFY_HANDLER: acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, acpi_processor_hotplug_notify); break; default: break; } /* found a processor; skip walking underneath */ return AE_CTRL_DEPTH; }
static int intel_hid_probe(struct platform_device *device) { acpi_handle handle = ACPI_HANDLE(&device->dev); struct intel_hid_priv *priv; unsigned long long mode; acpi_status status; int err; status = acpi_evaluate_integer(handle, "HDMM", NULL, &mode); if (!ACPI_SUCCESS(status)) { dev_warn(&device->dev, "failed to read mode\n"); return -ENODEV; } if (mode != 0) { /* * This driver only implements "simple" mode. There appear * to be no other modes, but we should be paranoid and check * for compatibility. */ dev_info(&device->dev, "platform is not in simple mode\n"); return -ENODEV; } priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; dev_set_drvdata(&device->dev, priv); err = intel_hid_input_setup(device); if (err) { pr_err("Failed to setup Intel HID hotkeys\n"); return err; } status = acpi_install_notify_handler(handle, ACPI_DEVICE_NOTIFY, notify_handler, device); if (ACPI_FAILURE(status)) { err = -EBUSY; goto err_remove_input; } err = intel_hid_set_enable(&device->dev, 1); if (err) goto err_remove_notify; return 0; err_remove_notify: acpi_remove_notify_handler(handle, ACPI_DEVICE_NOTIFY, notify_handler); err_remove_input: intel_hid_input_destroy(device); return err; }
acpi_status bm_terminate (void) { acpi_status status = AE_OK; u32 i = 0; FUNCTION_TRACE("bm_terminate"); /* * Terminate built-in power resource driver. */ bm_pr_terminate(); /* * Unregister for all notifications. */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Unregistering for device notifications.\n")); status = acpi_remove_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, &bm_notify); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unable to un-register for standard notifications.\n")); } status = acpi_remove_notify_handler(ACPI_ROOT_OBJECT, ACPI_DEVICE_NOTIFY, &bm_notify); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unable to un-register for device-specific notifications.\n")); } /* * Parse through the device array, freeing all entries. */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing device hierarchy.\n")); for (i = 0; i < node_list.count; i++) { if (node_list.nodes[i]) { acpi_os_free(node_list.nodes[i]); } } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Bus Manager disabled.\n")); return_ACPI_STATUS(AE_OK); }
static int acpi_pad_remove(struct acpi_device *device) { mutex_lock(&isolated_cpus_lock); acpi_pad_idle_cpus(0); mutex_unlock(&isolated_cpus_lock); acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_pad_notify); acpi_pad_remove_sysfs(device); return 0; }
static int intel_vbtn_remove(struct platform_device *device) { acpi_handle handle = ACPI_HANDLE(&device->dev); acpi_remove_notify_handler(handle, ACPI_DEVICE_NOTIFY, notify_handler); /* * Even if we failed to shut off the event stream, we can still * safely detach from the device. */ return 0; }
static void acpi_device_remove_notify_handler(struct acpi_device *device) { if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) 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 acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_device_notify); }
static acpi_status container_walk_namespace_cb(acpi_handle handle, u32 lvl, void *context, void **rv) { char *hid = NULL; struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; struct acpi_device_info *info; acpi_status status; int *action = context; ACPI_FUNCTION_TRACE("container_walk_namespace_cb"); status = acpi_get_object_info(handle, &buffer); if (ACPI_FAILURE(status) || !buffer.pointer) { return_ACPI_STATUS(AE_OK); } info = buffer.pointer; if (info->valid & ACPI_VALID_HID) hid = info->hardware_id.value; if (hid == NULL) { goto end; } if (strcmp(hid, "ACPI0004") && strcmp(hid, "PNP0A05") && strcmp(hid, "PNP0A06")) { goto end; } switch(*action) { case INSTALL_NOTIFY_HANDLER: acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, container_notify_cb, NULL); break; case UNINSTALL_NOTIFY_HANDLER: acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, container_notify_cb); break; default: break; } end: acpi_os_free(buffer.pointer); return_ACPI_STATUS(AE_OK); }
static int intel_hid_remove(struct platform_device *device) { acpi_handle handle = ACPI_HANDLE(&device->dev); device_init_wakeup(&device->dev, false); acpi_remove_notify_handler(handle, ACPI_DEVICE_NOTIFY, notify_handler); intel_hid_set_enable(&device->dev, false); intel_button_array_enable(&device->dev, false); /* * Even if we failed to shut off the event stream, we can still * safely detach from the device. */ return 0; }
static int cros_ec_lpc_remove(struct platform_device *pdev) { struct cros_ec_device *ec_dev; struct acpi_device *adev; adev = ACPI_COMPANION(&pdev->dev); if (adev) acpi_remove_notify_handler(adev->handle, ACPI_ALL_NOTIFY, cros_ec_lpc_acpi_notify); ec_dev = platform_get_drvdata(pdev); cros_ec_remove(ec_dev); return 0; }
static int ucsi_acpi_remove(struct platform_device *pdev) { struct ucsi *ucsi = platform_get_drvdata(pdev); acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev), ACPI_ALL_NOTIFY, ucsi_acpi_notify); /* Make sure there are no events in the middle of being processed */ if (wait_on_bit_timeout(&ucsi->flags, EVENT_PENDING, TASK_UNINTERRUPTIBLE, msecs_to_jiffies(UCSI_TIMEOUT_MS))) dev_WARN(ucsi->dev, "%s: Events still pending\n", __func__); ucsi_reset_ppm(ucsi); return 0; }
static acpi_status container_walk_namespace_cb(acpi_handle handle, u32 lvl, void *context, void **rv) { char *hid = NULL; struct acpi_device_info *info; acpi_status status; int *action = context; status = acpi_get_object_info(handle, &info); if (ACPI_FAILURE(status)) { return AE_OK; } if (info->valid & ACPI_VALID_HID) hid = info->hardware_id.string; if (hid == NULL) { goto end; } if (strcmp(hid, "ACPI0004") && strcmp(hid, "PNP0A05") && strcmp(hid, "PNP0A06")) { goto end; } switch (*action) { case INSTALL_NOTIFY_HANDLER: acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, container_notify_cb, NULL); break; case UNINSTALL_NOTIFY_HANDLER: acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, container_notify_cb); break; default: break; } end: kfree(info); return AE_OK; }
static int acpi_ac_remove(struct platform_device *pdev) { struct acpi_ac *ac; if (!pdev) return -EINVAL; acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev), ACPI_ALL_NOTIFY, acpi_ac_notify_handler); ac = platform_get_drvdata(pdev); if (ac->charger.dev) power_supply_unregister(&ac->charger); kfree(ac); return 0; }
static int ucsi_acpi_probe(struct platform_device *pdev) { struct resource *res; acpi_status status; struct ucsi *ucsi; int ret; ucsi = devm_kzalloc(&pdev->dev, sizeof(*ucsi), GFP_KERNEL); if (!ucsi) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "missing memory resource\n"); return -ENODEV; } /* * NOTE: ACPI has claimed the memory region as it's also an Operation * Region. It's not possible to request it in the driver. */ ucsi->data = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (!ucsi->data) return -ENOMEM; ucsi->dev = &pdev->dev; status = acpi_install_notify_handler(ACPI_HANDLE(&pdev->dev), ACPI_ALL_NOTIFY, ucsi_acpi_notify, ucsi); if (ACPI_FAILURE(status)) return -ENODEV; ret = ucsi_init(ucsi); if (ret) { acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev), ACPI_ALL_NOTIFY, ucsi_acpi_notify); return ret; } platform_set_drvdata(pdev, ucsi); return 0; }
static int acpi_processor_remove(struct acpi_device *device, int type) { acpi_status status = AE_OK; struct acpi_processor *pr = NULL; if (!device || !acpi_driver_data(device)) return -EINVAL; pr = acpi_driver_data(device); if (pr->id >= nr_cpu_ids) goto free; if (type == ACPI_BUS_REMOVAL_EJECT) { if (acpi_processor_handle_eject(pr)) return -EINVAL; } acpi_processor_power_exit(pr, device); status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, acpi_processor_notify); sysfs_remove_link(&device->dev.kobj, "sysdev"); acpi_processor_remove_fs(device); if (pr->cdev) { sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); sysfs_remove_link(&pr->cdev->device.kobj, "device"); thermal_cooling_device_unregister(pr->cdev); pr->cdev = NULL; } per_cpu(processors, pr->id) = NULL; per_cpu(processor_device_array, pr->id) = NULL; free: free_cpumask_var(pr->throttling.shared_cpu_map); kfree(pr); return 0; }
static int acpi_thermal_remove ( struct acpi_device *device, int type) { acpi_status status = AE_OK; struct acpi_thermal *tz = NULL; ACPI_FUNCTION_TRACE("acpi_thermal_remove"); if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); tz = (struct acpi_thermal *) acpi_driver_data(device); /* avoid timer adding new defer task */ tz->zombie = 1; /* wait for running timer (on other CPUs) finish */ delete_timer( tz->timer ); /* synchronize deferred task */ acpi_os_wait_events_complete(NULL); status = acpi_remove_notify_handler(tz->handle, ACPI_DEVICE_NOTIFY, acpi_thermal_notify); if (ACPI_FAILURE(status)) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error removing notify handler\n")); /* Terminate policy */ if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) { tz->trips.passive.flags.enabled = 0; acpi_thermal_passive(tz); } if (tz->trips.active[0].flags.valid && tz->trips.active[0].flags.enabled) { tz->trips.active[0].flags.enabled = 0; acpi_thermal_active(tz); } kfree(tz); return_VALUE(0); }
static int acpi_battery_remove(struct acpi_device *device, int type) { acpi_status status = 0; struct acpi_battery *battery = NULL; if (!device || !acpi_driver_data(device)) return -EINVAL; battery = (struct acpi_battery *)acpi_driver_data(device); status = acpi_remove_notify_handler(device->handle, ACPI_ALL_NOTIFY, acpi_battery_notify); acpi_battery_remove_fs(device); kfree(battery); return 0; }
static int acpi_thermal_remove ( struct acpi_device *device, int type) { acpi_status status = AE_OK; struct acpi_thermal *tz = NULL; ACPI_FUNCTION_TRACE("acpi_thermal_remove"); if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); tz = (struct acpi_thermal *) acpi_driver_data(device); if (timer_pending(&(tz->timer))) del_timer(&(tz->timer)); status = acpi_remove_notify_handler(tz->handle, ACPI_DEVICE_NOTIFY, acpi_thermal_notify); if (ACPI_FAILURE(status)) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error removing notify handler\n")); /* Terminate policy */ if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) { tz->trips.passive.flags.enabled = 0; acpi_thermal_passive(tz); } if (tz->trips.active[0].flags.valid && tz->trips.active[0].flags.enabled) { tz->trips.active[0].flags.enabled = 0; acpi_thermal_active(tz); } acpi_thermal_remove_fs(device); return_VALUE(0); }
static int acpi_processor_remove(struct acpi_device *device, int type) { acpi_status status = AE_OK; struct acpi_processor *pr = NULL; ACPI_FUNCTION_TRACE("acpi_processor_remove"); if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); pr = (struct acpi_processor *)acpi_driver_data(device); if (pr->id >= NR_CPUS) { kfree(pr); return_VALUE(0); } if (type == ACPI_BUS_REMOVAL_EJECT) { if (acpi_processor_handle_eject(pr)) return_VALUE(-EINVAL); } acpi_processor_power_exit(pr, device); status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, acpi_processor_notify); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error removing notify handler\n")); } acpi_processor_remove_fs(device); processors[pr->id] = NULL; kfree(pr); return_VALUE(0); }
static int acpi_processor_stop(struct device *dev) { struct acpi_device *device = ACPI_COMPANION(dev); struct acpi_processor *pr; if (!device) return 0; acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_processor_notify); pr = acpi_driver_data(device); if (!pr) return 0; acpi_processor_power_exit(pr); acpi_pss_perf_exit(pr, device); acpi_cppc_processor_exit(pr); return 0; }
static int acpi_button_remove (struct acpi_device *device, int type) { acpi_status status = 0; struct acpi_button *button = NULL; ACPI_FUNCTION_TRACE("acpi_button_remove"); if (!device || !acpi_driver_data(device)) return_VALUE(-EINVAL); button = acpi_driver_data(device); /* Unregister for device notifications. */ switch (button->type) { case ACPI_BUTTON_TYPE_POWERF: status = acpi_remove_fixed_event_handler( ACPI_EVENT_POWER_BUTTON, acpi_button_notify_fixed); break; case ACPI_BUTTON_TYPE_SLEEPF: status = acpi_remove_fixed_event_handler( ACPI_EVENT_SLEEP_BUTTON, acpi_button_notify_fixed); break; default: status = acpi_remove_notify_handler(button->handle, ACPI_DEVICE_NOTIFY, acpi_button_notify); break; } if (ACPI_FAILURE(status)) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error removing notify handler\n")); acpi_button_remove_fs(device); kfree(button); return_VALUE(0); }
/** * remove_pm_notifier - Unregister PM notifier from given ACPI device. * @dev: ACPI device to remove the notifier from. */ static acpi_status remove_pm_notifier(struct acpi_device *dev, acpi_notify_handler handler) { acpi_status status = AE_BAD_PARAMETER; mutex_lock(&pci_acpi_pm_notify_mtx); if (!dev->wakeup.flags.notifier_present) goto out; status = acpi_remove_notify_handler(dev->handle, ACPI_SYSTEM_NOTIFY, handler); if (ACPI_FAILURE(status)) goto out; dev->wakeup.flags.notifier_present = false; out: mutex_unlock(&pci_acpi_pm_notify_mtx); return status; }
static acpi_status acpi_memory_deregister_notify_handler(acpi_handle handle, u32 level, void *ctxt, void **retv) { acpi_status status; ACPI_FUNCTION_TRACE("acpi_memory_deregister_notify_handler"); status = is_memory_device(handle); if (ACPI_FAILURE(status)) return_ACPI_STATUS(AE_OK); /* continue */ status = acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, acpi_memory_device_notify); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error removing notify handler\n")); return_ACPI_STATUS(AE_OK); /* continue */ } return_ACPI_STATUS(status); }
static void ata_acpi_remove_pm_notifier(struct ata_device *dev) { acpi_handle handle = ata_dev_acpi_handle(dev); acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, zpodd_wake_dev); }