1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * wmi.h - ACPI WMI interface
5 * Copyright (c) 2015 Andrew Lutomirski
11 #include <linux/device.h>
12 #include <linux/acpi.h>
13 #include <linux/mod_devicetable.h>
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
23 * This represents WMI devices discovered by the WMI driver core.
28 const char *driver_override
;
32 * to_wmi_device() - Helper macro to cast a device to a wmi_device
33 * @device: device struct
35 * Cast a struct device to a struct wmi_device.
37 #define to_wmi_device(device) container_of_const(device, struct wmi_device, dev)
39 extern acpi_status
wmidev_evaluate_method(struct wmi_device
*wdev
,
40 u8 instance
, u32 method_id
,
41 const struct acpi_buffer
*in
,
42 struct acpi_buffer
*out
);
44 extern union acpi_object
*wmidev_block_query(struct wmi_device
*wdev
,
47 acpi_status
wmidev_block_set(struct wmi_device
*wdev
, u8 instance
, const struct acpi_buffer
*in
);
49 u8
wmidev_instance_count(struct wmi_device
*wdev
);
52 * struct wmi_driver - WMI driver structure
53 * @driver: Driver model structure
54 * @id_table: List of WMI GUIDs supported by this driver
55 * @no_notify_data: Driver supports WMI events which provide no event data
56 * @no_singleton: Driver can be instantiated multiple times
57 * @probe: Callback for device binding
58 * @remove: Callback for device unbinding
59 * @shutdown: Callback for device shutdown
60 * @notify: Callback for receiving WMI events
62 * This represents WMI drivers which handle WMI devices.
65 struct device_driver driver
;
66 const struct wmi_device_id
*id_table
;
70 int (*probe
)(struct wmi_device
*wdev
, const void *context
);
71 void (*remove
)(struct wmi_device
*wdev
);
72 void (*shutdown
)(struct wmi_device
*wdev
);
73 void (*notify
)(struct wmi_device
*device
, union acpi_object
*data
);
77 * to_wmi_driver() - Helper macro to cast a driver to a wmi_driver
80 * Cast a struct device_driver to a struct wmi_driver.
82 #define to_wmi_driver(drv) container_of_const(drv, struct wmi_driver, driver)
84 extern int __must_check
__wmi_driver_register(struct wmi_driver
*driver
,
85 struct module
*owner
);
86 extern void wmi_driver_unregister(struct wmi_driver
*driver
);
89 * wmi_driver_register() - Helper macro to register a WMI driver
90 * @driver: wmi_driver struct
92 * Helper macro for registering a WMI driver. It automatically passes
93 * THIS_MODULE to the underlying function.
95 #define wmi_driver_register(driver) __wmi_driver_register((driver), THIS_MODULE)
98 * module_wmi_driver() - Helper macro to register/unregister a WMI driver
99 * @__wmi_driver: wmi_driver struct
101 * Helper macro for WMI drivers which do not do anything special in module
102 * init/exit. This eliminates a lot of boilerplate. Each module may only
103 * use this macro once, and calling it replaces module_init() and module_exit().
105 #define module_wmi_driver(__wmi_driver) \
106 module_driver(__wmi_driver, wmi_driver_register, \
107 wmi_driver_unregister)