drivers/thermal/intel/int340x_thermal/processor_thermal_wt_req.c
Source file repositories/reference/linux-study-clean/drivers/thermal/intel/int340x_thermal/processor_thermal_wt_req.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/intel/int340x_thermal/processor_thermal_wt_req.c- Extension
.c- Size
- 3055 bytes
- Lines
- 139
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pci.hlinux/sysfs.hprocessor_thermal_device.h
Detected Declarations
function workload_available_types_showfunction workload_type_storefunction workload_type_showfunction proc_thermal_wt_req_addfunction proc_thermal_wt_req_removeexport proc_thermal_wt_req_addexport proc_thermal_wt_req_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* processor thermal device for Workload type hints
* update from user space
*
* Copyright (c) 2020-2023, Intel Corporation.
*/
#include <linux/pci.h>
#include <linux/sysfs.h>
#include "processor_thermal_device.h"
/* List of workload types */
static const char * const workload_types[] = {
"none",
"idle",
"semi_active",
"bursty",
"sustained",
"battery_life",
NULL
};
static ssize_t workload_available_types_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
int i = 0;
int ret = 0;
while (workload_types[i] != NULL)
ret += sysfs_emit_at(buf, ret, "%s ", workload_types[i++]);
ret += sysfs_emit_at(buf, ret, "\n");
return ret;
}
static DEVICE_ATTR_RO(workload_available_types);
static ssize_t workload_type_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct pci_dev *pdev = to_pci_dev(dev);
char str_preference[15];
u32 data = 0;
ssize_t ret;
ret = sscanf(buf, "%14s", str_preference);
if (ret != 1)
return -EINVAL;
ret = match_string(workload_types, -1, str_preference);
if (ret < 0)
return ret;
ret &= 0xff;
if (ret)
data = BIT(MBOX_DATA_BIT_VALID) | BIT(MBOX_DATA_BIT_AC_DC);
data |= ret;
ret = processor_thermal_send_mbox_write_cmd(pdev, MBOX_CMD_WORKLOAD_TYPE_WRITE, data);
if (ret)
return false;
return count;
}
static ssize_t workload_type_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct pci_dev *pdev = to_pci_dev(dev);
u64 cmd_resp;
int ret;
ret = processor_thermal_send_mbox_read_cmd(pdev, MBOX_CMD_WORKLOAD_TYPE_READ, &cmd_resp);
if (ret)
return false;
cmd_resp &= 0xff;
if (cmd_resp > ARRAY_SIZE(workload_types) - 1)
return -EINVAL;
return sysfs_emit(buf, "%s\n", workload_types[cmd_resp]);
}
Annotation
- Immediate include surface: `linux/pci.h`, `linux/sysfs.h`, `processor_thermal_device.h`.
- Detected declarations: `function workload_available_types_show`, `function workload_type_store`, `function workload_type_show`, `function proc_thermal_wt_req_add`, `function proc_thermal_wt_req_remove`, `export proc_thermal_wt_req_add`, `export proc_thermal_wt_req_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.