drivers/platform/x86/inspur_platform_profile.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/inspur_platform_profile.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/inspur_platform_profile.c- Extension
.c- Size
- 5206 bytes
- Lines
- 221
- 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/acpi.hlinux/device.hlinux/module.hlinux/platform_profile.hlinux/wmi.h
Detected Declarations
struct inspur_wmi_privenum inspur_wmi_method_idsenum inspur_tmp_profilefunction inspur_wmi_perform_queryfunction inspur_platform_profile_setfunction inspur_platform_profile_getfunction inspur_platform_profile_probefunction inspur_wmi_probe
Annotated Snippet
struct inspur_wmi_priv {
struct wmi_device *wdev;
struct device *ppdev;
};
static int inspur_wmi_perform_query(struct wmi_device *wdev,
enum inspur_wmi_method_ids query_id,
void *buffer, size_t insize,
size_t outsize)
{
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_buffer input = { insize, buffer};
union acpi_object *obj;
acpi_status status;
int ret = 0;
status = wmidev_evaluate_method(wdev, 0, query_id, &input, &output);
if (ACPI_FAILURE(status)) {
dev_err(&wdev->dev, "EC Powermode control failed: %s\n",
acpi_format_exception(status));
return -EIO;
}
obj = output.pointer;
if (!obj)
return -EINVAL;
if (obj->type != ACPI_TYPE_BUFFER ||
obj->buffer.length != outsize) {
ret = -EINVAL;
goto out_free;
}
memcpy(buffer, obj->buffer.pointer, obj->buffer.length);
out_free:
kfree(obj);
return ret;
}
/*
* Set Power Mode to EC RAM. If Power Mode value greater than 0x3,
* return error
* Method ID: 0x3
* Arg: 4 Bytes
* Byte [0]: Power Mode:
* 0x0: Balance Mode
* 0x1: Performance Mode
* 0x2: Power Saver Mode
* Return Value: 4 Bytes
* Byte [0]: Return Code
* 0x0: No Error
* 0x1: Error
*/
static int inspur_platform_profile_set(struct device *dev,
enum platform_profile_option profile)
{
struct inspur_wmi_priv *priv = dev_get_drvdata(dev);
u8 ret_code[4] = {0, 0, 0, 0};
int ret;
switch (profile) {
case PLATFORM_PROFILE_BALANCED:
ret_code[0] = INSPUR_TMP_PROFILE_BALANCE;
break;
case PLATFORM_PROFILE_PERFORMANCE:
ret_code[0] = INSPUR_TMP_PROFILE_PERFORMANCE;
break;
case PLATFORM_PROFILE_LOW_POWER:
ret_code[0] = INSPUR_TMP_PROFILE_POWERSAVE;
break;
default:
return -EOPNOTSUPP;
}
ret = inspur_wmi_perform_query(priv->wdev, INSPUR_WMI_SET_POWERMODE,
ret_code, sizeof(ret_code),
sizeof(ret_code));
if (ret < 0)
return ret;
if (ret_code[0])
return -EBADRQC;
return 0;
}
/*
* Get Power Mode from EC RAM, If Power Mode value greater than 0x3,
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/device.h`, `linux/module.h`, `linux/platform_profile.h`, `linux/wmi.h`.
- Detected declarations: `struct inspur_wmi_priv`, `enum inspur_wmi_method_ids`, `enum inspur_tmp_profile`, `function inspur_wmi_perform_query`, `function inspur_platform_profile_set`, `function inspur_platform_profile_get`, `function inspur_platform_profile_probe`, `function inspur_wmi_probe`.
- 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.