Skip to content

Commit 6ed2d7e

Browse files
Wer-Wolfjwrdegoede
authored andcommitted
platform/x86: wmi: Merge get_event_data() with wmi_get_notify_data()
Since get_event_data() is only called by wmi_get_notify_data(), it makes sense to merge both functions. Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20240901031055.3030-5-W_Armin@gmx.de Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent 79a56f4 commit 6ed2d7e

1 file changed

Lines changed: 17 additions & 26 deletions

File tree

  • drivers/platform/x86

drivers/platform/x86/wmi.c

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -166,22 +166,6 @@ static inline acpi_object_type get_param_acpi_type(const struct wmi_block *wbloc
166166
return ACPI_TYPE_BUFFER;
167167
}
168168

169-
static acpi_status get_event_data(const struct wmi_block *wblock, struct acpi_buffer *out)
170-
{
171-
union acpi_object param = {
172-
.integer = {
173-
.type = ACPI_TYPE_INTEGER,
174-
.value = wblock->gblock.notify_id,
175-
}
176-
};
177-
struct acpi_object_list input = {
178-
.count = 1,
179-
.pointer = &param,
180-
};
181-
182-
return acpi_evaluate_object(wblock->acpi_device->handle, "_WED", &input, out);
183-
}
184-
185169
static int wmidev_match_guid(struct device *dev, const void *data)
186170
{
187171
struct wmi_block *wblock = dev_to_wblock(dev);
@@ -1129,14 +1113,19 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev)
11291113
static int wmi_get_notify_data(struct wmi_block *wblock, union acpi_object **obj)
11301114
{
11311115
struct acpi_buffer data = { ACPI_ALLOCATE_BUFFER, NULL };
1116+
union acpi_object param = {
1117+
.integer = {
1118+
.type = ACPI_TYPE_INTEGER,
1119+
.value = wblock->gblock.notify_id,
1120+
}
1121+
};
1122+
struct acpi_object_list input = {
1123+
.count = 1,
1124+
.pointer = &param,
1125+
};
11321126
acpi_status status;
11331127

1134-
if (test_bit(WMI_NO_EVENT_DATA, &wblock->flags)) {
1135-
*obj = NULL;
1136-
return 0;
1137-
}
1138-
1139-
status = get_event_data(wblock, &data);
1128+
status = acpi_evaluate_object(wblock->acpi_device->handle, "_WED", &input, &data);
11401129
if (ACPI_FAILURE(status)) {
11411130
dev_warn(&wblock->dev.dev, "Failed to get event data\n");
11421131
return -EIO;
@@ -1163,7 +1152,7 @@ static void wmi_notify_driver(struct wmi_block *wblock, union acpi_object *obj)
11631152
static int wmi_notify_device(struct device *dev, void *data)
11641153
{
11651154
struct wmi_block *wblock = dev_to_wblock(dev);
1166-
union acpi_object *obj;
1155+
union acpi_object *obj = NULL;
11671156
u32 *event = data;
11681157
int ret;
11691158

@@ -1179,9 +1168,11 @@ static int wmi_notify_device(struct device *dev, void *data)
11791168
* WMI driver core stops evaluating _WED due to missing
11801169
* WMI event consumers.
11811170
*/
1182-
ret = wmi_get_notify_data(wblock, &obj);
1183-
if (ret < 0)
1184-
return -EIO;
1171+
if (!test_bit(WMI_NO_EVENT_DATA, &wblock->flags)) {
1172+
ret = wmi_get_notify_data(wblock, &obj);
1173+
if (ret < 0)
1174+
return -EIO;
1175+
}
11851176

11861177
down_read(&wblock->notify_lock);
11871178
/* The WMI driver notify handler conflicts with the legacy WMI handler.

0 commit comments

Comments
 (0)