drivers/thermal/thermal_of.c
Source file repositories/reference/linux-study-clean/drivers/thermal/thermal_of.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/thermal_of.c- Extension
.c- Size
- 18279 bytes
- Lines
- 653
- Domain
- Driver Families
- Bucket
- drivers/thermal
- 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.
- 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/err.hlinux/export.hlinux/of.hlinux/slab.hlinux/thermal.hlinux/types.hlinux/string.hthermal_core.h
Detected Declarations
function thermal_of_get_trip_typefunction thermal_of_populate_tripfunction thermal_of_monitor_initfunction thermal_of_parameters_initfunction thermal_of_get_cooling_specfunction thermal_of_cm_lookupfunction thermal_of_should_bindfunction thermal_of_zone_unregisterfunction thermal_of_zone_registerfunction devm_thermal_of_zone_releasefunction devm_thermal_of_zone_matchfunction thermal_of_zone_registerfunction thermal_of_zone_unregisterfunction thermal_of_cooling_device_registerfunction thermal_of_cooling_device_releasefunction __devm_thermal_of_cooling_device_registerfunction devm_thermal_of_cooling_device_registerfunction devm_thermal_of_child_cooling_device_registerexport devm_thermal_of_zone_registerexport devm_thermal_of_zone_unregisterexport thermal_of_cooling_device_registerexport devm_thermal_of_cooling_device_registerexport devm_thermal_of_child_cooling_device_register
Annotated Snippet
if (!strcasecmp(t, trip_types[i])) {
*type = i;
return 0;
}
return -ENODEV;
}
static int thermal_of_populate_trip(struct device_node *np,
struct thermal_trip *trip)
{
int prop;
int ret;
ret = of_property_read_u32(np, "temperature", &prop);
if (ret < 0) {
pr_err("missing temperature property\n");
return ret;
}
trip->temperature = prop;
ret = of_property_read_u32(np, "hysteresis", &prop);
if (ret < 0) {
pr_err("missing hysteresis property\n");
return ret;
}
trip->hysteresis = prop;
ret = thermal_of_get_trip_type(np, &trip->type);
if (ret < 0) {
pr_err("wrong trip type property\n");
return ret;
}
trip->flags = THERMAL_TRIP_FLAG_RW_TEMP;
trip->priv = np;
return 0;
}
static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *ntrips)
{
int ret, count;
*ntrips = 0;
struct device_node *trips __free(device_node) = of_get_child_by_name(np, "trips");
if (!trips)
return NULL;
count = of_get_child_count(trips);
if (!count)
return NULL;
struct thermal_trip *tt __free(kfree) = kzalloc_objs(*tt, count);
if (!tt)
return ERR_PTR(-ENOMEM);
count = 0;
for_each_child_of_node_scoped(trips, trip) {
ret = thermal_of_populate_trip(trip, &tt[count++]);
if (ret)
return ERR_PTR(ret);
}
*ntrips = count;
return no_free_ptr(tt);
}
static struct device_node *of_thermal_zone_find(struct device_node *sensor, int id)
{
struct of_phandle_args sensor_specs;
struct device_node *np __free(device_node) = of_find_node_by_name(NULL, "thermal-zones");
if (!np) {
pr_debug("No thermal zones description\n");
return ERR_PTR(-ENODEV);
}
/*
* Search for each thermal zone, a defined sensor
* corresponding to the one passed as parameter
*/
for_each_available_child_of_node_scoped(np, child) {
int count, i;
count = of_count_phandle_with_args(child, "thermal-sensors",
Annotation
- Immediate include surface: `linux/err.h`, `linux/export.h`, `linux/of.h`, `linux/slab.h`, `linux/thermal.h`, `linux/types.h`, `linux/string.h`, `thermal_core.h`.
- Detected declarations: `function thermal_of_get_trip_type`, `function thermal_of_populate_trip`, `function thermal_of_monitor_init`, `function thermal_of_parameters_init`, `function thermal_of_get_cooling_spec`, `function thermal_of_cm_lookup`, `function thermal_of_should_bind`, `function thermal_of_zone_unregister`, `function thermal_of_zone_register`, `function devm_thermal_of_zone_release`.
- Atlas domain: Driver Families / drivers/thermal.
- 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.