drivers/platform/surface/surface_platform_profile.c
Source file repositories/reference/linux-study-clean/drivers/platform/surface/surface_platform_profile.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/surface/surface_platform_profile.c- Extension
.c- Size
- 6677 bytes
- Lines
- 258
- Domain
- Driver Families
- Bucket
- drivers/platform
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/unaligned.hlinux/kernel.hlinux/module.hlinux/platform_profile.hlinux/types.hlinux/surface_aggregator/device.h
Detected Declarations
struct ssam_tmp_profile_infostruct ssam_platform_profile_deviceenum ssam_tmp_profileenum ssam_fan_profilefunction ssam_tmp_profile_getfunction ssam_tmp_profile_setfunction ssam_fan_profile_setfunction convert_ssam_tmp_to_profilefunction convert_profile_to_ssam_tmpfunction convert_profile_to_ssam_fanfunction ssam_platform_profile_getfunction ssam_platform_profile_setfunction ssam_platform_profile_probefunction surface_platform_profile_probe
Annotated Snippet
struct ssam_tmp_profile_info {
__le32 profile;
__le16 unknown1;
__le16 unknown2;
} __packed;
struct ssam_platform_profile_device {
struct ssam_device *sdev;
struct device *ppdev;
bool has_fan;
};
SSAM_DEFINE_SYNC_REQUEST_CL_R(__ssam_tmp_profile_get, struct ssam_tmp_profile_info, {
.target_category = SSAM_SSH_TC_TMP,
.command_id = 0x02,
});
SSAM_DEFINE_SYNC_REQUEST_CL_W(__ssam_tmp_profile_set, __le32, {
.target_category = SSAM_SSH_TC_TMP,
.command_id = 0x03,
});
SSAM_DEFINE_SYNC_REQUEST_W(__ssam_fan_profile_set, u8, {
.target_category = SSAM_SSH_TC_FAN,
.target_id = SSAM_SSH_TID_SAM,
.command_id = 0x0e,
.instance_id = 0x01,
});
static int ssam_tmp_profile_get(struct ssam_device *sdev, enum ssam_tmp_profile *p)
{
struct ssam_tmp_profile_info info;
int status;
status = ssam_retry(__ssam_tmp_profile_get, sdev, &info);
if (status < 0)
return status;
*p = le32_to_cpu(info.profile);
return 0;
}
static int ssam_tmp_profile_set(struct ssam_device *sdev, enum ssam_tmp_profile p)
{
const __le32 profile_le = cpu_to_le32(p);
return ssam_retry(__ssam_tmp_profile_set, sdev, &profile_le);
}
static int ssam_fan_profile_set(struct ssam_device *sdev, enum ssam_fan_profile p)
{
const u8 profile = p;
return ssam_retry(__ssam_fan_profile_set, sdev->ctrl, &profile);
}
static int convert_ssam_tmp_to_profile(struct ssam_device *sdev, enum ssam_tmp_profile p)
{
switch (p) {
case SSAM_TMP_PROFILE_NORMAL:
return PLATFORM_PROFILE_BALANCED;
case SSAM_TMP_PROFILE_BATTERY_SAVER:
return PLATFORM_PROFILE_LOW_POWER;
case SSAM_TMP_PROFILE_BETTER_PERFORMANCE:
return PLATFORM_PROFILE_BALANCED_PERFORMANCE;
case SSAM_TMP_PROFILE_BEST_PERFORMANCE:
return PLATFORM_PROFILE_PERFORMANCE;
default:
dev_err(&sdev->dev, "invalid performance profile: %d", p);
return -EINVAL;
}
}
static int convert_profile_to_ssam_tmp(struct ssam_device *sdev, enum platform_profile_option p)
{
switch (p) {
case PLATFORM_PROFILE_LOW_POWER:
return SSAM_TMP_PROFILE_BATTERY_SAVER;
case PLATFORM_PROFILE_BALANCED:
return SSAM_TMP_PROFILE_NORMAL;
case PLATFORM_PROFILE_BALANCED_PERFORMANCE:
return SSAM_TMP_PROFILE_BETTER_PERFORMANCE;
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/kernel.h`, `linux/module.h`, `linux/platform_profile.h`, `linux/types.h`, `linux/surface_aggregator/device.h`.
- Detected declarations: `struct ssam_tmp_profile_info`, `struct ssam_platform_profile_device`, `enum ssam_tmp_profile`, `enum ssam_fan_profile`, `function ssam_tmp_profile_get`, `function ssam_tmp_profile_set`, `function ssam_fan_profile_set`, `function convert_ssam_tmp_to_profile`, `function convert_profile_to_ssam_tmp`, `function convert_profile_to_ssam_fan`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: source 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.