drivers/platform/x86/gigabyte-wmi.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/gigabyte-wmi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/gigabyte-wmi.c- Extension
.c- Size
- 4113 bytes
- Lines
- 165
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/hwmon.hlinux/module.hlinux/wmi.h
Detected Declarations
struct gigabyte_wmi_argsenum gigabyte_wmi_commandtypefunction gigabyte_wmi_perform_queryfunction gigabyte_wmi_query_integerfunction gigabyte_wmi_temperaturefunction gigabyte_wmi_hwmon_readfunction gigabyte_wmi_hwmon_is_visiblefunction gigabyte_wmi_detect_sensor_usabilityfunction gigabyte_wmi_probe
Annotated Snippet
struct gigabyte_wmi_args {
u32 arg1;
};
static int gigabyte_wmi_perform_query(struct wmi_device *wdev,
enum gigabyte_wmi_commandtype command,
struct gigabyte_wmi_args *args, struct acpi_buffer *out)
{
const struct acpi_buffer in = {
.length = sizeof(*args),
.pointer = args,
};
acpi_status ret = wmidev_evaluate_method(wdev, 0x0, command, &in, out);
if (ACPI_FAILURE(ret))
return -EIO;
return 0;
}
static int gigabyte_wmi_query_integer(struct wmi_device *wdev,
enum gigabyte_wmi_commandtype command,
struct gigabyte_wmi_args *args, u64 *res)
{
union acpi_object *obj;
struct acpi_buffer result = { ACPI_ALLOCATE_BUFFER, NULL };
int ret;
ret = gigabyte_wmi_perform_query(wdev, command, args, &result);
if (ret)
return ret;
obj = result.pointer;
if (obj && obj->type == ACPI_TYPE_INTEGER)
*res = obj->integer.value;
else
ret = -EIO;
kfree(result.pointer);
return ret;
}
static int gigabyte_wmi_temperature(struct wmi_device *wdev, u8 sensor, long *res)
{
struct gigabyte_wmi_args args = {
.arg1 = sensor,
};
u64 temp;
acpi_status ret;
ret = gigabyte_wmi_query_integer(wdev, GIGABYTE_WMI_TEMPERATURE_QUERY, &args, &temp);
if (ret == 0) {
if (temp == 0)
return -ENODEV;
*res = (s8)temp * 1000; // value is a signed 8-bit integer
}
return ret;
}
static int gigabyte_wmi_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{
struct wmi_device *wdev = dev_get_drvdata(dev);
return gigabyte_wmi_temperature(wdev, channel, val);
}
static umode_t gigabyte_wmi_hwmon_is_visible(const void *data, enum hwmon_sensor_types type,
u32 attr, int channel)
{
return usable_sensors_mask & BIT(channel) ? 0444 : 0;
}
static const struct hwmon_channel_info * const gigabyte_wmi_hwmon_info[] = {
HWMON_CHANNEL_INFO(temp,
HWMON_T_INPUT,
HWMON_T_INPUT,
HWMON_T_INPUT,
HWMON_T_INPUT,
HWMON_T_INPUT,
HWMON_T_INPUT),
NULL
};
static const struct hwmon_ops gigabyte_wmi_hwmon_ops = {
.read = gigabyte_wmi_hwmon_read,
.is_visible = gigabyte_wmi_hwmon_is_visible,
};
static const struct hwmon_chip_info gigabyte_wmi_hwmon_chip_info = {
.ops = &gigabyte_wmi_hwmon_ops,
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/hwmon.h`, `linux/module.h`, `linux/wmi.h`.
- Detected declarations: `struct gigabyte_wmi_args`, `enum gigabyte_wmi_commandtype`, `function gigabyte_wmi_perform_query`, `function gigabyte_wmi_query_integer`, `function gigabyte_wmi_temperature`, `function gigabyte_wmi_hwmon_read`, `function gigabyte_wmi_hwmon_is_visible`, `function gigabyte_wmi_detect_sensor_usability`, `function gigabyte_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.