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.

Dependency Surface

Detected Declarations

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

Implementation Notes