drivers/hwmon/asus_wmi_sensors.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/asus_wmi_sensors.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/asus_wmi_sensors.c- Extension
.c- Size
- 15689 bytes
- Lines
- 664
- Domain
- Driver Families
- Bucket
- drivers/hwmon
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/dmi.hlinux/hwmon.hlinux/init.hlinux/jiffies.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/units.hlinux/wmi.h
Detected Declarations
struct asus_wmi_sensor_infostruct asus_wmi_wmi_infostruct asus_wmi_sensorsenum asus_wmi_sensor_classenum asus_wmi_locationenum asus_wmi_typeenum asus_wmi_sourcefunction Copyrightfunction asus_wmi_call_methodfunction asus_wmi_get_versionfunction asus_wmi_get_item_countfunction asus_wmi_hwmon_add_chan_infofunction asus_wmi_sensor_infofunction asus_wmi_update_bufferfunction asus_wmi_get_sensor_valuefunction asus_wmi_update_values_for_sourcefunction asus_wmi_scale_sensor_valuefunction asus_wmi_get_cached_value_or_updatefunction asus_wmi_hwmon_readfunction asus_wmi_hwmon_read_stringfunction asus_wmi_hwmon_is_visiblefunction asus_wmi_configure_sensor_setupfunction asus_wmi_probe
Annotated Snippet
struct asus_wmi_sensor_info {
u32 id;
int data_type;
int location;
char name[ASUS_WMI_MAX_STR_SIZE];
int source;
int type;
long cached_value;
};
struct asus_wmi_wmi_info {
unsigned long source_last_updated[3]; /* in jiffies */
int sensor_count;
const struct asus_wmi_sensor_info **info[hwmon_max];
struct asus_wmi_sensor_info **info_by_id;
};
struct asus_wmi_sensors {
struct asus_wmi_wmi_info wmi;
/* lock access to internal cache */
struct mutex lock;
};
/*
* Universal method for calling WMI method
*/
static int asus_wmi_call_method(u32 method_id, u32 *args, struct acpi_buffer *output)
{
struct acpi_buffer input = {(acpi_size) sizeof(*args), args };
acpi_status status;
status = wmi_evaluate_method(ASUSWMI_MONITORING_GUID, 0,
method_id, &input, output);
if (ACPI_FAILURE(status))
return -EIO;
return 0;
}
/*
* Gets the version of the ASUS sensors interface implemented
*/
static int asus_wmi_get_version(u32 *version)
{
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
u32 args[] = {0, 0, 0};
union acpi_object *obj;
int err;
err = asus_wmi_call_method(ASUSWMI_METHODID_GET_VERSION, args, &output);
if (err)
return err;
obj = output.pointer;
if (!obj)
return -EIO;
if (obj->type != ACPI_TYPE_INTEGER) {
err = -EIO;
goto out_free_obj;
}
err = 0;
*version = obj->integer.value;
out_free_obj:
ACPI_FREE(obj);
return err;
}
/*
* Gets the number of sensor items
*/
static int asus_wmi_get_item_count(u32 *count)
{
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
u32 args[] = {0, 0, 0};
union acpi_object *obj;
int err;
err = asus_wmi_call_method(ASUSWMI_METHODID_GET_NUMBER, args, &output);
if (err)
return err;
obj = output.pointer;
if (!obj)
return -EIO;
if (obj->type != ACPI_TYPE_INTEGER) {
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/dmi.h`, `linux/hwmon.h`, `linux/init.h`, `linux/jiffies.h`, `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`.
- Detected declarations: `struct asus_wmi_sensor_info`, `struct asus_wmi_wmi_info`, `struct asus_wmi_sensors`, `enum asus_wmi_sensor_class`, `enum asus_wmi_location`, `enum asus_wmi_type`, `enum asus_wmi_source`, `function Copyright`, `function asus_wmi_call_method`, `function asus_wmi_get_version`.
- Atlas domain: Driver Families / drivers/hwmon.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.