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 int acpi_thermal_add(struct acpi_device *device) { int result = 0; struct acpi_thermal *tz = NULL; if (!device) return -EINVAL; tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL); if (!tz) return -ENOMEM; tz->device = device; strcpy(tz->name, device->pnp.bus_id); strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS); device->driver_data = tz; mutex_init(&tz->lock); result = acpi_thermal_get_info(tz); if (result) goto free_memory; acpi_thermal_guess_offset(tz); result = acpi_thermal_register_thermal_zone(tz); if (result) goto free_memory; printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n", acpi_device_name(device), acpi_device_bid(device), KELVIN_TO_CELSIUS(tz->temperature)); goto end; free_memory: kfree(tz); end: return result; }