[PATCH 1/4] wmi: add a pair of interfaces to set/get wmi driver data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently there is no easy way to associate driver data kind of thing
with wmi drivers thus global variables have to be used to pass that
information between functions. Add a pair of functions to support
that.

Signed-off-by: Yong Wang <yong.y.wang@xxxxxxxxx>
---
 drivers/platform/x86/wmi.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/acpi.h       |    2 ++
 2 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 39ec5b6..706e58f 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -68,6 +68,7 @@ struct wmi_block {
 	wmi_notify_handler handler;
 	void *handler_data;
 	struct device *dev;
+	void *driver_data;
 };
 
 static struct wmi_block wmi_blocks;
@@ -583,6 +584,49 @@ bool wmi_has_guid(const char *guid_string)
 }
 EXPORT_SYMBOL_GPL(wmi_has_guid);
 
+/**
+ * wmi_set_driver_data
+ * @guid: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
+ * @data: Driver specific data
+ *
+ * Set driver specific data
+ */
+acpi_status wmi_set_driver_data(const char *guid, void *data)
+{
+	struct wmi_block *wblock;
+
+	if (!guid)
+		return AE_BAD_PARAMETER;
+
+	if (!find_guid(guid, &wblock))
+		return AE_NOT_EXIST;
+
+	wblock->driver_data = data;
+
+	return AE_OK;
+}
+EXPORT_SYMBOL_GPL(wmi_set_driver_data);
+
+/**
+ * wmi_get_driver_data
+ * @guid: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
+ *
+ * Get driver specific data
+ */
+void *wmi_get_driver_data(const char *guid)
+{
+	struct wmi_block *wblock;
+
+	if (!guid)
+		return NULL;
+
+	if (!find_guid(guid, &wblock))
+		return NULL;
+
+	return wblock->driver_data;
+}
+EXPORT_SYMBOL_GPL(wmi_get_driver_data);
+
 /*
  * sysfs interface
  */
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index b926afe..e56e5e2 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -169,6 +169,8 @@ extern acpi_status wmi_install_notify_handler(const char *guid,
 extern acpi_status wmi_remove_notify_handler(const char *guid);
 extern acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out);
 extern bool wmi_has_guid(const char *guid);
+extern acpi_status wmi_set_driver_data(const char *guid, void *data);
+extern void *wmi_get_driver_data(const char *guid);
 
 #endif	/* CONFIG_ACPI_WMI */
 
-- 
1.5.5.1

--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux