io_uring: split out cmd api into a separate header
[linux-block.git] / include / linux / wmi.h
CommitLineData
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>
44b6b766 14#include <uapi/linux/wmi.h>
844af950 15
b4cc9795
AW
16/**
17 * struct wmi_device - WMI device structure
18 * @dev: Device associated with this WMI device
19 * @setable: True for devices implementing the Set Control Method
20 *
21 * This represents WMI devices discovered by the WMI driver core.
22 */
844af950
AL
23struct wmi_device {
24 struct device dev;
d4fc91ad 25
b4cc9795 26 /* private: used by the WMI driver core */
fd70da6a 27 bool setable;
844af950
AL
28};
29
722c856d
ML
30extern acpi_status wmidev_evaluate_method(struct wmi_device *wdev,
31 u8 instance, u32 method_id,
32 const struct acpi_buffer *in,
33 struct acpi_buffer *out);
34
56a37025
AL
35extern union acpi_object *wmidev_block_query(struct wmi_device *wdev,
36 u8 instance);
37
2a2b13ae
AW
38u8 wmidev_instance_count(struct wmi_device *wdev);
39
44b6b766
ML
40extern int set_required_buffer_size(struct wmi_device *wdev, u64 length);
41
b4cc9795
AW
42/**
43 * struct wmi_driver - WMI driver structure
44 * @driver: Driver model structure
45 * @id_table: List of WMI GUIDs supported by this driver
46 * @no_notify_data: WMI events provide no event data
47 * @probe: Callback for device binding
48 * @remove: Callback for device unbinding
49 * @notify: Callback for receiving WMI events
50 * @filter_callback: Callback for filtering device IOCTLs
51 *
52 * This represents WMI drivers which handle WMI devices.
53 * @filter_callback is only necessary for drivers which
54 * want to set up a WMI IOCTL interface.
55 */
844af950
AL
56struct wmi_driver {
57 struct device_driver driver;
58 const struct wmi_device_id *id_table;
8c33915d 59 bool no_notify_data;
844af950 60
440c4983 61 int (*probe)(struct wmi_device *wdev, const void *context);
2b329f56 62 void (*remove)(struct wmi_device *wdev);
1686f544 63 void (*notify)(struct wmi_device *device, union acpi_object *data);
44b6b766
ML
64 long (*filter_callback)(struct wmi_device *wdev, unsigned int cmd,
65 struct wmi_ioctl_buffer *arg);
844af950
AL
66};
67
68extern int __must_check __wmi_driver_register(struct wmi_driver *driver,
69 struct module *owner);
70extern void wmi_driver_unregister(struct wmi_driver *driver);
b4cc9795
AW
71
72/**
73 * wmi_driver_register() - Helper macro to register a WMI driver
74 * @driver: wmi_driver struct
75 *
76 * Helper macro for registering a WMI driver. It automatically passes
77 * THIS_MODULE to the underlying function.
78 */
844af950
AL
79#define wmi_driver_register(driver) __wmi_driver_register((driver), THIS_MODULE)
80
b4cc9795
AW
81/**
82 * module_wmi_driver() - Helper macro to register/unregister a WMI driver
83 * @__wmi_driver: wmi_driver struct
84 *
85 * Helper macro for WMI drivers which do not do anything special in module
86 * init/exit. This eliminates a lot of boilerplate. Each module may only
87 * use this macro once, and calling it replaces module_init() and module_exit().
88 */
844af950
AL
89#define module_wmi_driver(__wmi_driver) \
90 module_driver(__wmi_driver, wmi_driver_register, \
91 wmi_driver_unregister)
92
93#endif