drivers/acpi/fan_core.c
Source file repositories/reference/linux-study-clean/drivers/acpi/fan_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/fan_core.c- Extension
.c- Size
- 17587 bytes
- Lines
- 702
- Domain
- Driver Families
- Bucket
- drivers/acpi
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bits.hlinux/kernel.hlinux/limits.hlinux/math.hlinux/math64.hlinux/module.hlinux/init.hlinux/types.hlinux/uaccess.hlinux/uuid.hlinux/thermal.hlinux/acpi.hlinux/platform_device.hlinux/sort.hfan.h
Detected Declarations
function fan_get_max_statefunction acpi_fan_get_fstfunction fan_get_state_acpi4function fan_get_statefunction fan_get_cur_statefunction fan_set_statefunction fan_set_state_acpi4function fan_set_cur_statefunction acpi_fan_get_fiffunction acpi_fan_speed_cmpfunction acpi_fan_get_fpsfunction acpi_fan_dsm_initfunction acpi_fan_dsm_set_trip_pointsfunction acpi_fan_dsm_startfunction acpi_fan_dsm_update_trips_pointsfunction acpi_fan_notify_handlerfunction acpi_fan_notify_removefunction devm_acpi_fan_notify_initfunction acpi_fan_probefunction acpi_fan_removefunction acpi_fan_suspendfunction acpi_fan_resume
Annotated Snippet
if (fst.control > 100) {
dev_dbg(&device->dev, "Invalid control value returned\n");
goto match_fps;
}
*state = (int) fst.control / fan->fif.step_size;
return 0;
}
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;
}
static int fan_get_state(struct acpi_device *device, unsigned long *state)
{
int result;
int acpi_state = ACPI_STATE_D0;
result = acpi_device_update_power(device, &acpi_state);
if (result)
return result;
*state = acpi_state == ACPI_STATE_D3_COLD
|| acpi_state == ACPI_STATE_D3_HOT ?
0 : (acpi_state == ACPI_STATE_D0 ? 1 : -1);
return 0;
}
static int fan_get_cur_state(struct thermal_cooling_device *cdev, unsigned long
*state)
{
struct acpi_device *device = cdev->devdata;
struct acpi_fan *fan = acpi_driver_data(device);
if (fan->acpi4)
return fan_get_state_acpi4(device, state);
else
return fan_get_state(device, state);
}
static int fan_set_state(struct acpi_device *device, unsigned long state)
{
if (state != 0 && state != 1)
return -EINVAL;
return acpi_device_set_power(device,
state ? ACPI_STATE_D0 : ACPI_STATE_D3_COLD);
}
static int fan_set_state_acpi4(struct acpi_device *device, unsigned long state)
{
struct acpi_fan *fan = acpi_driver_data(device);
acpi_status status;
u64 value = state;
int max_state;
if (fan->fif.fine_grain_ctrl)
max_state = 100 / fan->fif.step_size;
else
max_state = fan->fps_count - 1;
if (state > max_state)
return -EINVAL;
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;
}
Annotation
- Immediate include surface: `linux/bits.h`, `linux/kernel.h`, `linux/limits.h`, `linux/math.h`, `linux/math64.h`, `linux/module.h`, `linux/init.h`, `linux/types.h`.
- Detected declarations: `function fan_get_max_state`, `function acpi_fan_get_fst`, `function fan_get_state_acpi4`, `function fan_get_state`, `function fan_get_cur_state`, `function fan_set_state`, `function fan_set_state_acpi4`, `function fan_set_cur_state`, `function acpi_fan_get_fif`, `function acpi_fan_speed_cmp`.
- Atlas domain: Driver Families / drivers/acpi.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.