WMI Driver API¶
The WMI driver core supports a more modern bus-based interface for interactingwith WMI devices, and an older GUID-based interface. The latter interface isconsidered to be deprecated, so new WMI drivers should generally avoid it sinceit has some issues with multiple WMI devices sharing the same GUID.The modern bus-based interface instead maps each WMI device to astructwmi_device, so it supports WMI devices sharing thesame GUID. Drivers can then register astructwmi_driverwhich will be bound to compatible WMI devices by the driver core.
- structwmi_device¶
WMI device structure
Definition:
struct wmi_device { struct device dev; bool setable; const char *driver_override;};Members
devDevice associated with this WMI device
setableTrue for devices implementing the Set Control Method
driver_overrideDriver name to force a match; do not set directly,because core frees it; use
driver_set_override()toset or clear it.
Description
This represents WMI devices discovered by the WMI driver core.
- to_wmi_device¶
to_wmi_device(device)
Helper macro to cast a device to a wmi_device
- structwmi_driver¶
WMI driver structure
Definition:
struct wmi_driver { struct device_driver driver; const struct wmi_device_id *id_table; bool no_notify_data; bool no_singleton; int (*probe)(struct wmi_device *wdev, const void *context); void (*remove)(struct wmi_device *wdev); void (*shutdown)(struct wmi_device *wdev); void (*notify)(struct wmi_device *device, union acpi_object *data);};Members
driverDriver model structure
id_tableList of WMI GUIDs supported by this driver
no_notify_dataDriver supports WMI events which provide no event data
no_singletonDriver can be instantiated multiple times
probeCallback for device binding
removeCallback for device unbinding
shutdownCallback for device shutdown
notifyCallback for receiving WMI events
Description
This represents WMI drivers which handle WMI devices.
- to_wmi_driver¶
to_wmi_driver(drv)
Helper macro to cast a driver to a wmi_driver
- wmi_driver_register¶
wmi_driver_register(driver)
Helper macro to register a WMI driver
Parameters
driverwmi_driver struct
Description
Helper macro for registering a WMI driver. It automatically passesTHIS_MODULE to the underlying function.
- module_wmi_driver¶
module_wmi_driver(__wmi_driver)
Helper macro to register/unregister a WMI driver
Parameters
__wmi_driverwmi_driver struct
Description
Helper macro for WMI drivers which do not do anything special in moduleinit/exit. This eliminates a lot of boilerplate. Each module may onlyuse this macro once, and calling it replacesmodule_init() andmodule_exit().
- intwmi_instance_count(constchar*guid_string)¶
Get number of WMI object instances
Parameters
constchar*guid_string36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
Description
Get the number of WMI object instances.
Return
Number of WMI object instances or negative error code.
- u8wmidev_instance_count(structwmi_device*wdev)¶
Get number of WMI object instances
Parameters
structwmi_device*wdevA wmi bus device from a driver
Description
Get the number of WMI object instances.
Return
Number of WMI object instances.
- acpi_statuswmi_evaluate_method(constchar*guid_string,u8instance,u32method_id,conststructacpi_buffer*in,structacpi_buffer*out)¶
Evaluate a WMI method (deprecated)
Parameters
constchar*guid_string36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
u8instanceInstance index
u32method_idMethod ID to call
conststructacpi_buffer*inMandatory buffer containing input for the method call
structacpi_buffer*outEmpty buffer to return the method results
Description
Call an ACPI-WMI method, the caller must freeout.
Return
acpi_status signaling success or error.
- acpi_statuswmidev_evaluate_method(structwmi_device*wdev,u8instance,u32method_id,conststructacpi_buffer*in,structacpi_buffer*out)¶
Evaluate a WMI method
Parameters
structwmi_device*wdevA wmi bus device from a driver
u8instanceInstance index
u32method_idMethod ID to call
conststructacpi_buffer*inMandatory buffer containing input for the method call
structacpi_buffer*outEmpty buffer to return the method results
Description
Call an ACPI-WMI method, the caller must freeout.
Return
acpi_status signaling success or error.
- acpi_statuswmi_query_block(constchar*guid_string,u8instance,structacpi_buffer*out)¶
Return contents of a WMI block (deprecated)
Parameters
constchar*guid_string36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
u8instanceInstance index
structacpi_buffer*outEmpty buffer to return the contents of the data block to
Description
Query a ACPI-WMI block, the caller must freeout.
Return
ACPI object containing the content of the WMI block.
- unionacpi_object*wmidev_block_query(structwmi_device*wdev,u8instance)¶
Return contents of a WMI block
Parameters
structwmi_device*wdevA wmi bus device from a driver
u8instanceInstance index
Description
Query an ACPI-WMI block, the caller must free the result.
Return
ACPI object containing the content of the WMI block.
- acpi_statuswmi_set_block(constchar*guid_string,u8instance,conststructacpi_buffer*in)¶
Write to a WMI block (deprecated)
Parameters
constchar*guid_string36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
u8instanceInstance index
conststructacpi_buffer*inBuffer containing new values for the data block
Description
Write the contents of the input buffer to an ACPI-WMI data block.
Return
acpi_status signaling success or error.
- acpi_statuswmidev_block_set(structwmi_device*wdev,u8instance,conststructacpi_buffer*in)¶
Write to a WMI block
Parameters
structwmi_device*wdevA wmi bus device from a driver
u8instanceInstance index
conststructacpi_buffer*inBuffer containing new values for the data block
Description
Write contents of the input buffer to an ACPI-WMI data block.
Return
acpi_status signaling success or error.
- acpi_statuswmi_install_notify_handler(constchar*guid,wmi_notify_handlerhandler,void*data)¶
Register handler for WMI events (deprecated)
Parameters
constchar*guid36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
wmi_notify_handlerhandlerFunction to handle notifications
void*dataData to be returned to handler when event is fired
Description
Register a handler for events sent to the ACPI-WMI mapper device.
Return
acpi_status signaling success or error.
- acpi_statuswmi_remove_notify_handler(constchar*guid)¶
Unregister handler for WMI events (deprecated)
Parameters
constchar*guid36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
Description
Unregister handler for events sent to the ACPI-WMI mapper device.
Return
acpi_status signaling success or error.
- boolwmi_has_guid(constchar*guid_string)¶
Check if a GUID is available
Parameters
constchar*guid_string36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
Description
Check if a given GUID is defined by _WDG.
Return
True if GUID is available, false otherwise.
- char*wmi_get_acpi_device_uid(constchar*guid_string)¶
Get _UID name of ACPI device that defines GUID (deprecated)
Parameters
constchar*guid_string36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
Description
Find the _UID of ACPI device associated with this WMI GUID.
Return
The ACPI _UID field value or NULL if the WMI GUID was not found.
- voidwmi_driver_unregister(structwmi_driver*driver)¶
Unregister a WMI driver
Parameters
structwmi_driver*driverWMI driver to unregister
Description
Unregisters a WMI driver from the WMI bus.