drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
Source file repositories/reference/linux-study-clean/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c- Extension
.c- Size
- 6427 bytes
- Lines
- 243
- 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/kernel.hlinux/module.hlinux/init.hlinux/acpi.hlinux/thermal.hlinux/units.hint340x_thermal_zone.h
Detected Declarations
function Copyrightfunction int340x_thermal_set_trip_tempfunction int340x_thermal_criticalfunction int340x_thermal_read_tripsfunction intfunction int340x_thermal_zone_removefunction int340x_update_one_tripfunction int340x_thermal_update_tripsexport int340x_thermal_zone_addexport int340x_thermal_zone_removeexport int340x_thermal_update_trips
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* int340x_thermal_zone.c
* Copyright (c) 2015, Intel Corporation.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/acpi.h>
#include <linux/thermal.h>
#include <linux/units.h>
#include "int340x_thermal_zone.h"
static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone,
int *temp)
{
struct int34x_thermal_zone *d = thermal_zone_device_priv(zone);
unsigned long long tmp;
acpi_status status;
status = acpi_evaluate_integer(d->adev->handle, "_TMP", NULL, &tmp);
if (ACPI_FAILURE(status))
return -EIO;
if (d->lpat_table) {
int conv_temp;
conv_temp = acpi_lpat_raw_to_temp(d->lpat_table, (int)tmp);
if (conv_temp < 0)
return conv_temp;
*temp = conv_temp * 10;
} else {
/* _TMP returns the temperature in tenths of degrees Kelvin */
*temp = deci_kelvin_to_millicelsius(tmp);
}
return 0;
}
static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone,
const struct thermal_trip *trip, int temp)
{
struct int34x_thermal_zone *d = thermal_zone_device_priv(zone);
unsigned int trip_index = THERMAL_TRIP_PRIV_TO_INT(trip->priv);
char name[] = {'P', 'A', 'T', '0' + trip_index, '\0'};
acpi_status status;
if (trip_index > 9)
return -EINVAL;
status = acpi_execute_simple_method(d->adev->handle, name,
millicelsius_to_deci_kelvin(temp));
if (ACPI_FAILURE(status))
return -EIO;
return 0;
}
static void int340x_thermal_critical(struct thermal_zone_device *zone)
{
dev_dbg(thermal_zone_device(zone), "%s: critical temperature reached\n",
thermal_zone_device_type(zone));
}
static int int340x_thermal_read_trips(struct acpi_device *zone_adev,
struct thermal_trip *zone_trips,
int trip_cnt)
{
int i, ret;
ret = thermal_acpi_critical_trip_temp(zone_adev,
&zone_trips[trip_cnt].temperature);
if (!ret) {
zone_trips[trip_cnt].type = THERMAL_TRIP_CRITICAL;
trip_cnt++;
}
ret = thermal_acpi_hot_trip_temp(zone_adev,
&zone_trips[trip_cnt].temperature);
if (!ret) {
zone_trips[trip_cnt].type = THERMAL_TRIP_HOT;
trip_cnt++;
}
ret = thermal_acpi_passive_trip_temp(zone_adev,
&zone_trips[trip_cnt].temperature);
if (!ret) {
zone_trips[trip_cnt].type = THERMAL_TRIP_PASSIVE;
trip_cnt++;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/acpi.h`, `linux/thermal.h`, `linux/units.h`, `int340x_thermal_zone.h`.
- Detected declarations: `function Copyright`, `function int340x_thermal_set_trip_temp`, `function int340x_thermal_critical`, `function int340x_thermal_read_trips`, `function int`, `function int340x_thermal_zone_remove`, `function int340x_update_one_trip`, `function int340x_thermal_update_trips`, `export int340x_thermal_zone_add`, `export int340x_thermal_zone_remove`.
- 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.