drivers/platform/x86/wmi-bmof.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/wmi-bmof.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/wmi-bmof.c- Extension
.c- Size
- 2359 bytes
- Lines
- 103
- 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/device.hlinux/fs.hlinux/kernel.hlinux/module.hlinux/string.hlinux/sysfs.hlinux/types.hlinux/wmi.h
Detected Declarations
function Copyrightfunction bmof_bin_sizefunction wmi_bmof_probefunction wmi_bmof_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* WMI embedded Binary MOF driver
*
* Copyright (c) 2015 Andrew Lutomirski
* Copyright (C) 2017 VMware, Inc. All Rights Reserved.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/string.h>
#include <linux/sysfs.h>
#include <linux/types.h>
#include <linux/wmi.h>
#define WMI_BMOF_GUID "05901221-D566-11D1-B2F0-00A0C9062910"
static ssize_t bmof_read(struct file *filp, struct kobject *kobj, const struct bin_attribute *attr,
char *buf, loff_t off, size_t count)
{
struct device *dev = kobj_to_dev(kobj);
struct wmi_buffer *buffer = dev_get_drvdata(dev);
return memory_read_from_buffer(buf, count, &off, buffer->data, buffer->length);
}
static const BIN_ATTR_ADMIN_RO(bmof, 0);
static const struct bin_attribute * const bmof_attrs[] = {
&bin_attr_bmof,
NULL
};
static size_t bmof_bin_size(struct kobject *kobj, const struct bin_attribute *attr, int n)
{
struct device *dev = kobj_to_dev(kobj);
struct wmi_buffer *buffer = dev_get_drvdata(dev);
return buffer->length;
}
static const struct attribute_group bmof_group = {
.bin_size = bmof_bin_size,
.bin_attrs = bmof_attrs,
};
static const struct attribute_group *bmof_groups[] = {
&bmof_group,
NULL
};
static int wmi_bmof_probe(struct wmi_device *wdev, const void *context)
{
struct wmi_buffer *buffer;
int ret;
buffer = devm_kzalloc(&wdev->dev, sizeof(*buffer), GFP_KERNEL);
if (!buffer)
return -ENOMEM;
ret = wmidev_query_block(wdev, 0, buffer, 0);
if (ret < 0)
return ret;
dev_set_drvdata(&wdev->dev, buffer);
return 0;
}
static void wmi_bmof_remove(struct wmi_device *wdev)
{
struct wmi_buffer *buffer = dev_get_drvdata(&wdev->dev);
kfree(buffer->data);
}
static const struct wmi_device_id wmi_bmof_id_table[] = {
{ .guid_string = WMI_BMOF_GUID },
{ },
};
static struct wmi_driver wmi_bmof_driver = {
.driver = {
.name = "wmi-bmof",
.dev_groups = bmof_groups,
},
Annotation
- Immediate include surface: `linux/device.h`, `linux/fs.h`, `linux/kernel.h`, `linux/module.h`, `linux/string.h`, `linux/sysfs.h`, `linux/types.h`, `linux/wmi.h`.
- Detected declarations: `function Copyright`, `function bmof_bin_size`, `function wmi_bmof_probe`, `function wmi_bmof_remove`.
- 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.