[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <a33aa2e6d19e33ef3f602498d7eaa5bdd749269d.1495862272.git.dvhart@infradead.org>
Date: Fri, 26 May 2017 22:31:25 -0700
From: Darren Hart <dvhart@...radead.org>
To: platform-driver-x86@...r.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Andy Lutomirski <luto@...nel.org>,
Andy Lutomirski <luto@...capital.net>,
Mario Limonciello <mario_limonciello@...l.com>,
Pali Rohár <pali.rohar@...il.com>,
Rafael Wysocki <rjw@...ysocki.net>,
linux-kernel@...r.kernel.org, linux-acpi@...r.kernel.org,
Darren Hart <dvhart@...radead.org>
Subject: [PATCH 11/16] platform/x86: wmi: Add a new interface to read block data
From: Andy Lutomirski <luto@...nel.org>
wmi_query_block is unnecessarily indirect. Add a straightforward
method for wmi bus drivers to use to read block data.
Signed-off-by: Andy Lutomirski <luto@...nel.org>
Cc: Andy Lutomirski <luto@...capital.net>
Cc: Mario Limonciello <mario_limonciello@...l.com>
Cc: Pali Rohár <pali.rohar@...il.com>
Cc: Rafael Wysocki <rjw@...ysocki.net>
Cc: linux-kernel@...r.kernel.org
Cc: platform-driver-x86@...r.kernel.org
Cc: linux-acpi@...r.kernel.org
Signed-off-by: Darren Hart (VMware) <dvhart@...radead.org>
---
drivers/platform/x86/wmi.c | 54 ++++++++++++++++++++++++++++++++--------------
include/linux/wmi.h | 4 ++++
2 files changed, 42 insertions(+), 16 deletions(-)
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 208e187..483e4a6 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -244,19 +244,10 @@ u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out)
}
EXPORT_SYMBOL_GPL(wmi_evaluate_method);
-/**
- * wmi_query_block - Return contents of a WMI block
- * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
- * @instance: Instance index
- * &out: Empty buffer to return the contents of the data block to
- *
- * Return the contents of an ACPI-WMI data block to a buffer
- */
-acpi_status wmi_query_block(const char *guid_string, u8 instance,
-struct acpi_buffer *out)
+static acpi_status __query_block(struct wmi_block *wblock, u8 instance,
+ struct acpi_buffer *out)
{
struct guid_block *block = NULL;
- struct wmi_block *wblock = NULL;
acpi_handle handle;
acpi_status status, wc_status = AE_ERROR;
struct acpi_object_list input;
@@ -264,12 +255,9 @@ struct acpi_buffer *out)
char method[5];
char wc_method[5] = "WC";
- if (!guid_string || !out)
+ if (!out)
return AE_BAD_PARAMETER;
- if (!find_guid(guid_string, &wblock))
- return AE_ERROR;
-
block = &wblock->gblock;
handle = wblock->acpi_device->handle;
@@ -320,8 +308,42 @@ struct acpi_buffer *out)
return status;
}
+
+/**
+ * wmi_query_block - Return contents of a WMI block (deprecated)
+ * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
+ * @instance: Instance index
+ * &out: Empty buffer to return the contents of the data block to
+ *
+ * Return the contents of an ACPI-WMI data block to a buffer
+ */
+acpi_status wmi_query_block(const char *guid_string, u8 instance,
+ struct acpi_buffer *out)
+{
+ struct wmi_block *wblock;
+
+ if (!guid_string)
+ return AE_BAD_PARAMETER;
+
+ if (!find_guid(guid_string, &wblock))
+ return AE_ERROR;
+
+ return __query_block(wblock, instance, out);
+}
EXPORT_SYMBOL_GPL(wmi_query_block);
+union acpi_object *wmidev_block_query(struct wmi_device *wdev, u8 instance)
+{
+ struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL };
+ struct wmi_block *wblock = container_of(wdev, struct wmi_block, dev);
+
+ if (ACPI_FAILURE(__query_block(wblock, instance, &out)))
+ return NULL;
+
+ return (union acpi_object *)out.pointer;
+}
+EXPORT_SYMBOL_GPL(wmidev_block_query);
+
/**
* wmi_set_block - Write to a WMI block
* @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
@@ -331,7 +353,7 @@ EXPORT_SYMBOL_GPL(wmi_query_block);
* Write the contents of the input buffer to an ACPI-WMI data block
*/
acpi_status wmi_set_block(const char *guid_string, u8 instance,
-const struct acpi_buffer *in)
+ const struct acpi_buffer *in)
{
struct guid_block *block = NULL;
struct wmi_block *wblock = NULL;
diff --git a/include/linux/wmi.h b/include/linux/wmi.h
index c6eedfd..0ab2540 100644
--- a/include/linux/wmi.h
+++ b/include/linux/wmi.h
@@ -29,6 +29,10 @@ struct wmi_device {
bool readable, writeable;
};
+/* Caller must kfree the result. */
+extern union acpi_object *wmidev_block_query(struct wmi_device *wdev,
+ u8 instance);
+
struct wmi_device_id {
const char *guid_string;
};
--
2.9.4
Powered by blists - more mailing lists