drivers/acpi/thermal_lib.c
Source file repositories/reference/linux-study-clean/drivers/acpi/thermal_lib.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/thermal_lib.c- Extension
.c- Size
- 5129 bytes
- Lines
- 167
- Domain
- Driver Families
- Bucket
- drivers/acpi
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/units.hlinux/thermal.hinternal.h
Detected Declarations
function acpi_trip_tempfunction acpi_active_trip_tempfunction acpi_passive_trip_tempfunction acpi_hot_trip_tempfunction acpi_critical_trip_tempfunction thermal_tempfunction thermal_acpi_active_trip_tempfunction thermal_acpi_passive_trip_tempfunction thermal_acpi_hot_trip_tempfunction thermal_acpi_critical_trip_tempexport thermal_acpi_active_trip_tempexport thermal_acpi_passive_trip_tempexport thermal_acpi_hot_trip_tempexport thermal_acpi_critical_trip_temp
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright 2023 Linaro Limited
* Copyright 2023 Intel Corporation
*
* Library routines for retrieving trip point temperature values from the
* platform firmware via ACPI.
*/
#include <linux/acpi.h>
#include <linux/units.h>
#include <linux/thermal.h>
#include "internal.h"
/*
* Minimum temperature for full military grade is 218°K (-55°C) and
* max temperature is 448°K (175°C). We can consider those values as
* the boundaries for the [trips] temperature returned by the
* firmware. Any values out of these boundaries may be considered
* bogus and we can assume the firmware has no data to provide.
*/
#define TEMP_MIN_DECIK 2180ULL
#define TEMP_MAX_DECIK 4480ULL
static int acpi_trip_temp(struct acpi_device *adev, char *obj_name,
int *ret_temp)
{
unsigned long long temp;
acpi_status status;
status = acpi_evaluate_integer(adev->handle, obj_name, NULL, &temp);
if (ACPI_FAILURE(status)) {
acpi_handle_debug(adev->handle, "%s evaluation failed\n", obj_name);
return -ENODATA;
}
if (temp >= TEMP_MIN_DECIK && temp <= TEMP_MAX_DECIK) {
*ret_temp = temp;
} else {
acpi_handle_debug(adev->handle, "%s result %llu out of range\n",
obj_name, temp);
*ret_temp = THERMAL_TEMP_INVALID;
}
return 0;
}
int acpi_active_trip_temp(struct acpi_device *adev, int id, int *ret_temp)
{
char obj_name[] = {'_', 'A', 'C', '0' + id, '\0'};
if (id < 0 || id > 9)
return -EINVAL;
return acpi_trip_temp(adev, obj_name, ret_temp);
}
EXPORT_SYMBOL_NS_GPL(acpi_active_trip_temp, "ACPI_THERMAL");
int acpi_passive_trip_temp(struct acpi_device *adev, int *ret_temp)
{
return acpi_trip_temp(adev, "_PSV", ret_temp);
}
EXPORT_SYMBOL_NS_GPL(acpi_passive_trip_temp, "ACPI_THERMAL");
int acpi_hot_trip_temp(struct acpi_device *adev, int *ret_temp)
{
return acpi_trip_temp(adev, "_HOT", ret_temp);
}
EXPORT_SYMBOL_NS_GPL(acpi_hot_trip_temp, "ACPI_THERMAL");
int acpi_critical_trip_temp(struct acpi_device *adev, int *ret_temp)
{
return acpi_trip_temp(adev, "_CRT", ret_temp);
}
EXPORT_SYMBOL_NS_GPL(acpi_critical_trip_temp, "ACPI_THERMAL");
static int thermal_temp(int error, int temp_decik, int *ret_temp)
{
if (error)
return error;
if (temp_decik == THERMAL_TEMP_INVALID)
*ret_temp = THERMAL_TEMP_INVALID;
else
*ret_temp = deci_kelvin_to_millicelsius(temp_decik);
return 0;
}
/**
* thermal_acpi_active_trip_temp - Retrieve active trip point temperature
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/units.h`, `linux/thermal.h`, `internal.h`.
- Detected declarations: `function acpi_trip_temp`, `function acpi_active_trip_temp`, `function acpi_passive_trip_temp`, `function acpi_hot_trip_temp`, `function acpi_critical_trip_temp`, `function thermal_temp`, `function thermal_acpi_active_trip_temp`, `function thermal_acpi_passive_trip_temp`, `function thermal_acpi_hot_trip_temp`, `function thermal_acpi_critical_trip_temp`.
- Atlas domain: Driver Families / drivers/acpi.
- Implementation status: integration 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.