Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * wmi.h - ACPI WMI interface
4 *
5 * Copyright (c) 2015 Andrew Lutomirski
6 */
7
8#ifndef _LINUX_WMI_H
9#define _LINUX_WMI_H
10
11#include <linux/device.h>
12#include <linux/acpi.h>
13#include <linux/mod_devicetable.h>
14
15/**
16 * struct wmi_device - WMI device structure
17 * @dev: Device associated with this WMI device
18 * @setable: True for devices implementing the Set Control Method
19 * @driver_override: Driver name to force a match; do not set directly,
20 * because core frees it; use driver_set_override() to
21 * set or clear it.
22 *
23 * This represents WMI devices discovered by the WMI driver core.
24 */
25struct wmi_device {
26 struct device dev;
27 bool setable;
28 const char *driver_override;
29};
30
31/**
32 * to_wmi_device() - Helper macro to cast a device to a wmi_device
33 * @device: device struct
34 *
35 * Cast a struct device to a struct wmi_device.
36 */
37#define to_wmi_device(device) container_of_const(device, struct wmi_device, dev)
38
39acpi_status wmidev_evaluate_method(struct wmi_device *wdev, u8 instance, u32 method_id,
40 const struct acpi_buffer *in, struct acpi_buffer *out);
41
42union acpi_object *wmidev_block_query(struct wmi_device *wdev, u8 instance);
43
44acpi_status wmidev_block_set(struct wmi_device *wdev, u8 instance, const struct acpi_buffer *in);
45
46u8 wmidev_instance_count(struct wmi_device *wdev);
47
48/**
49 * struct wmi_driver - WMI driver structure
50 * @driver: Driver model structure
51 * @id_table: List of WMI GUIDs supported by this driver
52 * @no_notify_data: Driver supports WMI events which provide no event data
53 * @no_singleton: Driver can be instantiated multiple times
54 * @probe: Callback for device binding
55 * @remove: Callback for device unbinding
56 * @shutdown: Callback for device shutdown
57 * @notify: Callback for receiving WMI events
58 *
59 * This represents WMI drivers which handle WMI devices.
60 */
61struct wmi_driver {
62 struct device_driver driver;
63 const struct wmi_device_id *id_table;
64 bool no_notify_data;
65 bool no_singleton;
66
67 int (*probe)(struct wmi_device *wdev, const void *context);
68 void (*remove)(struct wmi_device *wdev);
69 void (*shutdown)(struct wmi_device *wdev);
70 void (*notify)(struct wmi_device *device, union acpi_object *data);
71};
72
73/**
74 * to_wmi_driver() - Helper macro to cast a driver to a wmi_driver
75 * @drv: driver struct
76 *
77 * Cast a struct device_driver to a struct wmi_driver.
78 */
79#define to_wmi_driver(drv) container_of_const(drv, struct wmi_driver, driver)
80
81int __must_check __wmi_driver_register(struct wmi_driver *driver, struct module *owner);
82
83void wmi_driver_unregister(struct wmi_driver *driver);
84
85/**
86 * wmi_driver_register() - Helper macro to register a WMI driver
87 * @driver: wmi_driver struct
88 *
89 * Helper macro for registering a WMI driver. It automatically passes
90 * THIS_MODULE to the underlying function.
91 */
92#define wmi_driver_register(driver) __wmi_driver_register((driver), THIS_MODULE)
93
94/**
95 * module_wmi_driver() - Helper macro to register/unregister a WMI driver
96 * @__wmi_driver: wmi_driver struct
97 *
98 * Helper macro for WMI drivers which do not do anything special in module
99 * init/exit. This eliminates a lot of boilerplate. Each module may only
100 * use this macro once, and calling it replaces module_init() and module_exit().
101 */
102#define module_wmi_driver(__wmi_driver) \
103 module_driver(__wmi_driver, wmi_driver_register, \
104 wmi_driver_unregister)
105
106#endif