aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/wmi.c
diff options
context:
space:
mode:
authorArmin Wolf <[email protected]>2023-04-30 20:31:52 +0000
committerHans de Goede <[email protected]>2023-05-09 10:07:25 +0000
commit2a2b13ae50cf70e07b471301ff50299f31d81c1d (patch)
treedc0a47eea618886daa8bf328590039b21874c738 /drivers/platform/x86/wmi.c
parentplatform/x86: x86-android-tablets: Add support for extra buttons on Cyberbook... (diff)
downloadkernel-2a2b13ae50cf70e07b471301ff50299f31d81c1d.tar.gz
kernel-2a2b13ae50cf70e07b471301ff50299f31d81c1d.zip
platform/x86: wmi: Allow retrieving the number of WMI object instances
Currently, the WMI driver core knows how many instances of a given WMI object exist, but WMI drivers cannot access this information. At the same time, some current and upcoming WMI drivers want to have access to this information. Add wmi_instance_count() and wmidev_instance_count() to allow WMI drivers to get the number of WMI object instances. Signed-off-by: Armin Wolf <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
Diffstat (limited to 'drivers/platform/x86/wmi.c')
-rw-r--r--drivers/platform/x86/wmi.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index c226dd4163a1..5b95d7aa5c2f 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -264,6 +264,47 @@ int set_required_buffer_size(struct wmi_device *wdev, u64 length)
EXPORT_SYMBOL_GPL(set_required_buffer_size);
/**
+ * wmi_instance_count - Get number of WMI object instances
+ * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
+ *
+ * Get the number of WMI object instances.
+ *
+ * Returns: Number of WMI object instances or negative error code.
+ */
+int wmi_instance_count(const char *guid_string)
+{
+ struct wmi_block *wblock;
+ acpi_status status;
+
+ status = find_guid(guid_string, &wblock);
+ if (ACPI_FAILURE(status)) {
+ if (status == AE_BAD_PARAMETER)
+ return -EINVAL;
+
+ return -ENODEV;
+ }
+
+ return wmidev_instance_count(&wblock->dev);
+}
+EXPORT_SYMBOL_GPL(wmi_instance_count);
+
+/**
+ * wmidev_instance_count - Get number of WMI object instances
+ * @wdev: A wmi bus device from a driver
+ *
+ * Get the number of WMI object instances.
+ *
+ * Returns: Number of WMI object instances.
+ */
+u8 wmidev_instance_count(struct wmi_device *wdev)
+{
+ struct wmi_block *wblock = container_of(wdev, struct wmi_block, dev);
+
+ return wblock->gblock.instance_count;
+}
+EXPORT_SYMBOL_GPL(wmidev_instance_count);
+
+/**
* wmi_evaluate_method - Evaluate a WMI method (deprecated)
* @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
* @instance: Instance index