static void acpi_thermal_notify(struct acpi_device *device, u32 event) { struct acpi_thermal *tz = acpi_driver_data(device); if (!tz) return; switch (event) { case ACPI_THERMAL_NOTIFY_TEMPERATURE: acpi_thermal_check(tz); break; case ACPI_THERMAL_NOTIFY_THRESHOLDS: acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS); acpi_thermal_check(tz); acpi_bus_generate_proc_event(device, event, 0); acpi_bus_generate_netlink_event(device->pnp.device_class, dev_name(&device->dev), event, 0); break; case ACPI_THERMAL_NOTIFY_DEVICES: acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); acpi_thermal_check(tz); acpi_bus_generate_proc_event(device, event, 0); acpi_bus_generate_netlink_event(device->pnp.device_class, dev_name(&device->dev), event, 0); break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unsupported event [0x%x]\n", event)); break; } }
static int thermal_set_mode(struct thermal_zone_device *thermal, enum thermal_device_mode mode) { struct acpi_thermal *tz = thermal->devdata; int enable; if (!tz) return -EINVAL; /* * enable/disable thermal management from ACPI thermal driver */ if (mode == THERMAL_DEVICE_ENABLED) enable = 1; else if (mode == THERMAL_DEVICE_DISABLED) enable = 0; else return -EINVAL; if (enable != tz->tz_enabled) { tz->tz_enabled = enable; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s ACPI thermal control\n", tz->tz_enabled ? enabled : disabled)); acpi_thermal_check(tz); } return 0; }
static int acpi_thermal_resume(struct acpi_device *device) { struct acpi_thermal *tz = NULL; int i, j, power_state, result; if (!device || !acpi_driver_data(device)) return -EINVAL; tz = acpi_driver_data(device); for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { if (!(&tz->trips.active[i])) break; if (!tz->trips.active[i].flags.valid) break; tz->trips.active[i].flags.enabled = 1; for (j = 0; j < tz->trips.active[i].devices.count; j++) { result = acpi_bus_update_power( tz->trips.active[i].devices.handles[j], &power_state); if (result || (power_state != ACPI_STATE_D0)) { tz->trips.active[i].flags.enabled = 0; break; } } tz->state.active |= tz->trips.active[i].flags.enabled; } acpi_thermal_check(tz); return AE_OK; }
static int acpi_thermal_write_polling ( struct file *file, const char *buffer, unsigned long count, void *data) { int result = 0; struct acpi_thermal *tz = (struct acpi_thermal *) data; char polling_string[12] = {'\0'}; int seconds = 0; ACPI_FUNCTION_TRACE("acpi_thermal_write_polling"); if (!tz || (count > sizeof(polling_string) - 1)) return_VALUE(-EINVAL); if (copy_from_user(polling_string, buffer, count)) return_VALUE(-EFAULT); polling_string[count] = '\0'; seconds = simple_strtoul(polling_string, NULL, 0); result = acpi_thermal_set_polling(tz, seconds); if (result) return_VALUE(result); acpi_thermal_check(tz); return_VALUE(count); }
static int acpi_thermal_add ( struct acpi_device *device) { int result = 0; acpi_status status = AE_OK; struct acpi_thermal *tz = NULL; ACPI_FUNCTION_TRACE("acpi_thermal_add"); if (!device) return_VALUE(-EINVAL); tz = kmalloc(sizeof(struct acpi_thermal), GFP_KERNEL); if (!tz) return_VALUE(-ENOMEM); memset(tz, 0, sizeof(struct acpi_thermal)); tz->handle = device->handle; sprintf(tz->name, "%s", device->pnp.bus_id); sprintf(acpi_device_name(device), "%s", ACPI_THERMAL_DEVICE_NAME); sprintf(acpi_device_class(device), "%s", ACPI_THERMAL_CLASS); acpi_driver_data(device) = tz; result = acpi_thermal_get_info(tz); if (result) goto end; result = acpi_thermal_add_fs(device); if (result) return_VALUE(result); init_timer(&tz->timer); acpi_thermal_check(tz); status = acpi_install_notify_handler(tz->handle, ACPI_DEVICE_NOTIFY, acpi_thermal_notify, tz); 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] (%ld C)\n", acpi_device_name(device), acpi_device_bid(device), KELVIN_TO_CELSIUS(tz->temperature)); end: if (result) { acpi_thermal_remove_fs(device); kfree(tz); } return_VALUE(result); }
static void acpi_thermal_notify ( acpi_handle handle, u32 event, void *data) { struct acpi_thermal *tz = (struct acpi_thermal *) data; struct acpi_device *device = NULL; ACPI_FUNCTION_TRACE("acpi_thermal_notify"); if (!tz) return_VOID; if (acpi_bus_get_device(tz->handle, &device)) return_VOID; switch (event) { case ACPI_THERMAL_NOTIFY_TEMPERATURE: acpi_thermal_check(tz); break; case ACPI_THERMAL_NOTIFY_THRESHOLDS: acpi_thermal_get_trip_points(tz); acpi_thermal_check(tz); acpi_bus_generate_event(device, event, 0); break; case ACPI_THERMAL_NOTIFY_DEVICES: if (tz->flags.devices) acpi_thermal_get_devices(tz); acpi_bus_generate_event(device, event, 0); break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unsupported event [0x%x]\n", event)); break; } return_VOID; }
static void acpi_thermal_check_fn(struct work_struct *work) { struct acpi_thermal *tz = container_of(work, struct acpi_thermal, thermal_check_work); acpi_thermal_check(tz); }