drivers/thermal/intel/int340x_thermal/platform_temperature_control.c
Source file repositories/reference/linux-study-clean/drivers/thermal/intel/int340x_thermal/platform_temperature_control.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/intel/int340x_thermal/platform_temperature_control.c- Extension
.c- Size
- 9109 bytes
- Lines
- 320
- Domain
- Driver Families
- Bucket
- drivers/thermal
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/debugfs.hlinux/pci.hprocessor_thermal_device.h
Detected Declarations
struct mmio_regstruct ptc_datafunction ptc_mmio_showfunction ptc_mmio_writefunction ptc_storefunction ptc_create_groupsfunction ptc_temperature_writefunction ptc_create_debugfsfunction ptc_delete_debugfsfunction proc_thermal_ptc_addfunction proc_thermal_ptc_removeexport proc_thermal_ptc_addexport proc_thermal_ptc_remove
Annotated Snippet
static const struct file_operations ptc_fops = {
.open = simple_open,
.write = ptc_temperature_write,
.llseek = generic_file_llseek,
};
static void ptc_create_debugfs(void)
{
ptc_debugfs = debugfs_create_dir("platform_temperature_control", NULL);
debugfs_create_file("temperature_0", 0200, ptc_debugfs, &ptc_instance[0], &ptc_fops);
debugfs_create_file("temperature_1", 0200, ptc_debugfs, &ptc_instance[1], &ptc_fops);
debugfs_create_file("temperature_2", 0200, ptc_debugfs, &ptc_instance[2], &ptc_fops);
}
static void ptc_delete_debugfs(void)
{
debugfs_remove_recursive(ptc_debugfs);
}
int proc_thermal_ptc_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv)
{
if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_PTC) {
int i, ret;
for (i = 0; i < PTC_MAX_INSTANCES; i++) {
ptc_instance[i].offset = ptc_offsets[i];
ptc_instance[i].pdev = pdev;
ret = ptc_create_groups(pdev, i, &ptc_instance[i]);
if (ret) {
while (i--)
sysfs_remove_group(&pdev->dev.kobj,
&ptc_instance[i].ptc_attr_group);
return ret;
}
}
ptc_create_debugfs();
}
return 0;
}
EXPORT_SYMBOL_GPL(proc_thermal_ptc_add);
void proc_thermal_ptc_remove(struct pci_dev *pdev)
{
struct proc_thermal_device *proc_priv = pci_get_drvdata(pdev);
if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_PTC) {
int i;
for (i = 0; i < PTC_MAX_INSTANCES; i++)
sysfs_remove_group(&pdev->dev.kobj, &ptc_instance[i].ptc_attr_group);
ptc_delete_debugfs();
}
}
EXPORT_SYMBOL_GPL(proc_thermal_ptc_remove);
MODULE_IMPORT_NS("INT340X_THERMAL");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Processor Thermal PTC Interface");
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/debugfs.h`, `linux/pci.h`, `processor_thermal_device.h`.
- Detected declarations: `struct mmio_reg`, `struct ptc_data`, `function ptc_mmio_show`, `function ptc_mmio_write`, `function ptc_store`, `function ptc_create_groups`, `function ptc_temperature_write`, `function ptc_create_debugfs`, `function ptc_delete_debugfs`, `function proc_thermal_ptc_add`.
- Atlas domain: Driver Families / drivers/thermal.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.