drivers/thermal/thermal_core.c
Source file repositories/reference/linux-study-clean/drivers/thermal/thermal_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/thermal_core.c- Extension
.c- Size
- 46771 bytes
- Lines
- 1831
- 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/device.hlinux/err.hlinux/export.hlinux/slab.hlinux/kdev_t.hlinux/idr.hlinux/thermal.hlinux/reboot.hlinux/string.hlinux/of.hlinux/suspend.hthermal_trace.hthermal_core.hthermal_hwmon.h
Detected Declarations
function bind_previous_governorfunction thermal_set_governorfunction thermal_register_governorfunction thermal_zone_device_set_policyfunction thermal_build_list_of_policiesfunction list_for_each_entryfunction thermal_unregister_governorsfunction thermal_register_governorsfunction for_each_governor_tablefunction __thermal_zone_device_set_modefunction thermal_zone_broken_disablefunction for_each_trip_descfunction thermal_zone_device_set_pollingfunction thermal_zone_recheckfunction monitor_thermal_zonefunction thermal_governor_update_tzfunction thermal_zone_device_haltfunction thermal_zone_device_criticalfunction thermal_zone_device_critical_shutdownfunction thermal_zone_device_critical_rebootfunction handle_critical_tripsfunction move_trip_to_sorted_listfunction move_to_trips_highfunction move_to_trips_reachedfunction move_to_trips_invalidfunction thermal_governor_trip_crossedfunction thermal_trip_crossedfunction thermal_zone_set_trip_hystfunction thermal_zone_set_trip_tempfunction thermal_zone_handle_tripsfunction __thermal_zone_device_updatefunction thermal_zone_device_set_modefunction thermal_zone_device_enablefunction thermal_zone_device_disablefunction thermal_zone_device_updatefunction for_each_thermal_governorfunction list_for_each_entryfunction for_each_thermal_cooling_devicefunction list_for_each_entryfunction for_each_thermal_zonefunction list_for_each_entryfunction list_for_each_entryfunction thermal_instance_addfunction list_for_each_entryfunction thermal_bind_cdev_to_tripfunction thermal_instance_deletefunction thermal_unbind_cdev_from_tripfunction list_for_each_entry_safe
Annotated Snippet
ret = device_add(&cdev->device);
if (ret)
goto out_put_device;
if (current_state <= cdev->max_state)
thermal_debug_cdev_add(cdev, current_state);
thermal_cooling_device_init_complete(cdev);
return 0;
out_put_device:
/*
* The device core will release the memory via
* thermal_release() after put_device() is called in the error
* path
*/
put_device(&cdev->device);
return ret;
}
/**
* thermal_cooling_device_register() - register a new thermal cooling device
* @type: the thermal cooling device type.
* @devdata: device private data.
* @ops: standard thermal cooling devices callbacks.
*
* This interface function adds a new thermal cooling device (fan/processor/...)
* to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself
* to all the thermal zone devices registered at the same time.
*
* Return: a pointer to the created struct thermal_cooling_device or an
* ERR_PTR. Caller must check return value with IS_ERR*() helpers.
*/
struct thermal_cooling_device *
thermal_cooling_device_register(const char *type, void *devdata,
const struct thermal_cooling_device_ops *ops)
{
struct thermal_cooling_device *cdev;
int ret;
cdev = thermal_cooling_device_alloc(type, ops);
if (IS_ERR(cdev))
return cdev;
ret = thermal_cooling_device_add(cdev, devdata);
if (ret)
return ERR_PTR(ret);
return cdev;
}
EXPORT_SYMBOL_GPL(thermal_cooling_device_register);
static void thermal_cooling_device_release(void *data)
{
struct thermal_cooling_device *cdev = data;
thermal_cooling_device_unregister(cdev);
}
/**
* devm_thermal_cooling_device_register() - register a thermal cooling device
*
* @dev: a valid struct device pointer of a sensor device.
* @type: the thermal cooling device type.
* @devdata: device private data.
* @ops: standard thermal cooling devices callbacks.
*
* This function will register a cooling device. This interface
* function adds a new thermal cooling device (fan/processor/...) to
* /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind
* itself to all the thermal zone devices registered at the same time.
*
* Return: a pointer to the created struct thermal_cooling_device or an
* ERR_PTR. Caller must check return value with IS_ERR*() helpers.
*/
struct thermal_cooling_device *
devm_thermal_cooling_device_register(struct device *dev, const char *type, void *devdata,
const struct thermal_cooling_device_ops *ops)
{
struct thermal_cooling_device *cdev;
int ret;
cdev = thermal_cooling_device_register(type, devdata, ops);
if (IS_ERR(cdev))
return cdev;
ret = devm_add_action_or_reset(dev, thermal_cooling_device_release, cdev);
if (ret)
return ERR_PTR(ret);
Annotation
- Immediate include surface: `linux/device.h`, `linux/err.h`, `linux/export.h`, `linux/slab.h`, `linux/kdev_t.h`, `linux/idr.h`, `linux/thermal.h`, `linux/reboot.h`.
- Detected declarations: `function bind_previous_governor`, `function thermal_set_governor`, `function thermal_register_governor`, `function thermal_zone_device_set_policy`, `function thermal_build_list_of_policies`, `function list_for_each_entry`, `function thermal_unregister_governors`, `function thermal_register_governors`, `function for_each_governor_table`, `function __thermal_zone_device_set_mode`.
- 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.