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.
Unified · Split
| @@ -146,6 +146,28 @@ static bool find_guid(const char *guid_string, struct wmi_block **out) · 145 unmodified lines | |||
| 146 | return false; | 146 | return false; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | static const void *find_guid_context(struct wmi_block *wblock, | ||
| 150 | struct wmi_driver *wdriver) | ||
| 151 | { | ||
| 152 | const struct wmi_device_id *id; | ||
| 153 | uuid_le guid_input; | ||
| 154 | |||
| 155 | if (wblock == NULL || wdriver == NULL) | ||
| 156 | return NULL; | ||
| 157 | if (wdriver->id_table == NULL) | ||
| 158 | return NULL; | ||
| 159 | |||
| 160 | id = wdriver->id_table; | ||
| 161 | while (*id->guid_string) { | ||
| 162 | if (uuid_le_to_bin(id->guid_string, &guid_input)) | ||
| 163 | continue; | ||
| 164 | if (!memcmp(wblock->gblock.guid, &guid_input, 16)) | ||
| 165 | return id->context; | ||
| 166 | id++; | ||
| 167 | } | ||
| 168 | return NULL; | ||
| 169 | } | ||
| 170 | |||
| 149 | static int get_subobj_info(acpi_handle handle, const char *pathname, | 171 | static int get_subobj_info(acpi_handle handle, const char *pathname, |
| 150 | struct acpi_device_info **info) | 172 | struct acpi_device_info **info) |
| 151 | { | 173 | { |
| @@ -798,6 +798,7 @@ struct tee_client_device_id { · 797 unmodified lines | |||
| 798 | */ | 798 | */ |
| 799 | struct wmi_device_id { | 799 | struct wmi_device_id { |
| 800 | const char guid_string[UUID_STRING_LEN+1]; | 800 | const char guid_string[UUID_STRING_LEN+1]; |
| 801 | const void *context; | ||
| 801 | }; | 802 | }; |
| 802 | 803 | ||
| 803 | #endif /* LINUX_MOD_DEVICETABLE_H */ | 804 | #endif /* LINUX_MOD_DEVICETABLE_H */ |