platform/x86: wmi: introduce helper to retrieve event data
Previously, `acpi_wmi_notify_handler()` and `wmi_get_event_data()` shared more or less the exact same code to query the data for a particular event. Introduce a function to get rid of the duplication, and use it from `acpi_wmi_notify_handler()` and `wmi_get_event_data()`. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210904175450.156801-30-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
51142a0886
commit
25be44f6e2
|
@ -219,6 +219,22 @@ static inline acpi_object_type get_param_acpi_type(const struct wmi_block *wbloc
|
||||||
return ACPI_TYPE_BUFFER;
|
return ACPI_TYPE_BUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static acpi_status get_event_data(const struct wmi_block *wblock, struct acpi_buffer *out)
|
||||||
|
{
|
||||||
|
union acpi_object param = {
|
||||||
|
.integer = {
|
||||||
|
.type = ACPI_TYPE_INTEGER,
|
||||||
|
.value = wblock->gblock.notify_id,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
struct acpi_object_list input = {
|
||||||
|
.count = 1,
|
||||||
|
.pointer = ¶m,
|
||||||
|
};
|
||||||
|
|
||||||
|
return acpi_evaluate_object(wblock->acpi_device->handle, "_WED", &input, out);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Exported WMI functions
|
* Exported WMI functions
|
||||||
*/
|
*/
|
||||||
|
@ -623,22 +639,13 @@ EXPORT_SYMBOL_GPL(wmi_remove_notify_handler);
|
||||||
*/
|
*/
|
||||||
acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out)
|
acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out)
|
||||||
{
|
{
|
||||||
struct acpi_object_list input;
|
|
||||||
union acpi_object params[1];
|
|
||||||
struct wmi_block *wblock;
|
struct wmi_block *wblock;
|
||||||
|
|
||||||
input.count = 1;
|
|
||||||
input.pointer = params;
|
|
||||||
params[0].type = ACPI_TYPE_INTEGER;
|
|
||||||
params[0].integer.value = event;
|
|
||||||
|
|
||||||
list_for_each_entry(wblock, &wmi_block_list, list) {
|
list_for_each_entry(wblock, &wmi_block_list, list) {
|
||||||
struct guid_block *gblock = &wblock->gblock;
|
struct guid_block *gblock = &wblock->gblock;
|
||||||
|
|
||||||
if ((gblock->flags & ACPI_WMI_EVENT) &&
|
if ((gblock->flags & ACPI_WMI_EVENT) && gblock->notify_id == event)
|
||||||
(gblock->notify_id == event))
|
return get_event_data(wblock, out);
|
||||||
return acpi_evaluate_object(wblock->acpi_device->handle,
|
|
||||||
"_WED", &input, out);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return AE_NOT_FOUND;
|
return AE_NOT_FOUND;
|
||||||
|
@ -1303,21 +1310,12 @@ static void acpi_wmi_notify_handler(acpi_handle handle, u32 event,
|
||||||
/* If a driver is bound, then notify the driver. */
|
/* If a driver is bound, then notify the driver. */
|
||||||
if (wblock->dev.dev.driver) {
|
if (wblock->dev.dev.driver) {
|
||||||
struct wmi_driver *driver = drv_to_wdrv(wblock->dev.dev.driver);
|
struct wmi_driver *driver = drv_to_wdrv(wblock->dev.dev.driver);
|
||||||
struct acpi_object_list input;
|
|
||||||
union acpi_object params[1];
|
|
||||||
struct acpi_buffer evdata = { ACPI_ALLOCATE_BUFFER, NULL };
|
struct acpi_buffer evdata = { ACPI_ALLOCATE_BUFFER, NULL };
|
||||||
acpi_status status;
|
acpi_status status;
|
||||||
|
|
||||||
input.count = 1;
|
status = get_event_data(wblock, &evdata);
|
||||||
input.pointer = params;
|
|
||||||
params[0].type = ACPI_TYPE_INTEGER;
|
|
||||||
params[0].integer.value = event;
|
|
||||||
|
|
||||||
status = acpi_evaluate_object(wblock->acpi_device->handle,
|
|
||||||
"_WED", &input, &evdata);
|
|
||||||
if (ACPI_FAILURE(status)) {
|
if (ACPI_FAILURE(status)) {
|
||||||
dev_warn(&wblock->dev.dev,
|
dev_warn(&wblock->dev.dev, "failed to get event data\n");
|
||||||
"failed to get event data\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue