drivers/platform/x86/wireless-hotkey.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/wireless-hotkey.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/wireless-hotkey.c- Extension
.c- Size
- 3146 bytes
- Lines
- 139
- 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/kernel.hlinux/module.hlinux/init.hlinux/input.hlinux/platform_device.hlinux/acpi.hacpi/acpi_bus.h
Detected Declarations
struct wl_buttonfunction wireless_input_setupfunction wireless_input_destroyfunction wl_notifyfunction wl_probefunction wl_remove
Annotated Snippet
struct wl_button {
struct input_dev *input_dev;
char phys[32];
};
static const struct acpi_device_id wl_ids[] = {
{"HPQ6001", 0},
{"WSTADEF", 0},
{"AMDI0051", 0},
{"LGEX0815", 0},
{"", 0},
};
static int wireless_input_setup(struct device *dev)
{
struct wl_button *button = dev_get_drvdata(dev);
int err;
button->input_dev = input_allocate_device();
if (!button->input_dev)
return -ENOMEM;
snprintf(button->phys, sizeof(button->phys), "%s/input0",
acpi_device_hid(ACPI_COMPANION(dev)));
button->input_dev->name = "Wireless hotkeys";
button->input_dev->phys = button->phys;
button->input_dev->id.bustype = BUS_HOST;
button->input_dev->evbit[0] = BIT(EV_KEY);
set_bit(KEY_RFKILL, button->input_dev->keybit);
err = input_register_device(button->input_dev);
if (err)
goto err_free_dev;
return 0;
err_free_dev:
input_free_device(button->input_dev);
return err;
}
static void wireless_input_destroy(struct device *dev)
{
struct wl_button *button = dev_get_drvdata(dev);
input_unregister_device(button->input_dev);
kfree(button);
}
static void wl_notify(acpi_handle handle, u32 event, void *data)
{
struct wl_button *button = data;
if (event != 0x80) {
pr_info("Received unknown event (0x%x)\n", event);
return;
}
input_report_key(button->input_dev, KEY_RFKILL, 1);
input_sync(button->input_dev);
input_report_key(button->input_dev, KEY_RFKILL, 0);
input_sync(button->input_dev);
}
static int wl_probe(struct platform_device *pdev)
{
struct acpi_device *adev;
struct wl_button *button;
int err;
adev = ACPI_COMPANION(&pdev->dev);
if (!adev)
return -ENODEV;
button = kzalloc_obj(struct wl_button);
if (!button)
return -ENOMEM;
platform_set_drvdata(pdev, button);
err = wireless_input_setup(&pdev->dev);
if (err) {
pr_err("Failed to setup wireless hotkeys\n");
kfree(button);
return err;
}
err = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
wl_notify, button);
if (err) {
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/input.h`, `linux/platform_device.h`, `linux/acpi.h`, `acpi/acpi_bus.h`.
- Detected declarations: `struct wl_button`, `function wireless_input_setup`, `function wireless_input_destroy`, `function wl_notify`, `function wl_probe`, `function wl_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.