Commit | Line | Data |
---|---|---|
1802d0be | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
844af950 AL |
2 | /* |
3 | * wmi.h - ACPI WMI interface | |
4 | * | |
5 | * Copyright (c) 2015 Andrew Lutomirski | |
844af950 AL |
6 | */ |
7 | ||
8 | #ifndef _LINUX_WMI_H | |
9 | #define _LINUX_WMI_H | |
10 | ||
11 | #include <linux/device.h> | |
12 | #include <linux/acpi.h> | |
eacc95ea | 13 | #include <linux/mod_devicetable.h> |
844af950 | 14 | |
b4cc9795 AW |
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 | * | |
20 | * This represents WMI devices discovered by the WMI driver core. | |
21 | */ | |
844af950 AL |
22 | struct wmi_device { |
23 | struct device dev; | |
fd70da6a | 24 | bool setable; |
844af950 AL |
25 | }; |
26 | ||
7275bf3e AW |
27 | /** |
28 | * to_wmi_device() - Helper macro to cast a device to a wmi_device | |
29 | * @device: device struct | |
30 | * | |
31 | * Cast a struct device to a struct wmi_device. | |
32 | */ | |
33 | #define to_wmi_device(device) container_of(device, struct wmi_device, dev) | |
34 | ||
722c856d ML |
35 | extern acpi_status wmidev_evaluate_method(struct wmi_device *wdev, |
36 | u8 instance, u32 method_id, | |
37 | const struct acpi_buffer *in, | |
38 | struct acpi_buffer *out); | |
39 | ||
56a37025 AL |
40 | extern union acpi_object *wmidev_block_query(struct wmi_device *wdev, |
41 | u8 instance); | |
42 | ||
f25d3464 AW |
43 | acpi_status wmidev_block_set(struct wmi_device *wdev, u8 instance, const struct acpi_buffer *in); |
44 | ||
2a2b13ae AW |
45 | u8 wmidev_instance_count(struct wmi_device *wdev); |
46 | ||
b4cc9795 AW |
47 | /** |
48 | * struct wmi_driver - WMI driver structure | |
49 | * @driver: Driver model structure | |
50 | * @id_table: List of WMI GUIDs supported by this driver | |
4f299135 | 51 | * @no_notify_data: Driver supports WMI events which provide no event data |
a66ccfc2 | 52 | * @no_singleton: Driver can be instantiated multiple times |
b4cc9795 AW |
53 | * @probe: Callback for device binding |
54 | * @remove: Callback for device unbinding | |
55 | * @notify: Callback for receiving WMI events | |
b4cc9795 AW |
56 | * |
57 | * This represents WMI drivers which handle WMI devices. | |
b4cc9795 | 58 | */ |
844af950 AL |
59 | struct wmi_driver { |
60 | struct device_driver driver; | |
61 | const struct wmi_device_id *id_table; | |
8c33915d | 62 | bool no_notify_data; |
a66ccfc2 | 63 | bool no_singleton; |
844af950 | 64 | |
440c4983 | 65 | int (*probe)(struct wmi_device *wdev, const void *context); |
2b329f56 | 66 | void (*remove)(struct wmi_device *wdev); |
1686f544 | 67 | void (*notify)(struct wmi_device *device, union acpi_object *data); |
844af950 AL |
68 | }; |
69 | ||
70 | extern int __must_check __wmi_driver_register(struct wmi_driver *driver, | |
71 | struct module *owner); | |
72 | extern void wmi_driver_unregister(struct wmi_driver *driver); | |
b4cc9795 AW |
73 | |
74 | /** | |
75 | * wmi_driver_register() - Helper macro to register a WMI driver | |
76 | * @driver: wmi_driver struct | |
77 | * | |
78 | * Helper macro for registering a WMI driver. It automatically passes | |
79 | * THIS_MODULE to the underlying function. | |
80 | */ | |
844af950 AL |
81 | #define wmi_driver_register(driver) __wmi_driver_register((driver), THIS_MODULE) |
82 | ||
b4cc9795 AW |
83 | /** |
84 | * module_wmi_driver() - Helper macro to register/unregister a WMI driver | |
85 | * @__wmi_driver: wmi_driver struct | |
86 | * | |
87 | * Helper macro for WMI drivers which do not do anything special in module | |
88 | * init/exit. This eliminates a lot of boilerplate. Each module may only | |
89 | * use this macro once, and calling it replaces module_init() and module_exit(). | |
90 | */ | |
844af950 AL |
91 | #define module_wmi_driver(__wmi_driver) \ |
92 | module_driver(__wmi_driver, wmi_driver_register, \ | |
93 | wmi_driver_unregister) | |
94 | ||
95 | #endif |