tools/thermal/thermal-engine/thermal-engine.c
Source file repositories/reference/linux-study-clean/tools/thermal/thermal-engine/thermal-engine.c
File Facts
- System
- Linux kernel
- Corpus path
tools/thermal/thermal-engine/thermal-engine.c- Extension
.c- Size
- 9728 bytes
- Lines
- 421
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
errno.hfcntl.hgetopt.hlibgen.hlimits.hstdio.hstdlib.hstring.hsignal.hunistd.hsyslog.hsys/epoll.hsys/stat.hsys/types.hthermal.hthermal-tools.h
Detected Declarations
struct optionsstruct thermal_datafunction show_thresholdfunction show_tripfunction show_tempfunction show_governorfunction show_tzfunction set_thresholdfunction tz_createfunction tz_deletefunction tz_disablefunction tz_enablefunction trip_highfunction trip_lowfunction trip_addfunction trip_deletefunction trip_changefunction cdev_addfunction cdev_deletefunction cdev_updatefunction gov_changefunction threshold_addfunction threshold_deletefunction threshold_flushfunction threshold_upfunction threshold_downfunction thermal_eventfunction usagefunction options_initfunction main
Annotated Snippet
struct options {
int loglevel;
int logopt;
int interactive;
int daemonize;
};
struct thermal_data {
struct thermal_zone *tz;
struct thermal_handler *th;
};
static int show_threshold(struct thermal_threshold *th, __maybe_unused void *arg)
{
INFO("threshold temp=%d, direction=%d\n",
th->temperature, th->direction);
return 0;
}
static int show_trip(struct thermal_trip *tt, __maybe_unused void *arg)
{
INFO("trip id=%d, type=%d, temp=%d, hyst=%d\n",
tt->id, tt->type, tt->temp, tt->hyst);
return 0;
}
static int show_temp(struct thermal_zone *tz, __maybe_unused void *arg)
{
thermal_cmd_get_temp(arg, tz);
INFO("temperature: %d\n", tz->temp);
return 0;
}
static int show_governor(struct thermal_zone *tz, __maybe_unused void *arg)
{
thermal_cmd_get_governor(arg, tz);
INFO("governor: '%s'\n", tz->governor);
return 0;
}
static int show_tz(struct thermal_zone *tz, __maybe_unused void *arg)
{
INFO("thermal zone '%s', id=%d\n", tz->name, tz->id);
for_each_thermal_trip(tz->trip, show_trip, NULL);
for_each_thermal_threshold(tz->thresholds, show_threshold, NULL);
show_temp(tz, arg);
show_governor(tz, arg);
return 0;
}
static int set_threshold(struct thermal_zone *tz, __maybe_unused void *arg)
{
struct thermal_handler *th = arg;
int thresholds[] = { 43000, 65000, 49000, 55000, 57000 };
size_t i;
INFO("Setting threshold for thermal zone '%s', id=%d\n", tz->name, tz->id);
if (thermal_cmd_threshold_flush(th, tz)) {
ERROR("Failed to flush all previous thresholds\n");
return -1;
}
for (i = 0; i < sizeof(thresholds) / sizeof(thresholds[0]); i++)
if (thermal_cmd_threshold_add(th, tz, thresholds[i],
THERMAL_THRESHOLD_WAY_UP |
THERMAL_THRESHOLD_WAY_DOWN)) {
ERROR("Failed to set threshold\n");
return -1;
}
return 0;
}
static int tz_create(const char *name, int tz_id, __maybe_unused void *arg)
{
INFO("Thermal zone '%s'/%d created\n", name, tz_id);
return 0;
Annotation
- Immediate include surface: `errno.h`, `fcntl.h`, `getopt.h`, `libgen.h`, `limits.h`, `stdio.h`, `stdlib.h`, `string.h`.
- Detected declarations: `struct options`, `struct thermal_data`, `function show_threshold`, `function show_trip`, `function show_temp`, `function show_governor`, `function show_tz`, `function set_threshold`, `function tz_create`, `function tz_delete`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.