[PATCH 3/7] platform/x86: lenovo-wmi-events: Modernize WMI event handling
From: Rong Zhang
Date: Sun Nov 15 2026 - 14:28:51 EST
The WMI core calls the new notify_new() callback with unmarshaled event
data and size check, aligning with the Windows behavior that the ACPI
object type doesn't matter but the size does.
Adopt it to modernize the driver and hopefully improve robustness on
various firmware, like previously did for lenovo-wmi-{capdata,helpers}.
The blocking_notifier_call_chain() code path is also moved, so that it
will be easier when adding new GUIDs to the driver.
Signed-off-by: Rong Zhang <i@xxxxxxxx>
---
drivers/platform/x86/lenovo/wmi-events.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/drivers/platform/x86/lenovo/wmi-events.c b/drivers/platform/x86/lenovo/wmi-events.c
index 3a82192dc9e5..01ad5bcf0437 100644
--- a/drivers/platform/x86/lenovo/wmi-events.c
+++ b/drivers/platform/x86/lenovo/wmi-events.c
@@ -9,13 +9,14 @@
* Copyright (C) 2025 Derek J. Clark <derekjohn.clark@xxxxxxxxx>
*/
-#include <linux/acpi.h>
#include <linux/export.h>
#include <linux/module.h>
#include <linux/notifier.h>
#include <linux/types.h>
#include <linux/wmi.h>
+#include <asm/byteorder.h>
+
#include "wmi-events.h"
#include "wmi-helpers.h"
@@ -110,25 +111,23 @@ EXPORT_SYMBOL_NS_GPL(devm_lwmi_events_register_notifier, "LENOVO_WMI_EVENTS");
/**
* lwmi_events_notify() - Call functions for the notifier call chain.
* @wdev: The parent WMI device of the driver.
- * @obj: ACPI object passed by the registered WMI Event.
+ * @buf: WMI buffer passed by the registered WMI Event.
*
* Validate WMI event data and notify all registered drivers of the event and
* its output.
*
* Return: 0 on success, or an error code.
*/
-static void lwmi_events_notify(struct wmi_device *wdev, union acpi_object *obj)
+static void lwmi_events_notify(struct wmi_device *wdev, const struct wmi_buffer *buf)
{
struct lwmi_events_priv *priv = dev_get_drvdata(&wdev->dev);
+ void *notif_data = NULL;
int sel_prof;
int ret;
switch (priv->type) {
case LWMI_EVENT_THERMAL_MODE:
- if (obj->type != ACPI_TYPE_INTEGER)
- return;
-
- sel_prof = obj->integer.value;
+ sel_prof = le32_to_cpup(buf->data);
switch (sel_prof) {
case LWMI_GZ_THERMAL_MODE_QUIET:
@@ -136,13 +135,8 @@ static void lwmi_events_notify(struct wmi_device *wdev, union acpi_object *obj)
case LWMI_GZ_THERMAL_MODE_PERFORMANCE:
case LWMI_GZ_THERMAL_MODE_EXTREME:
case LWMI_GZ_THERMAL_MODE_CUSTOM:
- ret = blocking_notifier_call_chain(&events_chain_head,
- LWMI_EVENT_THERMAL_MODE,
- &sel_prof);
- if (ret == NOTIFY_BAD)
- dev_err(&wdev->dev,
- "Failed to send notification to call chain for WMI Events\n");
- return;
+ notif_data = &sel_prof;
+ break;
default:
dev_err(&wdev->dev, "Got invalid thermal mode: %x",
sel_prof);
@@ -152,6 +146,13 @@ static void lwmi_events_notify(struct wmi_device *wdev, union acpi_object *obj)
default:
return;
}
+
+ ret = blocking_notifier_call_chain(&events_chain_head, priv->type, notif_data);
+ if (ret == NOTIFY_BAD) {
+ dev_err(&wdev->dev,
+ "Failed to send notification to call chain for WMI event type %d\n",
+ priv->type);
+ }
}
static int lwmi_events_probe(struct wmi_device *wdev, const void *context)
@@ -185,7 +186,7 @@ static struct wmi_driver lwmi_events_driver = {
.id_table = lwmi_events_id_table,
.min_event_size = sizeof(u32),
.probe = lwmi_events_probe,
- .notify = lwmi_events_notify,
+ .notify_new = lwmi_events_notify,
.no_singleton = true,
};
--
2.55.0