status = acpi_fan_get_fst(device->handle, &fst); if (status) return status;
if (fan->fif.fine_grain_ctrl) { /* This control should be same what we set using _FSL by spec */ if (fst.control > 100) {
dev_dbg(&device->dev, "Invalid control value returned\n"); goto match_fps;
}
match_fps: for (i = 0; i < fan->fps_count; i++) { if (fst.control == fan->fps[i].control) break;
} if (i == fan->fps_count) {
dev_dbg(&device->dev, "No matching fps control value\n"); return -EINVAL;
}
*state = i;
return status;
}
staticint fan_get_state(struct acpi_device *device, unsignedlong *state)
{ int result; int acpi_state = ACPI_STATE_D0;
result = acpi_device_update_power(device, &acpi_state); if (result) return result;
if (fan->fif.fine_grain_ctrl) {
value *= fan->fif.step_size; /* Spec allows compensate the last step only */ if (value + fan->fif.step_size > 100)
value = 100;
} else {
value = fan->fps[state].control;
}
status = acpi_execute_simple_method(device->handle, "_FSL", value); if (ACPI_FAILURE(status)) {
dev_dbg(&device->dev, "Failed to set state by _FSL\n"); return -ENODEV;
}
/* If there is a bug in step size and set as 0, change to 1 */ if (!fan->fif.step_size)
fan->fif.step_size = 1; /* If step size > 9, change to 9 (by spec valid values 1-9) */ elseif (fan->fif.step_size > 9)
fan->fif.step_size = 9;
err:
kfree(obj); return status;
}
if (acpi_fan_has_fst(device)) {
fan->has_fst = true;
fan->acpi4 = acpi_fan_is_acpi4(device);
}
if (fan->acpi4) {
result = acpi_fan_get_fif(device); if (result) return result;
result = acpi_fan_get_fps(device); if (result) return result;
}
if (fan->has_fst) {
result = devm_acpi_fan_create_hwmon(&pdev->dev); if (result) return result;
result = acpi_fan_create_attributes(device); if (result) return result;
}
if (!fan->acpi4) {
result = acpi_device_update_power(device, NULL); if (result) {
dev_err(&device->dev, "Failed to set initial power state\n"); goto err_end;
}
}
if (!strncmp(pdev->name, "PNP0C0B", strlen("PNP0C0B")))
name = "Fan"; else
name = acpi_device_bid(device);
cdev = thermal_cooling_device_register(name, device,
&fan_cooling_ops); if (IS_ERR(cdev)) {
result = PTR_ERR(cdev); goto err_end;
}
dev_dbg(&pdev->dev, "registered as cooling_device%d\n", cdev->id);
fan->cdev = cdev;
result = sysfs_create_link(&pdev->dev.kobj,
&cdev->device.kobj, "thermal_cooling"); if (result) {
dev_err(&pdev->dev, "Failed to create sysfs link 'thermal_cooling'\n"); goto err_unregister;
}
result = sysfs_create_link(&cdev->device.kobj,
&pdev->dev.kobj, "device"); if (result) {
dev_err(&pdev->dev, "Failed to create sysfs link 'device'\n"); goto err_remove_link;
}
return 0;
err_remove_link:
sysfs_remove_link(&pdev->dev.kobj, "thermal_cooling");
err_unregister:
thermal_cooling_device_unregister(cdev);
err_end: if (fan->has_fst)
acpi_fan_delete_attributes(device);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.