platform/x86: wmi: add context pointer field to struct wmi_device_id
authorMattias Jacobsson <2pi@mok.nu>
Mon, 27 May 2019 16:21:29 +0000 (18:21 +0200)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 17 Jun 2019 12:22:47 +0000 (15:22 +0300)
When using wmi_install_notify_handler() to initialize a WMI handler a
data pointer can be supplied which will be passed on to the notification
handler. No similar feature exist when handling WMI events via struct
wmi_driver.

Add a context field pointer to struct wmi_device_id and add a function
find_guid_context() to retrieve that context pointer.

Signed-off-by: Mattias Jacobsson <2pi@mok.nu>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
drivers/platform/x86/wmi.c
include/linux/mod_devicetable.h

index b08ffb769cbe0da4557a4ba90cc25cc9e5e41dab..f3be1c008856f40e84abd571bb150aa964794896 100644 (file)
@@ -146,6 +146,28 @@ static bool find_guid(const char *guid_string, struct wmi_block **out)
        return false;
 }
 
+static const void *find_guid_context(struct wmi_block *wblock,
+                                     struct wmi_driver *wdriver)
+{
+       const struct wmi_device_id *id;
+       uuid_le guid_input;
+
+       if (wblock == NULL || wdriver == NULL)
+               return NULL;
+       if (wdriver->id_table == NULL)
+               return NULL;
+
+       id = wdriver->id_table;
+       while (*id->guid_string) {
+               if (uuid_le_to_bin(id->guid_string, &guid_input))
+                       continue;
+               if (!memcmp(wblock->gblock.guid, &guid_input, 16))
+                       return id->context;
+               id++;
+       }
+       return NULL;
+}
+
 static int get_subobj_info(acpi_handle handle, const char *pathname,
                           struct acpi_device_info **info)
 {
index 448621c32e4d3f9d32cd08e87e3274a64daf09e5..09366859aac23f6bd20a7e7330574792df5999c5 100644 (file)
@@ -798,6 +798,7 @@ struct tee_client_device_id {
  */
 struct wmi_device_id {
        const char guid_string[UUID_STRING_LEN+1];
+       const void *context;
 };
 
 #endif /* LINUX_MOD_DEVICETABLE_H */